Bundle operation implementation
Summary: Plugin bundling operation implemented in flipper-pkg Reviewed By: passy Differential Revision: D20191845 fbshipit-source-id: 6a7156debf96668c323dcb740b33542f129f0689
This commit is contained in:
committed by
Facebook Github Bot
parent
6766fb9d56
commit
3ddd1c14f2
@@ -38,6 +38,7 @@ export type PluginManifest = {
|
||||
version: string;
|
||||
name: string;
|
||||
main?: string;
|
||||
bundleMain?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
@@ -245,14 +246,12 @@ async function compilePlugin(
|
||||
options: DynamicCompileOptions,
|
||||
): Promise<CompiledPluginInfo | null> {
|
||||
const {rootDir, manifest, entry, name} = pluginInfo;
|
||||
const isPreBundled = fs.existsSync(path.join(rootDir, 'dist'));
|
||||
if (isPreBundled) {
|
||||
const bundleMain = manifest.bundleMain ?? path.join('dist', 'index.js');
|
||||
const bundlePath = path.join(rootDir, bundleMain);
|
||||
if (fs.existsSync(bundlePath)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`🥫 Using pre-built version of ${name}...`);
|
||||
const out = path.join(
|
||||
rootDir,
|
||||
manifest.main ?? path.join('dist', 'index.js'),
|
||||
);
|
||||
const out = path.join(rootDir, bundleMain);
|
||||
console.log(`🥫 Using pre-built version of ${name}: ${out}...`);
|
||||
return Object.assign({}, pluginInfo.manifest, {out});
|
||||
} else {
|
||||
const out = path.join(
|
||||
|
||||
Reference in New Issue
Block a user