fix: only override valid electron module names (#35915)

Fixes #33014
This commit is contained in:
Samuel Attard 2022-10-06 03:14:03 -07:00 committed by GitHub
parent faafcc7f87
commit e31c96a564
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,8 +52,9 @@ if (process.type === 'renderer') {
}
const originalResolveFilename = Module._resolveFilename;
const electronModuleNames = new Set(['electron', 'electron/main', 'electron/renderer', 'electron/common']);
Module._resolveFilename = function (request: string, parent: NodeModule, isMain: boolean, options?: { paths: Array<string>}) {
if (request === 'electron' || request.startsWith('electron/')) {
if (electronModuleNames.has(request)) {
return 'electron';
} else {
return originalResolveFilename(request, parent, isMain, options);