From a62242163440a9b3d7d00356d095d7335db198b2 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 9 Jul 2019 03:12:53 -0700 Subject: [PATCH] Add `registerEntryPoint` to HmrServer Summary: This diff changes a few things around so that a diff coming on top of this stack will be smaller. The aim of this change is to add a method `registerEntryPoint` which will allow a client to subscribe to updates for multiple bundles. Reviewed By: gaearon Differential Revision: D16131963 fbshipit-source-id: d460d6647b15a711021c7a3a51f52486a1aea535 --- Libraries/Utilities/HMRClient.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js index c959f32fd7..aadb0d0cff 100644 --- a/Libraries/Utilities/HMRClient.js +++ b/Libraries/Utilities/HMRClient.js @@ -101,20 +101,14 @@ const HMRClient: HMRClientNativeInterface = { invariant(bundleEntry, 'Missing required paramenter `bundleEntry`'); invariant(host, 'Missing required paramenter `host`'); invariant(!hmrClient, 'Cannot initialize hmrClient twice'); + // Moving to top gives errors due to NativeModules not being initialized const HMRLoadingView = require('./HMRLoadingView'); - const wsHostPort = port !== null && port !== '' ? `${host}:${port}` : host; - - bundleEntry = bundleEntry.replace(/\.(bundle|delta)/, '.js'); - - // Build the websocket url - const wsUrl = - `ws://${wsHostPort}/hot?` + - `platform=${platform}&` + - `bundleEntry=${bundleEntry}`; - - const client = new MetroHMRClient(wsUrl); + const wsHost = port !== null && port !== '' ? `${host}:${port}` : host; + const client = new MetroHMRClient( + `ws://${wsHost}/hot?bundleEntry=${bundleEntry}&platform=${platform}`, + ); hmrClient = client; client.on('connection-error', e => {