Simplify HMR codepath

Reviewed By: davidaurelio

Differential Revision: D2839590

fb-gh-sync-id: 9bb14cafc69eec7d7a8712b60435e29f2ba48d3c
This commit is contained in:
Martín Bigio
2016-01-20 07:13:26 -08:00
committed by facebook-github-bot-7
parent 4bd39500f8
commit 4afeb4310b
7 changed files with 545 additions and 458 deletions

View File

@@ -168,18 +168,18 @@ function attachHMRServer({httpServer, path, packagerServer}) {
entryFile: client.bundleEntry,
platform: client.platform,
modules: modulesToUpdate,
});
})
})
.then(update => {
if (!client) {
.then(bundle => {
if (!client || !bundle) {
return;
}
// check we actually want to send an HMR update
if (update) {
const hmrUpdate = bundle.getSource();
if (hmrUpdate) {
return JSON.stringify({
type: 'update',
body: update,
body: hmrUpdate,
});
}
})
@@ -206,15 +206,12 @@ function attachHMRServer({httpServer, path, packagerServer}) {
return JSON.stringify({type: 'error', body});
})
.then(bundle => {
.then(update => {
if (!client) {
return;
}
// check we actually want to send an HMR update
if (bundle) {
client.ws.send(bundle);
}
client.ws.send(update);
});
},
() => {