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
This commit is contained in:
Родитель
88e18b6c8d
Коммит
a622421634
|
@ -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 => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче