mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
abc663dd5a
Summary: Running a PROD JS bundle with a DEV binary used to redbox with Fast Refresh on. The error said "HMRClient is not a registered callable module". This isn't a new issue: https://www.google.com/search?q=%22hmrclient%20is%20not%20a%20registered%22. However, now it happens every time because `setup()` is now called unconditionally in a DEV native build. Because a combination of DEV binary + PROD JS is technically possible, I'm adding a tiny shim that will make it a no-op instead of crashing. It will also explain what's wrong if you *intentionally* try to turn on Fast Refresh. Reviewed By: sahrens Differential Revision: D16145378 fbshipit-source-id: 0b9c0a6f30c02ca7f4a0133048450bdde3576ad2
28 lines
691 B
JavaScript
28 lines
691 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
import type {HMRClientNativeInterface} from './HMRClient';
|
|
|
|
// This shim ensures DEV binary builds don't crash in JS
|
|
// when they're combined with a PROD JavaScript build.
|
|
const HMRClientProdShim: HMRClientNativeInterface = {
|
|
setup() {},
|
|
enable() {
|
|
console.error(
|
|
'Fast Refresh is disabled in JavaScript bundles built in production mode. ' +
|
|
'Did you forget to run Metro?',
|
|
);
|
|
},
|
|
disable() {},
|
|
};
|
|
|
|
module.exports = HMRClientProdShim;
|