Bundle headless plugins
Summary: Current temporary limitations: all headless plugins are bundled with Flipper. Reviewed By: antonk52 Differential Revision: D36098168 fbshipit-source-id: c58abe41776157258a5c39a80a5c1a33cf3f42c5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1f2f799772
commit
a6d7f98cfd
@@ -37,6 +37,7 @@ import {
|
||||
rootDir,
|
||||
browserUiDir,
|
||||
serverCoreDir,
|
||||
serverCompanionDir,
|
||||
} from './paths';
|
||||
import pFilter from 'p-filter';
|
||||
import child from 'child_process';
|
||||
@@ -110,6 +111,14 @@ export async function prepareDefaultPlugins(isInsidersBuild: boolean = false) {
|
||||
console.log('✅ Prepared default plugins.');
|
||||
}
|
||||
|
||||
export async function prepareHeadlessPlugins() {
|
||||
console.log(`⚙️ Preparing headless plugins...`);
|
||||
const sourcePlugins = await getSourcePlugins();
|
||||
const headlessPlugins = sourcePlugins.filter((p) => p.headless);
|
||||
await generateHeadlessPluginEntryPoints(headlessPlugins);
|
||||
console.log('✅ Prepared headless plugins.');
|
||||
}
|
||||
|
||||
function getGeneratedIndex(pluginRequires: string) {
|
||||
return `
|
||||
/* eslint-disable */
|
||||
@@ -191,6 +200,28 @@ async function generateDefaultPluginEntryPoints(
|
||||
console.log('✅ Generated bundled plugin entry points.');
|
||||
}
|
||||
|
||||
async function generateHeadlessPluginEntryPoints(
|
||||
headlessPlugins: InstalledPluginDetails[],
|
||||
) {
|
||||
console.log(
|
||||
`⚙️ Generating entry points for ${headlessPlugins.length} headless plugins...`,
|
||||
);
|
||||
const headlessRequires = headlessPlugins
|
||||
.map(
|
||||
(x) =>
|
||||
` '${x.name}': tryRequire('${x.name}', () => require('${x.name}'))`,
|
||||
)
|
||||
.join(',\n');
|
||||
const generatedIndexHeadless = getGeneratedIndex(headlessRequires);
|
||||
await fs.ensureDir(path.join(serverCompanionDir, 'src', 'defaultPlugins'));
|
||||
await fs.writeFile(
|
||||
path.join(serverCompanionDir, 'src', 'defaultPlugins', 'index.tsx'),
|
||||
generatedIndexHeadless,
|
||||
);
|
||||
|
||||
console.log('✅ Generated headless plugin entry points.');
|
||||
}
|
||||
|
||||
async function buildDefaultPlugins(defaultPlugins: InstalledPluginDetails[]) {
|
||||
if (process.env.FLIPPER_NO_REBUILD_PLUGINS) {
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user