Summary: Stop bundling plugins into Flipper Server bundles. In later diffs, we will start building all plugins even in dev mode which removes the need to bundle them. Reviewed By: lblasa Differential Revision: D39276249 fbshipit-source-id: 091405cfcf58aa7e1bd2b382da40f8d9841ae6b1
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {
|
|
ServerAddOn as ServerAddOnFn,
|
|
ServerAddOnStartDetails,
|
|
} from 'flipper-common';
|
|
import {assertNotNull} from '../comms/Utilities';
|
|
import * as FlipperPluginSDK from 'flipper-plugin-core';
|
|
|
|
declare global {
|
|
// eslint-disable-next-line no-var
|
|
var FlipperPlugin: typeof FlipperPluginSDK;
|
|
}
|
|
global.FlipperPlugin = FlipperPluginSDK;
|
|
|
|
interface ServerAddOnModule {
|
|
default: ServerAddOnFn<any, any>;
|
|
}
|
|
|
|
export const loadServerAddOn = (
|
|
pluginName: string,
|
|
details: ServerAddOnStartDetails,
|
|
): ServerAddOnModule => {
|
|
console.debug('loadPlugin', pluginName, details);
|
|
|
|
assertNotNull(
|
|
details.path,
|
|
`loadPlugin -> server add-on path is empty plugin ${pluginName}.`,
|
|
);
|
|
|
|
// eslint-disable-next-line no-eval
|
|
const serverAddOnModule = eval(`require("${details.path}")`);
|
|
return serverAddOnModule;
|
|
};
|