module: use compileFunction over Module.wrap
Use vm.compileFunction (which is a binding for v8::CompileFunctionInContext) instead of Module.wrap internally in Module._compile for the cjs loader. Fixes: https://github.com/nodejs/node/issues/17396 PR-URL: https://github.com/nodejs/node/pull/21573 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
8375c706ad
commit
d345b0dc12
@ -700,19 +700,13 @@ Module.prototype._compile = function(content, filename) {
|
|||||||
|
|
||||||
content = stripShebang(content);
|
content = stripShebang(content);
|
||||||
|
|
||||||
// create wrapper function
|
const compiledWrapper = vm.compileFunction(content, [
|
||||||
var wrapper = Module.wrap(content);
|
'exports',
|
||||||
|
'require',
|
||||||
var compiledWrapper = vm.runInThisContext(wrapper, {
|
'module',
|
||||||
filename: filename,
|
'__filename',
|
||||||
lineOffset: 0,
|
'__dirname',
|
||||||
displayErrors: true,
|
], { filename });
|
||||||
importModuleDynamically: experimentalModules ? async (specifier) => {
|
|
||||||
if (asyncESM === undefined) lazyLoadESM();
|
|
||||||
const loader = await asyncESM.loaderPromise;
|
|
||||||
return loader.import(specifier, normalizeReferrerURL(filename));
|
|
||||||
} : undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
var inspectorWrapper = null;
|
var inspectorWrapper = null;
|
||||||
if (process._breakFirstLine && process._eval == null) {
|
if (process._breakFirstLine && process._eval == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user