@@ -43,6 +43,10 @@ const perContextModuleId = new WeakMap();
43
43
const wrapMap = new WeakMap ( ) ;
44
44
const dependencyCacheMap = new WeakMap ( ) ;
45
45
const linkingStatusMap = new WeakMap ( ) ;
46
+ // vm.Module -> function
47
+ const initImportMetaMap = new WeakMap ( ) ;
48
+ // ModuleWrap -> vm.Module
49
+ const wrapToModuleMap = new WeakMap ( ) ;
46
50
47
51
class Module {
48
52
constructor ( src , options = { } ) {
@@ -80,6 +84,16 @@ class Module {
80
84
perContextModuleId . set ( context , 1 ) ;
81
85
}
82
86
87
+ if ( options . initializeImportMeta !== undefined ) {
88
+ if ( typeof options . initializeImportMeta === 'function' ) {
89
+ initImportMetaMap . set ( this , options . initializeImportMeta ) ;
90
+ } else {
91
+ throw new ERR_INVALID_ARG_TYPE (
92
+ 'options.initializeImportMeta' , 'function' ,
93
+ options . initializeImportMeta ) ;
94
+ }
95
+ }
96
+
83
97
const wrap = new ModuleWrap ( src , url , {
84
98
[ kParsingContext ] : context ,
85
99
lineOffset : options . lineOffset ,
@@ -88,6 +102,7 @@ class Module {
88
102
89
103
wrapMap . set ( this , wrap ) ;
90
104
linkingStatusMap . set ( this , 'unlinked' ) ;
105
+ wrapToModuleMap . set ( wrap , this ) ;
91
106
92
107
Object . defineProperties ( this , {
93
108
url : { value : url , enumerable : true } ,
@@ -206,5 +221,7 @@ class Module {
206
221
}
207
222
208
223
module . exports = {
209
- Module
224
+ Module,
225
+ initImportMetaMap,
226
+ wrapToModuleMap
210
227
} ;
0 commit comments