@@ -1616,7 +1616,7 @@ MaybeLocal<Object> ContextifyFunction::CompileFunctionAndCacheResult(
16161616// While top-level `await` is not permitted in CommonJS, it returns the same
16171617// error message as when `await` is used in a sync function, so we don't use it
16181618// as a disambiguation.
1619- static std::vector <std::string_view> esm_syntax_error_messages = {
1619+ static const auto esm_syntax_error_messages = std::array <std::string_view, 3 > {
16201620 " Cannot use import statement outside a module" , // `import` statements
16211621 " Unexpected token 'export'" , // `export` statements
16221622 " Cannot use 'import.meta' outside a module" }; // `import.meta` references
@@ -1631,14 +1631,15 @@ static std::vector<std::string_view> esm_syntax_error_messages = {
16311631// - Top-level `await`: if the user writes `await` at the top level of a
16321632// CommonJS module, it will throw a syntax error; but the same code is valid
16331633// in ESM.
1634- static std::vector<std::string_view> throws_only_in_cjs_error_messages = {
1635- " Identifier 'module' has already been declared" ,
1636- " Identifier 'exports' has already been declared" ,
1637- " Identifier 'require' has already been declared" ,
1638- " Identifier '__filename' has already been declared" ,
1639- " Identifier '__dirname' has already been declared" ,
1640- " await is only valid in async functions and "
1641- " the top level bodies of modules" };
1634+ static const auto throws_only_in_cjs_error_messages =
1635+ std::array<std::string_view, 6 >{
1636+ " Identifier 'module' has already been declared" ,
1637+ " Identifier 'exports' has already been declared" ,
1638+ " Identifier 'require' has already been declared" ,
1639+ " Identifier '__filename' has already been declared" ,
1640+ " Identifier '__dirname' has already been declared" ,
1641+ " await is only valid in async functions and "
1642+ " the top level bodies of modules" };
16421643
16431644// If cached_data is provided, it would be used for the compilation and
16441645// the on-disk compilation cache from NODE_COMPILE_CACHE (if configured)
0 commit comments