Install pre-bundled packages 2/N

Summary: A first simple version of pre-bundled plugin installation. Currently both pre-bundled and source-only plugins are supported. Pre-bundled plugins should have folder "dist" inside and package.json's "main" field should point to the entry point script there.

Reviewed By: passy

Differential Revision: D19834020

fbshipit-source-id: 7e0b495fb9666acbb22fc32ca2382339cd9dc72f
This commit is contained in:
Anton Nikolaev
2020-02-12 04:55:55 -08:00
committed by Facebook Github Bot
parent c315691b2d
commit 707759f096
3 changed files with 29 additions and 23 deletions

View File

@@ -210,9 +210,17 @@ async function compilePlugin(
pluginCache,
options,
) {
const isPreBundled = fs.existsSync(path.join(rootDir, 'dist'));
const result = Object.assign({}, packageJSON, {rootDir, name, entry});
if (isPreBundled) {
// eslint-disable-next-line no-console
console.log(`🥫 Using pre-built version of ${name}...`);
result.out = path.resolve(rootDir, result.main);
return result;
}
const fileName = `${name}@${packageJSON.version || '0.0.0'}.js`;
const out = path.join(pluginCache, fileName);
const result = Object.assign({}, packageJSON, {rootDir, name, entry, out});
result.out = out;
// check if plugin needs to be compiled
const rootDirCtime = await mostRecentlyChanged(rootDir);
if (