Use setGlobalObject from flipper-frontned-core in flipper-ui-core

Summary: See D37139129

Reviewed By: lblasa

Differential Revision: D37236905

fbshipit-source-id: aeb4c02cfc0e57d262fa59c045fa542819ee988c
This commit is contained in:
Andrey Goncharov
2022-06-20 12:18:40 -07:00
committed by Facebook GitHub Bot
parent 851270589f
commit 68e2bc73c9

View File

@@ -48,29 +48,25 @@ import {isDevicePluginDefinition} from '../utils/pluginUtils';
import isPluginCompatible from '../utils/isPluginCompatible'; import isPluginCompatible from '../utils/isPluginCompatible';
import isPluginVersionMoreRecent from '../utils/isPluginVersionMoreRecent'; import isPluginVersionMoreRecent from '../utils/isPluginVersionMoreRecent';
import {createSandyPluginWrapper} from '../utils/createSandyPluginWrapper'; import {createSandyPluginWrapper} from '../utils/createSandyPluginWrapper';
import {getRenderHostInstance} from 'flipper-frontend-core'; import {getRenderHostInstance, setGlobalObject} from 'flipper-frontend-core';
import pMap from 'p-map'; import pMap from 'p-map';
import * as deprecatedExports from '../deprecated-exports'; import * as deprecatedExports from '../deprecated-exports';
let defaultPluginsIndex: any = null; let defaultPluginsIndex: any = null;
export default async (store: Store, _logger: Logger) => { export default async (store: Store, _logger: Logger) => {
// expose Flipper and exact globally for dynamically loaded plugins setGlobalObject({
const globalObject = (function (this: any) { React,
return this; ReactDOM,
})(); ReactDOMClient,
ReactIs,
// this list should match `replace-flipper-requires.tsx` and the `builtInModules` in `desktop/.eslintrc` Flipper: deprecatedExports,
globalObject.React = React; FlipperPlugin: FlipperPluginSDK,
globalObject.ReactDOM = ReactDOM; Immer,
globalObject.ReactDOMClient = ReactDOMClient; antd,
globalObject.ReactIs = ReactIs; emotion_styled,
globalObject.Flipper = deprecatedExports; antdesign_icons,
globalObject.FlipperPlugin = FlipperPluginSDK; });
globalObject.Immer = Immer;
globalObject.antd = antd;
globalObject.emotion_styled = emotion_styled;
globalObject.antdesign_icons = antdesign_icons;
const gatekeepedPlugins: Array<ActivatablePluginDetails> = []; const gatekeepedPlugins: Array<ActivatablePluginDetails> = [];
const disabledPlugins: Array<ActivatablePluginDetails> = []; const disabledPlugins: Array<ActivatablePluginDetails> = [];