fix: disable use of the vm module in the renderer (#26087)

This commit is contained in:
Shelley Vohr 2020-10-23 11:49:52 -07:00 committed by GitHub
parent c89ce5eecf
commit e89abed924
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;