@@ -26,17 +26,20 @@ using v8::Array;
2626using v8::ArrayBufferView;
2727using v8::Context;
2828using v8::EscapableHandleScope;
29+ using v8::FixedArray;
2930using v8::Function;
3031using v8::FunctionCallbackInfo;
3132using v8::FunctionTemplate;
3233using v8::HandleScope;
34+ using v8::Int32;
3335using v8::Integer;
3436using v8::IntegrityLevel;
3537using v8::Isolate;
3638using v8::Local;
3739using v8::MaybeLocal;
3840using v8::MicrotaskQueue;
3941using v8::Module;
42+ using v8::ModuleRequest;
4043using v8::Number;
4144using v8::Object;
4245using v8::PrimitiveArray;
@@ -128,8 +131,8 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
128131 context = contextify_context->context ();
129132 }
130133
131- Local<Integer> line_offset;
132- Local<Integer> column_offset;
134+ int line_offset = 0 ;
135+ int column_offset = 0 ;
133136
134137 bool synthetic = args[2 ]->IsArray ();
135138 if (synthetic) {
@@ -139,9 +142,9 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
139142 // new ModuleWrap(url, context, source, lineOffset, columOffset, cachedData)
140143 CHECK (args[2 ]->IsString ());
141144 CHECK (args[3 ]->IsNumber ());
142- line_offset = args[3 ].As <Integer> ();
145+ line_offset = args[3 ].As <Int32>()-> Value ();
143146 CHECK (args[4 ]->IsNumber ());
144- column_offset = args[4 ].As <Integer> ();
147+ column_offset = args[4 ].As <Int32>()-> Value ();
145148 }
146149
147150 Local<PrimitiveArray> host_defined_options =
@@ -185,14 +188,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
185188
186189 Local<String> source_text = args[2 ].As <String>();
187190 ScriptOrigin origin (url,
188- line_offset, // line offset
189- column_offset, // column offset
190- True (isolate), // is cross origin
191- Local<Integer>(), // script id
191+ line_offset,
192+ column_offset,
193+ true , // is cross origin
194+ - 1 , // script id
192195 Local<Value>(), // source map URL
193- False (isolate), // is opaque (?)
194- False (isolate), // is WASM
195- True (isolate), // is ES Module
196+ false , // is opaque (?)
197+ false , // is WASM
198+ true , // is ES Module
196199 host_defined_options);
197200 ScriptCompiler::Source source (source_text, origin, cached_data);
198201 ScriptCompiler::CompileOptions options;
@@ -270,12 +273,15 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
270273 Local<Context> mod_context = obj->context ();
271274 Local<Module> module = obj->module_ .Get (isolate);
272275
273- const int module_requests_length = module ->GetModuleRequestsLength ();
276+ Local<FixedArray> module_requests = module ->GetModuleRequests ();
277+ const int module_requests_length = module_requests->Length ();
274278 MaybeStackBuffer<Local<Value>, 16 > promises (module_requests_length);
275279
276280 // call the dependency resolve callbacks
277281 for (int i = 0 ; i < module_requests_length; i++) {
278- Local<String> specifier = module ->GetModuleRequest (i);
282+ Local<ModuleRequest> module_request =
283+ module_requests->Get (env->context (), i).As <ModuleRequest>();
284+ Local<String> specifier = module_request->GetSpecifier ();
279285 Utf8Value specifier_utf8 (env->isolate (), specifier);
280286 std::string specifier_std (*specifier_utf8, specifier_utf8.length ());
281287
@@ -311,7 +317,7 @@ void ModuleWrap::Instantiate(const FunctionCallbackInfo<Value>& args) {
311317 Local<Context> context = obj->context ();
312318 Local<Module> module = obj->module_ .Get (isolate);
313319 TryCatchScope try_catch (env);
314- USE (module ->InstantiateModule (context, ResolveCallback ));
320+ USE (module ->InstantiateModule (context, ResolveModuleCallback ));
315321
316322 // clear resolve cache on instantiate
317323 obj->resolve_cache_ .clear ();
@@ -453,12 +459,16 @@ void ModuleWrap::GetStaticDependencySpecifiers(
453459
454460 Local<Module> module = obj->module_ .Get (env->isolate ());
455461
456- int count = module ->GetModuleRequestsLength ();
462+ Local<FixedArray> module_requests = module ->GetModuleRequests ();
463+ int count = module_requests->Length ();
457464
458465 MaybeStackBuffer<Local<Value>, 16 > specifiers (count);
459466
460- for (int i = 0 ; i < count; i++)
461- specifiers[i] = module ->GetModuleRequest (i);
467+ for (int i = 0 ; i < count; i++) {
468+ Local<ModuleRequest> module_request =
469+ module_requests->Get (env->context (), i).As <ModuleRequest>();
470+ specifiers[i] = module_request->GetSpecifier ();
471+ }
462472
463473 args.GetReturnValue ().Set (
464474 Array::New (env->isolate (), specifiers.out (), count));
@@ -473,9 +483,11 @@ void ModuleWrap::GetError(const FunctionCallbackInfo<Value>& args) {
473483 args.GetReturnValue ().Set (module ->GetException ());
474484}
475485
476- MaybeLocal<Module> ModuleWrap::ResolveCallback (Local<Context> context,
477- Local<String> specifier,
478- Local<Module> referrer) {
486+ MaybeLocal<Module> ModuleWrap::ResolveModuleCallback (
487+ Local<Context> context,
488+ Local<String> specifier,
489+ Local<FixedArray> import_assertions,
490+ Local<Module> referrer) {
479491 Environment* env = Environment::GetCurrent (context);
480492 if (env == nullptr ) {
481493 Isolate* isolate = context->GetIsolate ();
@@ -524,14 +536,14 @@ static MaybeLocal<Promise> ImportModuleDynamically(
524536 Local<Context> context,
525537 Local<ScriptOrModule> referrer,
526538 Local<String> specifier) {
527- Isolate* iso = context->GetIsolate ();
539+ Isolate* isolate = context->GetIsolate ();
528540 Environment* env = Environment::GetCurrent (context);
529541 if (env == nullptr ) {
530- THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE (iso );
542+ THROW_ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE (isolate );
531543 return MaybeLocal<Promise>();
532544 }
533545
534- EscapableHandleScope handle_scope (iso );
546+ EscapableHandleScope handle_scope (isolate );
535547
536548 Local<Function> import_callback =
537549 env->host_import_module_dynamically_callback ();
@@ -550,11 +562,11 @@ static MaybeLocal<Promise> ImportModuleDynamically(
550562
551563 Local<Value> object;
552564
553- int type = options->Get (iso , HostDefinedOptions::kType )
565+ int type = options->Get (isolate , HostDefinedOptions::kType )
554566 .As <Number>()
555567 ->Int32Value (context)
556568 .ToChecked ();
557- uint32_t id = options->Get (iso , HostDefinedOptions::kID )
569+ uint32_t id = options->Get (isolate , HostDefinedOptions::kID )
558570 .As <Number>()
559571 ->Uint32Value (context)
560572 .ToChecked ();
@@ -580,7 +592,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
580592 Local<Value> result;
581593 if (import_callback->Call (
582594 context,
583- Undefined (iso ),
595+ Undefined (isolate ),
584596 arraysize (import_args),
585597 import_args).ToLocal (&result)) {
586598 CHECK (result->IsPromise ());
@@ -592,16 +604,16 @@ static MaybeLocal<Promise> ImportModuleDynamically(
592604
593605void ModuleWrap::SetImportModuleDynamicallyCallback (
594606 const FunctionCallbackInfo<Value>& args) {
595- Isolate* iso = args.GetIsolate ();
607+ Isolate* isolate = args.GetIsolate ();
596608 Environment* env = Environment::GetCurrent (args);
597- HandleScope handle_scope (iso );
609+ HandleScope handle_scope (isolate );
598610
599611 CHECK_EQ (args.Length (), 1 );
600612 CHECK (args[0 ]->IsFunction ());
601613 Local<Function> import_callback = args[0 ].As <Function>();
602614 env->set_host_import_module_dynamically_callback (import_callback);
603615
604- iso ->SetHostImportModuleDynamicallyCallback (ImportModuleDynamically);
616+ isolate ->SetHostImportModuleDynamicallyCallback (ImportModuleDynamically);
605617}
606618
607619void ModuleWrap::HostInitializeImportMetaObjectCallback (
0 commit comments