mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 02:04:55 +00:00
Make sure client is still connected while computing HMR update
Reviewed By: vjeux Differential Revision: D2803506 fb-gh-sync-id: a182343947d52724e48709a8114fa48e8c97a7e2
This commit is contained in:
parent
0b15418d92
commit
bdbadfd966
@ -113,6 +113,10 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||||||
|
|
||||||
return packagerServer.getShallowDependencies(filename)
|
return packagerServer.getShallowDependencies(filename)
|
||||||
.then(deps => {
|
.then(deps => {
|
||||||
|
if (!client) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// if the file dependencies have change we need to invalidate the
|
// if the file dependencies have change we need to invalidate the
|
||||||
// dependencies caches because the list of files we need to send
|
// dependencies caches because the list of files we need to send
|
||||||
// to the client may have changed
|
// to the client may have changed
|
||||||
@ -129,6 +133,10 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||||||
dependenciesModulesCache,
|
dependenciesModulesCache,
|
||||||
shallowDependencies,
|
shallowDependencies,
|
||||||
}) => {
|
}) => {
|
||||||
|
if (!client) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// build list of modules for which we'll send HMR updates
|
// build list of modules for which we'll send HMR updates
|
||||||
const modulesToUpdate = [];
|
const modulesToUpdate = [];
|
||||||
Object.keys(dependenciesModulesCache).forEach(module => {
|
Object.keys(dependenciesModulesCache).forEach(module => {
|
||||||
@ -146,6 +154,10 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(modulesToUpdate => {
|
.then(modulesToUpdate => {
|
||||||
|
if (!client) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// make sure the file was modified is part of the bundle
|
// make sure the file was modified is part of the bundle
|
||||||
if (!client.shallowDependencies[filename]) {
|
if (!client.shallowDependencies[filename]) {
|
||||||
return;
|
return;
|
||||||
@ -158,6 +170,11 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(bundle => {
|
.then(bundle => {
|
||||||
|
if (!client) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check we actually want to send an HMR update
|
||||||
if (bundle) {
|
if (bundle) {
|
||||||
client.ws.send(bundle);
|
client.ws.send(bundle);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user