@@ -1622,7 +1622,7 @@ MaybeLocal<Object> ContextifyFunction::CompileFunctionAndCacheResult(
16221622// While top-level `await` is not permitted in CommonJS, it returns the same
16231623// error message as when `await` is used in a sync function, so we don't use it
16241624// as a disambiguation.
1625- static std::vector <std::string_view> esm_syntax_error_messages = {
1625+ static const auto esm_syntax_error_messages = std::array <std::string_view, 3 > {
16261626 " Cannot use import statement outside a module" , // `import` statements
16271627 " Unexpected token 'export'" , // `export` statements
16281628 " Cannot use 'import.meta' outside a module" }; // `import.meta` references
@@ -1637,14 +1637,15 @@ static std::vector<std::string_view> esm_syntax_error_messages = {
16371637// - Top-level `await`: if the user writes `await` at the top level of a
16381638// CommonJS module, it will throw a syntax error; but the same code is valid
16391639// in ESM.
1640- static std::vector<std::string_view> throws_only_in_cjs_error_messages = {
1641- " Identifier 'module' has already been declared" ,
1642- " Identifier 'exports' has already been declared" ,
1643- " Identifier 'require' has already been declared" ,
1644- " Identifier '__filename' has already been declared" ,
1645- " Identifier '__dirname' has already been declared" ,
1646- " await is only valid in async functions and "
1647- " the top level bodies of modules" };
1640+ static const auto throws_only_in_cjs_error_messages =
1641+ std::array<std::string_view, 6 >{
1642+ " Identifier 'module' has already been declared" ,
1643+ " Identifier 'exports' has already been declared" ,
1644+ " Identifier 'require' has already been declared" ,
1645+ " Identifier '__filename' has already been declared" ,
1646+ " Identifier '__dirname' has already been declared" ,
1647+ " await is only valid in async functions and "
1648+ " the top level bodies of modules" };
16481649
16491650// If cached_data is provided, it would be used for the compilation and
16501651// the on-disk compilation cache from NODE_COMPILE_CACHE (if configured)
0 commit comments