@@ -1510,38 +1510,37 @@ void ContextifyContext::ContainsModuleSyntax(
15101510 if (!should_retry_as_esm) {
15111511 for (const auto & error_message : throws_only_in_cjs_error_messages) {
15121512 if (message.find (error_message) != std::string_view::npos) {
1513- // Try parsing again where the user's code is wrapped within an async
1514- // function. If the new parse succeeds, then the error was caused by
1515- // either a top-level declaration of one of the CommonJS module
1516- // variables, or a top-level `await`.
1513+ // Try parsing again where the CommonJS wrapper is replaced by an
1514+ // async function wrapper . If the new parse succeeds, then the error
1515+ // was caused by either a top-level declaration of one of the CommonJS
1516+ // module variables, or a top-level `await`.
15171517 TryCatchScope second_parse_try_catch (env);
1518- Local<String> wrapped_code =
1518+ code =
15191519 String::Concat (isolate,
15201520 String::NewFromUtf8 (isolate, " (async function() {" )
15211521 .ToLocalChecked (),
15221522 code);
1523- wrapped_code = String::Concat (
1523+ code = String::Concat (
15241524 isolate,
1525- wrapped_code ,
1525+ code ,
15261526 String::NewFromUtf8 (isolate, " })();" ).ToLocalChecked ());
15271527 ScriptCompiler::Source wrapped_source =
15281528 GetCommonJSSourceInstance (isolate,
1529- wrapped_code ,
1529+ code ,
15301530 filename,
15311531 0 ,
15321532 0 ,
15331533 host_defined_options,
15341534 nullptr );
1535- ContextifyContext::CompileFunctionAndCacheResult (
1536- env,
1535+ std::ignore = ScriptCompiler::CompileFunction (
15371536 context,
15381537 &wrapped_source,
1539- std::move (params),
1540- std::vector<Local<Object>>(),
1538+ params.size (),
1539+ params.data (),
1540+ 0 ,
1541+ nullptr ,
15411542 options,
1542- true ,
1543- id_symbol,
1544- second_parse_try_catch);
1543+ v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason );
15451544 if (!second_parse_try_catch.HasTerminated ()) {
15461545 if (second_parse_try_catch.HasCaught ()) {
15471546 // If on the second parse an error is thrown by ESM syntax, then
0 commit comments