diff --git a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx index 38f22bee3..75bd1b3f0 100644 --- a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx +++ b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx @@ -61,8 +61,11 @@ export function initializeRenderHost( async requirePlugin(path) { // TODO: use `await import(path)`? const source = await flipperServer.exec('plugin-source', path); - // eslint-disable-next-line no-eval - return eval(source); + // eslint-disable-next-line no-new-func + const cjsLoader = new Function('module', source); + const theModule = {exports: {}}; + cjsLoader(theModule); + return theModule.exports; }, getStaticResourceUrl(path): string { // the 'static' folder is mounted as static middleware in Express at the root diff --git a/desktop/scripts/build-flipper-server-release.ts b/desktop/scripts/build-flipper-server-release.ts index 0021ffa50..e7cfa9b81 100644 --- a/desktop/scripts/build-flipper-server-release.ts +++ b/desktop/scripts/build-flipper-server-release.ts @@ -46,6 +46,11 @@ const argv = yargs type: 'boolean', default: true, }, + 'enabled-plugins': { + describe: + 'Load only specified plugins and skip loading rest. This is useful when you are developing only one or few plugins. Plugins to load can be specified as a comma-separated list with either plugin id or name used as identifier, e.g. "--enabled-plugins network,inspector". The flag is not provided by default which means that all plugins loaded.', + type: 'array', + }, }) .version('DEV') .help() @@ -76,6 +81,10 @@ if (argv['public-build'] === true) { delete process.env.FLIPPER_FORCE_PUBLIC_BUILD; } +if (argv['enabled-plugins'] !== undefined) { + process.env.FLIPPER_ENABLED_PLUGINS = argv['enabled-plugins'].join(','); +} + (async () => { console.log(`⚙️ Starting build-flipper-server-release`); diff --git a/desktop/static/index.web.html b/desktop/static/index.web.html index 4448c9dab..f3883d86e 100644 --- a/desktop/static/index.web.html +++ b/desktop/static/index.web.html @@ -57,26 +57,12 @@ - -