Fix require monkey-patching in electron build
Summary:
In D39311893 (094c5bdfdd) we started monkey-patching `require` to resolve global dependencies in the plugins. Apparently, patching `globalThis.require` did not work in the electron env. On my local machine it kept working because I had the experimental `flipper-server` feature enabled which embeds flipper-server into the electron build. In flipper-server we properly patch `require` via `Module.prototype.require` which affected the global require in electron.
With this fix we now properly patch require in electron via Module.prototype.require all the time
Changelog: Fix plugin loading with experimental flipper-server disabled
Reviewed By: nikoant
Differential Revision: D39633821
fbshipit-source-id: 9554f643c625620d116075ae87f573d8447850f6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d600203627
commit
8716761cb3
@@ -37,6 +37,7 @@ import {
|
||||
parseEnvironmentVariables,
|
||||
setLoggerInstance,
|
||||
Settings,
|
||||
wrapRequire,
|
||||
} from 'flipper-common';
|
||||
import constants from './fb-stubs/constants';
|
||||
import {initializeElectron} from './electron/initializeElectron';
|
||||
@@ -48,7 +49,9 @@ import {KeytarModule} from 'flipper-server-core/src/utils/keytar';
|
||||
import {initCompanionEnv} from 'flipper-server-companion';
|
||||
import ReconnectingWebSocket from 'reconnecting-websocket';
|
||||
import WS from 'ws';
|
||||
import {Module} from 'module';
|
||||
|
||||
Module.prototype.require = wrapRequire(Module.prototype.require);
|
||||
enableMapSet();
|
||||
|
||||
async function getKeytarModule(staticPath: string): Promise<KeytarModule> {
|
||||
|
||||
Reference in New Issue
Block a user