Track plugin changes and notify frontend
Summary: Watch source plugin folders and notify frontend that any of them changed. In subsequent diffs, we will start reloading plugins that changed. Reviewed By: lblasa Differential Revision: D39539443 fbshipit-source-id: 726916c0bce336a2c0179558526bcb1b74e35b93
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3639feef61
commit
c69d102ca1
@@ -15,6 +15,7 @@ import fs from 'fs-extra';
|
||||
import {WebSocketServer} from 'ws';
|
||||
import pFilter from 'p-filter';
|
||||
import {homedir} from 'os';
|
||||
import {InstalledPluginDetails} from 'flipper-common';
|
||||
|
||||
// This file is heavily inspired by scripts/start-dev-server.ts!
|
||||
// part of that is done by start-flipper-server-dev (compiling "main"),
|
||||
@@ -24,6 +25,8 @@ const uiSourceDirs = [
|
||||
'flipper-ui-browser',
|
||||
'flipper-ui-core',
|
||||
'flipper-plugin-core',
|
||||
'flipper-plugin',
|
||||
'flipper-frontend-core',
|
||||
'flipper-common',
|
||||
];
|
||||
|
||||
@@ -65,7 +68,8 @@ export async function attachDevServer(
|
||||
// prevent bundling!
|
||||
const Metro = electronRequire('metro');
|
||||
const MetroResolver = electronRequire('metro-resolver');
|
||||
const {getWatchFolders} = electronRequire('flipper-pkg-lib');
|
||||
const {getWatchFolders, startWatchPlugins} =
|
||||
electronRequire('flipper-pkg-lib');
|
||||
|
||||
const babelTransformationsDir = path.resolve(
|
||||
rootDir,
|
||||
@@ -90,7 +94,6 @@ export async function attachDevServer(
|
||||
uiSourceDirs.map((dir) => getWatchFolders(path.resolve(rootDir, dir))),
|
||||
)
|
||||
).flat(),
|
||||
...(await getPluginSourceFolders()),
|
||||
]);
|
||||
|
||||
const baseConfig = await Metro.loadConfig();
|
||||
@@ -154,6 +157,17 @@ export async function attachDevServer(
|
||||
next();
|
||||
});
|
||||
|
||||
await startWatchPlugins((changedPlugins: InstalledPluginDetails[]) => {
|
||||
socket.clients.forEach((client) => {
|
||||
client.send(
|
||||
JSON.stringify({
|
||||
event: 'plugins-source-updated',
|
||||
payload: changedPlugins,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
console.log('DEV webserver started.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user