/** * 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; } 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; };