@@ -43,6 +43,10 @@ const perContextModuleId = new WeakMap();
4343const wrapMap = new WeakMap ( ) ;
4444const dependencyCacheMap = new WeakMap ( ) ;
4545const linkingStatusMap = new WeakMap ( ) ;
46+ // vm.Module -> function
47+ const initImportMetaMap = new WeakMap ( ) ;
48+ // ModuleWrap -> vm.Module
49+ const wrapToModuleMap = new WeakMap ( ) ;
4650
4751class Module {
4852 constructor ( src , options = { } ) {
@@ -80,6 +84,16 @@ class Module {
8084 perContextModuleId . set ( context , 1 ) ;
8185 }
8286
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+
8397 const wrap = new ModuleWrap ( src , url , {
8498 [ kParsingContext ] : context ,
8599 lineOffset : options . lineOffset ,
@@ -88,6 +102,7 @@ class Module {
88102
89103 wrapMap . set ( this , wrap ) ;
90104 linkingStatusMap . set ( this , 'unlinked' ) ;
105+ wrapToModuleMap . set ( wrap , this ) ;
91106
92107 Object . defineProperties ( this , {
93108 url : { value : url , enumerable : true } ,
@@ -206,5 +221,7 @@ class Module {
206221}
207222
208223module . exports = {
209- Module
224+ Module,
225+ initImportMetaMap,
226+ wrapToModuleMap
210227} ;
0 commit comments