mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
93bebf146f
Summary:
This diff builds on the previous ones and changes the setup process from using the WebSocket URL to using a message that is sent after the connection is established. It also exposes a function on the HMRClient that allows registering more bundles, which I will make use of in the next (and hopefully final :D ) diff.
I was initially planning on using structured data, like `{bundleName, platform}` but decided to keep using URLs as that is the format used throughout Metro. In fact, when we parse the options from the URL, we need to re-encode the input URL to create the `sourceMapUrl`. I thought it doesn't make sense to write more code to send structured data over the connection only to re-construct a URL on the server manually.
Finally, I also slightly modified the "Internal Bundler" error that is shown in a RedBox (now used by the websocket connection if an invalid message is received). I removed the "internal" wording from the message and I'm actually attaching the failure message to the error instead of directing users to the Terminal.
Reviewed By: gaearon
Differential Revision: D16162729
fbshipit-source-id: 977fde5f6c2f1c14efb4fd99ed30a6bf95a3b13e
29 lines
714 B
JavaScript
29 lines
714 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() {},
|
|
registerBundle() {},
|
|
};
|
|
|
|
module.exports = HMRClientProdShim;
|