mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Simplify HMR codepath
Reviewed By: davidaurelio Differential Revision: D2839590 fb-gh-sync-id: 9bb14cafc69eec7d7a8712b60435e29f2ba48d3c
This commit is contained in:
committed by
facebook-github-bot-7
parent
4bd39500f8
commit
4afeb4310b
@@ -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);
|
||||
});
|
||||
},
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user