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 678b754

Browse filesBrowse files
danbevMylesBorins
authored andcommitted
module: introduce defaultModuleName in module.js
This commit adds a constant named defaultModuleName to avoid duplicating it in the Module constructor function. PR-URL: #20709 Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d5db576 commit 678b754
Copy full SHA for 678b754

File tree

Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/vm/module.js‎

Copy file name to clipboardExpand all lines: lib/internal/vm/module.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const linkingStatusMap = new WeakMap();
4848
const initImportMetaMap = new WeakMap();
4949
// ModuleWrap -> vm.Module
5050
const wrapToModuleMap = new WeakMap();
51+
const defaultModuleName = 'vm:module';
5152

5253
class Module {
5354
constructor(src, options = {}) {
@@ -82,13 +83,13 @@ class Module {
8283
}
8384
url = new URL(url).href;
8485
} else if (context === undefined) {
85-
url = `vm:module(${globalModuleId++})`;
86+
url = `${defaultModuleName}(${globalModuleId++})`;
8687
} else if (perContextModuleId.has(context)) {
8788
const curId = perContextModuleId.get(context);
88-
url = `vm:module(${curId})`;
89+
url = `${defaultModuleName}(${curId})`;
8990
perContextModuleId.set(context, curId + 1);
9091
} else {
91-
url = 'vm:module(0)';
92+
url = `${defaultModuleName}(0)`;
9293
perContextModuleId.set(context, 1);
9394
}
9495

0 commit comments

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