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:
Anton Nikolaev
2020-04-20 06:01:08 -07:00
committed by Facebook GitHub Bot
parent eb34b2f6e3
commit ca2d04a5da
22 changed files with 329 additions and 163 deletions

View File

@@ -96,15 +96,15 @@ function getBundledPlugins(): Array<PluginDefinition> {
}
return bundledPlugins
.filter((plugin) => notNull(plugin.out))
.filter((plugin) => notNull(plugin.entry))
.map(
(plugin) =>
({
...plugin,
out: path.join(pluginPath, plugin.out!),
entry: path.resolve(pluginPath, plugin.entry!),
} as PluginDefinition),
)
.concat(bundledPlugins.filter((plugin) => !plugin.out));
.concat(bundledPlugins.filter((plugin) => !plugin.entry));
}
export function getDynamicPlugins() {
@@ -155,8 +155,8 @@ export const requirePlugin = (
pluginDefinition: PluginDefinition,
): typeof FlipperPlugin | typeof FlipperDevicePlugin | null => {
try {
let plugin = pluginDefinition.out
? reqFn(pluginDefinition.out)
let plugin = pluginDefinition.entry
? reqFn(pluginDefinition.entry)
: defaultPluginsIndex[pluginDefinition.name];
if (plugin.default) {
plugin = plugin.default;