Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b338edb

Browse filesBrowse files
ryzokukenrvagg
authored andcommitted
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: #17396 PR-URL: #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>
1 parent 25ddbc9 commit b338edb
Copy full SHA for b338edb

File tree

Expand file treeCollapse file tree

1 file changed

+7
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-13
lines changed
Open diff view settings
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+7-13Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -692,19 +692,13 @@ Module.prototype._compile = function(content, filename) {
692692

693693
content = stripShebang(content);
694694

695-
// create wrapper function
696-
var wrapper = Module.wrap(content);
697-
698-
var compiledWrapper = vm.runInThisContext(wrapper, {
699-
filename: filename,
700-
lineOffset: 0,
701-
displayErrors: true,
702-
importModuleDynamically: experimentalModules ? async (specifier) => {
703-
if (asyncESM === undefined) lazyLoadESM();
704-
const loader = await asyncESM.loaderPromise;
705-
return loader.import(specifier, normalizeReferrerURL(filename));
706-
} : undefined,
707-
});
695+
const compiledWrapper = vm.compileFunction(content, [
696+
'exports',
697+
'require',
698+
'module',
699+
'__filename',
700+
'__dirname',
701+
], { filename });
708702

709703
var inspectorWrapper = null;
710704
if (process._breakFirstLine && process._eval == null) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.