Versioning for plugin format
Summary: Added versioning for plugin format. The first version is where "main" points to source code entry and plugins are bundled by Flipper in run-time on loading them. The second version is where "main" points to the already existing bundle and Flipper just loads it without bundling. The plugins of version 2 must be bundled using "flipper-pkg" tool before publishing. Changelog: Support new packaging format for plugins. Reviewed By: mweststrate Differential Revision: D21074173 fbshipit-source-id: 7b70250e48e5bd5d359c96149fb5b14e67783c4d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eb34b2f6e3
commit
ca2d04a5da
@@ -4,7 +4,7 @@
|
||||
"description": "Utility for building and publishing Flipper plugins",
|
||||
"repository": "facebook/flipper",
|
||||
"main": "lib/index.js",
|
||||
"flipper:source": "src",
|
||||
"flipperBundlerEntry": "src",
|
||||
"types": "lib/index.d.ts",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as inquirer from 'inquirer';
|
||||
import * as path from 'path';
|
||||
import * as yarn from '../utils/yarn';
|
||||
import cli from 'cli-ux';
|
||||
import {runBuild} from 'flipper-pkg-lib';
|
||||
import {runBuild, getPluginDetails} from 'flipper-pkg-lib';
|
||||
|
||||
async function deriveOutputFileName(inputDirectory: string): Promise<string> {
|
||||
const packageJson = await readJSON(path.join(inputDirectory, 'package.json'));
|
||||
@@ -100,22 +100,14 @@ export default class Bundle extends Command {
|
||||
await yarn.install(inputDirectory);
|
||||
cli.action.stop();
|
||||
|
||||
cli.action.start('Reading package.json');
|
||||
const packageJson = await readJSON(
|
||||
path.join(inputDirectory, 'package.json'),
|
||||
);
|
||||
const entry =
|
||||
packageJson.main ??
|
||||
((await pathExists(path.join(inputDirectory, 'index.tsx')))
|
||||
? 'index.tsx'
|
||||
: 'index.jsx');
|
||||
const bundleMain = packageJson.bundleMain ?? path.join('dist', 'index.js');
|
||||
const out = path.resolve(inputDirectory, bundleMain);
|
||||
cli.action.stop(`done. Entry: ${entry}. Bundle main: ${bundleMain}.`);
|
||||
cli.action.start('Reading plugin details');
|
||||
const plugin = await getPluginDetails(inputDirectory);
|
||||
const out = path.resolve(inputDirectory, plugin.main);
|
||||
cli.action.stop(`done. Source: ${plugin.source}. Main: ${plugin.main}.`);
|
||||
|
||||
cli.action.start(`Compiling`);
|
||||
await ensureDir(path.dirname(out));
|
||||
await runBuild(inputDirectory, entry, out);
|
||||
await runBuild(inputDirectory, plugin.source, out);
|
||||
cli.action.stop();
|
||||
|
||||
cli.action.start(`Packing to ${outputFile}`);
|
||||
|
||||
Reference in New Issue
Block a user