Skip to content

Commit 678b754

Browse 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 <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d5db576 commit 678b754

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/internal/vm/module.js

+4-3
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)