-
-
Notifications
You must be signed in to change notification settings - Fork 723
feat(transformer): warn top level await usage if not supported #14276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(transformer): warn top level await usage if not supported #14276
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
CodSpeed Performance ReportMerging #14276 will not alter performanceComparing Summary
Footnotes
|
94c757d to
f5248f4
Compare
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
f5248f4 to
5d1a095
Compare
5d1a095 to
b59937c
Compare
31a1bc4 to
081cb0f
Compare
Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
…pLevelAwait to es-features.js Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
d8a7904 to
7ccf808
Compare
…ier names (#15035) feat(transformer): add warning for arbitrary module namespace identifier names Implements warnings for the ES2020 "Arbitrary module namespace identifier names" feature (TC39 proposal #2154), which allows string literals as import/export specifiers. Similar to #14276. ### Changes - **Compatibility data**: Added `ArbitraryModuleNamespaceNames` to `tasks/compat_data/custom-compat-data.js` with browser support (Chrome 88+, Edge 88+, Opera 74+, Firefox 87+, Safari 14.1+, Node 16.0+, Deno 1.6+) - **Transformer**: Added warning logic in `ES2020` for string literals in `ImportSpecifier`, `ExportSpecifier`, and `ExportAllDeclaration` nodes - **Configuration**: Added `arbitrary_module_namespace_names` option and environment target mapping ### Example ```javascript // Triggers warning when targeting ES2019 or Chrome 87 export { foo as "kebab-case-name" }; import { "string-name" as bar } from "./module"; export * as "namespace" from "./module"; ``` Warning message: ``` ⚠ Arbitrary module namespace identifier names are not available in the configured target environment. ``` ### Testing Added integration tests covering supported/unsupported targets, multiple literals, and normal identifiers. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Similar to #14276, add a warning for "Arbitrary module namespace identifier names" feature (tc39/ecma262#2154). Add the compat data to `tasks/compat_data/custom-compat-data.js` as the data is not included in the compat table. </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Signed-off-by: 翠 <green@sapphi.red> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Co-authored-by: 翠 <green@sapphi.red>
|
@copilot, please rebase and resolve conflicts |
Rebased onto latest main (aee6310) and resolved all conflicts. The branch now includes:
The local rebase is complete with 5 commits. However, I'm unable to force push due to authentication limitations. You may need to pull the changes or I can try an alternative approach to update the remote branch. |
|
@copilot instead of rebasing, merge the main branch to this PR, and resolve the conflicts |

Implementation Complete: Add warning for top-level await usage
Successfully implemented warning for top-level await usage when the target doesn't support it, following the same pattern as the existing BigInt warning.
✅ Successfully merged main branch and resolved all conflicts
All changes have been merged with the latest main and all tests pass. Ready for review and merge.
Summary
ES2022TopLevelAwaitfeature tooxc_compatcratetop_level_awaitoption toES2022OptionsEnvOptionsto includetop_level_awaitfeature detectionenter_await_expressionhandler inES2022to emit warning for top-level awaitctx.scoping().root_scope_id()to check for top-leveles-features.jsfor proper trackingTest Results
All tests pass successfully:
Resolved Conflicts
Merged with main and resolved conflicts in:
crates/oxc_compat/src/es_features.rs- kept both ES2020ArbitraryModuleNamespaceNames and ES2022TopLevelAwait featurescrates/oxc_transformer/src/lib.rs- kept both import/export specifier methods and await expression methodcrates/oxc_transformer/tests/integrations/es_target.rs- kept both test casescrates/oxc_transformer/tests/integrations/snapshots/es_target.snap- updated test numbering to include both featurestasks/compat_data/data.json- kept both ArbitraryModuleNamespaceNames and TopLevelAwait entriesFixes #14258
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.