Option to load only specific plugins in dev mode

Summary: Currently we load all the plugins even if they are not required in dev mode, e.g. when you are developing a specific plugin. This diff adds an env var and command-line option to specify exact list of plugins to load. This makes dev mode startup faster and consume less memory.

Reviewed By: passy

Differential Revision: D24394146

fbshipit-source-id: 42a78c1ffb2632e657c2411e34e9c80fff18df3a
This commit is contained in:
Anton Nikolaev
2020-10-22 11:34:24 -07:00
committed by Facebook GitHub Bot
parent 966d748ace
commit 2d9cf5a905
6 changed files with 140 additions and 18 deletions

View File

@@ -29,7 +29,21 @@ export async function getSourcePlugins(): Promise<PluginDetails[]> {
entryPoints[key] = p[key];
});
}
return Object.values(entryPoints);
const allPlugins = Object.values(entryPoints);
if (process.env.FLIPPER_ENABLED_PLUGINS) {
const pluginNames = new Set<string>(
process.env.FLIPPER_ENABLED_PLUGINS.split(',').map((x) =>
x.toLowerCase(),
),
);
return allPlugins.filter(
(x) =>
pluginNames.has(x.name) ||
pluginNames.has(x.id) ||
pluginNames.has(x.name.replace('flipper-plugin-', '')),
);
}
return allPlugins;
}
async function entryPointForPluginFolder(
pluginsDir: string,