From e6d32d8a49bbdae6ecb4dd964b6d12fdcb98805a Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 18 Jul 2019 11:05:44 -0700 Subject: [PATCH] Register the bundle regardless of whether Fast Refresh is on Summary: We want to move to a world where Fast Refresh is on by default. As a first step, we can register the bundle early. This means we'll start receiving hot updates via the socket even if Fast Refresh is off. We'll just be ignoring those. Anecdotally people with Fast Refresh on have had good experience even with invasive changes like branch switches. So this seems like a good way to test the waters further. It's also a prerequisite to unlocking a nicer experience where you can turn it on anytime and "catch up" on the changes you've missed. (That's out of scope of this diff.) Reviewed By: cpojer Differential Revision: D16344019 fbshipit-source-id: 6e5f8278909810b32c80e0af010251c876e4313b --- Libraries/Utilities/HMRClient.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js index d806150aacd..8f168908736 100644 --- a/Libraries/Utilities/HMRClient.js +++ b/Libraries/Utilities/HMRClient.js @@ -53,6 +53,10 @@ const HMRClient: HMRClientNativeInterface = { invariant(hmrClient, 'Expected HMRClient.setup() call at startup.'); hmrClient.shouldApplyUpdates = true; + // We use this for internal logging only. + // It doesn't affect the logic. + hmrClient.send(JSON.stringify({type: 'log-opt-in'})); + // Intentionally reading it outside the condition // so that it's less likely we'd break it later. const modules = (require: any).getModules(); @@ -73,8 +77,6 @@ const HMRClient: HMRClientNativeInterface = { // Don't warn about the same modules twice. hmrClient.outdatedModules.clear(); } - - registerBundleEntryPoints(hmrClient); }, disable() { @@ -223,6 +225,8 @@ Error: ${e.message}`; } else { HMRClient.disable(); } + + registerBundleEntryPoints(hmrClient); }, };