module: introduce defaultModuleName in module.js
This commit adds a constant named defaultModuleName to avoid duplicating it in the Module constructor function. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
2b8cd93246
commit
ea01d305f6
@ -48,6 +48,7 @@ const linkingStatusMap = new WeakMap();
|
||||
const initImportMetaMap = new WeakMap();
|
||||
// ModuleWrap -> vm.Module
|
||||
const wrapToModuleMap = new WeakMap();
|
||||
const defaultModuleName = 'vm:module';
|
||||
|
||||
class Module {
|
||||
constructor(src, options = {}) {
|
||||
@ -82,13 +83,13 @@ class Module {
|
||||
}
|
||||
url = new URL(url).href;
|
||||
} else if (context === undefined) {
|
||||
url = `vm:module(${globalModuleId++})`;
|
||||
url = `${defaultModuleName}(${globalModuleId++})`;
|
||||
} else if (perContextModuleId.has(context)) {
|
||||
const curId = perContextModuleId.get(context);
|
||||
url = `vm:module(${curId})`;
|
||||
url = `${defaultModuleName}(${curId})`;
|
||||
perContextModuleId.set(context, curId + 1);
|
||||
} else {
|
||||
url = 'vm:module(0)';
|
||||
url = `${defaultModuleName}(0)`;
|
||||
perContextModuleId.set(context, 1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user