Expose a subset of flipper-plugin to flipper server
Summary: Flipper plugins rely on 'flipper-plugin' package being accessible from 'global'. Expose a subset (without UI stuff) of flipper-plugin to server add-ons Reviewed By: mweststrate Differential Revision: D34400811 fbshipit-source-id: e0079ddfa67e66c1b24ab02d7682917ddfc84aaf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9449f61adb
commit
aec05533d7
@@ -12,9 +12,24 @@ import {
|
||||
ServerAddOnStartDetails,
|
||||
} from 'flipper-common';
|
||||
import {assertNotNull} from '../comms/Utilities';
|
||||
// Special subset of flipper-plugin exports designed for server-side usage
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import * as FlipperPluginSDK from 'flipper-plugin/src/server';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var FlipperPlugin: typeof FlipperPluginSDK;
|
||||
}
|
||||
global.FlipperPlugin = FlipperPluginSDK;
|
||||
|
||||
// defaultPlugins has to be required after we set FlipperPlugin.
|
||||
// In server add-ons, developers might import utilities from 'flipper-plugin'
|
||||
// In babel-transformer/plugin-flipper-requires flipper-plugin is replaces with global.FlipperPlugin.
|
||||
// If defaultPlugins is required before we set global.FlipperPlugin,
|
||||
// then flipper-plugin replaced with global.FlipperPlugin is evaluated in server add-ons before we set it - to undefined.
|
||||
//
|
||||
// The file is generated automatically by "prepareDefaultPlugins" in "scripts"
|
||||
// @ts-ignore
|
||||
import defaultPlugins from '../defaultPlugins';
|
||||
const defaultPlugins = require('../defaultPlugins').default;
|
||||
|
||||
interface ServerAddOnModule {
|
||||
default: ServerAddOnFn<any, any>;
|
||||
|
||||
Reference in New Issue
Block a user