@@ -1616,7 +1616,7 @@ MaybeLocal<Object> ContextifyFunction::CompileFunctionAndCacheResult(
1616
1616
// While top-level `await` is not permitted in CommonJS, it returns the same
1617
1617
// error message as when `await` is used in a sync function, so we don't use it
1618
1618
// 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 > {
1620
1620
" Cannot use import statement outside a module" , // `import` statements
1621
1621
" Unexpected token 'export'" , // `export` statements
1622
1622
" Cannot use 'import.meta' outside a module" }; // `import.meta` references
@@ -1631,14 +1631,15 @@ static std::vector<std::string_view> esm_syntax_error_messages = {
1631
1631
// - Top-level `await`: if the user writes `await` at the top level of a
1632
1632
// CommonJS module, it will throw a syntax error; but the same code is valid
1633
1633
// 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" };
1642
1643
1643
1644
// If cached_data is provided, it would be used for the compilation and
1644
1645
// the on-disk compilation cache from NODE_COMPILE_CACHE (if configured)
0 commit comments