| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 181014a commit e9c6fa5
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1622,7 +1622,7 @@ MaybeLocal<Object> ContextifyFunction::CompileFunctionAndCacheResult( | |||
| 1622 | 1622 | // While top-level `await` is not permitted in CommonJS, it returns the same | |
| 1623 | 1623 | // error message as when `await` is used in a sync function, so we don't use it | |
| 1624 | 1624 | // 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>{ | ||
| 1626 | 1626 | "Cannot use import statement outside a module", // `import` statements | |
| 1627 | 1627 | "Unexpected token 'export'", // `export` statements | |
| 1628 | 1628 | "Cannot use 'import.meta' outside a module"}; // `import.meta` references | |
@@ -1637,14 +1637,15 @@ static std::vector<std::string_view> esm_syntax_error_messages = { | |||
| 1637 | 1637 | // - Top-level `await`: if the user writes `await` at the top level of a | |
| 1638 | 1638 | // CommonJS module, it will throw a syntax error; but the same code is valid | |
| 1639 | 1639 | // 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"}; | ||
| 1648 | 1649 | ||
| 1649 | 1650 | // If cached_data is provided, it would be used for the compilation and | |
| 1650 | 1651 | // the on-disk compilation cache from NODE_COMPILE_CACHE (if configured) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments