Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/react-native/Libraries/Utilities/HMRClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ const HMRClient: HMRClientNativeInterface = {
invariant(host, 'Missing required parameter `host`');
invariant(!hmrClient, 'Cannot initialize hmrClient twice');

// HMR requires a Metro-served bundle so the server can map source edits back
// to the running module set. When the bundle was loaded from a local file
// there's nothing to hot-reload — registering with the server would just log
// spurious "Unable to resolve module" errors.
if (!getDevServer().bundleLoadedFromServer) {
console.warn(
'Not enabling Hot Module Reloading: the JS bundle was loaded from a local ' +
'file, not from Metro. To use HMR, load the bundle from the packager.',
);
return;
}

// Moving to top gives errors due to NativeModules not being initialized
const DevLoadingView = require('./DevLoadingView').default;

Expand Down
Loading