Launch without plugin hot reload in case plugin change detection failed to start

Summary: Launch without plugin hot reload in case plugin change detection failed to start

Reviewed By: mweststrate

Differential Revision: D19264418

fbshipit-source-id: 089f818b9101d924c504c7d96f71ebca11c9422f
This commit is contained in:
Anton Nikolaev
2020-01-07 06:54:39 -08:00
committed by Facebook Github Bot
parent 205e04fe6c
commit 857b9816a0
5 changed files with 79 additions and 56 deletions

View File

@@ -127,17 +127,29 @@ async function addWebsocket(server) {
// refresh the app on changes to the src folder
// this can be removed once metroServer notifies us about file changes
const watchman = new Watchman(path.resolve(__dirname, '..', 'src'));
await watchman.initialize();
await watchman.startWatchFiles(
'/',
resp => {
io.emit('refresh');
},
{
excludes: ['**/__tests__/**/*', '**/node_modules/**/*', '**/.*'],
},
);
try {
const watchman = new Watchman(path.resolve(__dirname, '..', 'src'));
await watchman.initialize();
await watchman.startWatchFiles(
'',
() => {
io.emit('refresh');
},
{
excludes: [
'**/__tests__/**/*',
'**/node_modules/**/*',
'**/.*',
'plugins/**/*', // plugin changes are tracked separately, so exlcuding them here to avoid double reloading.
],
},
);
} catch (err) {
console.error(
'Failed to start watching for changes using Watchman, continue without hot reloading',
err,
);
}
return io;
}