Move unloadModule to RenderHost
Summary: Define unload module on RenderHost. Not sure how to do that the browser and not sure how meaning full it is in a browser context. Reviewed By: nikoant Differential Revision: D32827050 fbshipit-source-id: 87025c6f5c2b950880712bff8df1c92a044a222e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6c7a139554
commit
d0402d7268
@@ -195,6 +195,13 @@ export function initializeElectron(
|
||||
!flipperServerConfig.environmentInfo.isProduction,
|
||||
);
|
||||
},
|
||||
unloadModule(path: string) {
|
||||
const resolvedPath = global.electronRequire.resolve(path);
|
||||
if (!resolvedPath || !global.electronRequire.cache[resolvedPath]) {
|
||||
return;
|
||||
}
|
||||
delete global.electronRequire.cache[resolvedPath];
|
||||
},
|
||||
} as RenderHost;
|
||||
|
||||
setupMenuBar();
|
||||
|
||||
@@ -12,7 +12,6 @@ import type {PluginNotification} from './reducers/notifications';
|
||||
import type {NotificationConstructorOptions} from 'electron';
|
||||
import {FlipperLib} from 'flipper-plugin';
|
||||
import {FlipperServer, FlipperServerConfig} from 'flipper-common';
|
||||
import {IconSize} from './ui/components/Glyph';
|
||||
import {Icon} from './utils/icons';
|
||||
|
||||
// Events that are emitted from the main.ts ovr the IPC process bridge in Electron
|
||||
@@ -102,6 +101,7 @@ export interface RenderHost {
|
||||
getStaticResourceUrl(relativePath: string): string;
|
||||
// given the requested icon and proposed public url of the icon, rewrite it to a local icon if needed
|
||||
getLocalIconUrl?(icon: Icon, publicUrl: string): string;
|
||||
unloadModule?(path: string): void;
|
||||
}
|
||||
|
||||
export function getRenderHostInstance(): RenderHost {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
jest.mock('../plugins');
|
||||
jest.mock('../../utils/electronModuleCache');
|
||||
import {
|
||||
loadPlugin,
|
||||
switchPlugin,
|
||||
|
||||
@@ -22,7 +22,6 @@ import {requirePlugin} from './plugins';
|
||||
import {showErrorNotification} from '../utils/notifications';
|
||||
import {PluginDefinition} from '../plugin';
|
||||
import type Client from '../Client';
|
||||
import {unloadModule} from '../utils/electronModuleCache';
|
||||
import {
|
||||
pluginLoaded,
|
||||
pluginUninstalled,
|
||||
@@ -373,5 +372,5 @@ function unloadPluginModule(plugin: ActivatablePluginDetails) {
|
||||
// We cannot unload bundled plugin.
|
||||
return;
|
||||
}
|
||||
unloadModule(plugin.entry);
|
||||
getRenderHostInstance().unloadModule?.(plugin.entry);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
export function unloadModule(path: string) {
|
||||
const resolvedPath = global.electronRequire.resolve(path);
|
||||
if (!resolvedPath || !global.electronRequire.cache[resolvedPath]) {
|
||||
return;
|
||||
}
|
||||
delete global.electronRequire.cache[resolvedPath];
|
||||
}
|
||||
Reference in New Issue
Block a user