Watch and rebuild plugins

Summary: Now, once we build all plugins before we start Flipper, we need to rebuild some of them when they change. Previously, it was handled by Metro when we included plugins int he bundle, but we no longer include them in the bundle.

Reviewed By: lblasa

Differential Revision: D39510213

fbshipit-source-id: a352d78946f844a25d9127ac09c26e43e6739ca9
This commit is contained in:
Andrey Goncharov
2022-09-15 10:02:19 -07:00
committed by Facebook GitHub Bot
parent 9dda947371
commit 3639feef61
4 changed files with 71 additions and 14 deletions

View File

@@ -37,6 +37,7 @@ import {
import pFilter from 'p-filter';
import child from 'child_process';
import pMap from 'p-map';
import chalk from 'chalk';
const dev = process.env.NODE_ENV !== 'production';
@@ -510,3 +511,17 @@ function defaultResolve(...rest: any[]) {
...rest,
);
}
export async function rebuildPlugin(pluginPath: string) {
try {
await runBuild(pluginPath, true);
console.info(chalk.green('Rebuilt plugin'), pluginPath);
} catch (e) {
console.error(
chalk.red(
'Failed to compile a plugin, waiting for additional changes...',
),
e,
);
}
}