refactor: const Module = require('module') as NodeJS.ModuleInternal; (#38757)
Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
parent
65901f4c6a
commit
e71a56d11e
8 changed files with 20 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
import * as path from 'path';
|
||||
|
||||
const Module = require('module');
|
||||
const Module = require('module') as NodeJS.ModuleInternal;
|
||||
|
||||
// We do not want to allow use of the VM module in the renderer process as
|
||||
// it conflicts with Blink's V8::Context internal logic.
|
||||
|
@ -10,7 +10,7 @@ if (process.type === 'renderer') {
|
|||
if (request === 'vm') {
|
||||
console.warn('The vm module of Node.js is deprecated in the renderer process and will be removed.');
|
||||
}
|
||||
return _load.apply(this, arguments);
|
||||
return _load.apply(this, arguments as any);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ const originalResolveFilename = Module._resolveFilename;
|
|||
// renderer process regardless of the names, they're superficial for TypeScript
|
||||
// only.
|
||||
const electronModuleNames = new Set(['electron', 'electron/main', 'electron/renderer', 'electron/common']);
|
||||
Module._resolveFilename = function (request: string, parent: NodeModule, isMain: boolean, options?: { paths: Array<string>}) {
|
||||
Module._resolveFilename = function (request, parent, isMain, options) {
|
||||
if (electronModuleNames.has(request)) {
|
||||
return 'electron';
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue