fix: disable use of the vm module in the renderer (#26087)
This commit is contained in:
parent
c89ce5eecf
commit
e89abed924
1 changed files with 12 additions and 0 deletions
|
@ -5,6 +5,18 @@ const Module = require('module');
|
|||
// Clear Node's global search paths.
|
||||
Module.globalPaths.length = 0;
|
||||
|
||||
// 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.
|
||||
if (process.type === 'renderer') {
|
||||
const _load = Module._load;
|
||||
Module._load = function (request: string) {
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
// Prevent Node from adding paths outside this app to search paths.
|
||||
const resourcesPathWithTrailingSlash = process.resourcesPath + path.sep;
|
||||
const originalNodeModulePaths = Module._nodeModulePaths;
|
||||
|
|
Loading…
Reference in a new issue