Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 1, 2025

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

  • Add ES2022TopLevelAwait feature to oxc_compat crate
  • Add top_level_await option to ES2022Options
  • Update EnvOptions to include top_level_await feature detection
  • Implement enter_await_expression handler in ES2022 to emit warning for top-level await
  • Add test cases to verify the warning is emitted correctly
  • Run tests to ensure everything works
  • Address review feedback: use ctx.scoping().root_scope_id() to check for top-level
  • Add feature to es-features.js for proper tracking
  • Add test case for nested block with await (confirms current implementation is correct)
  • Merge main branch and resolve all conflicts

Test Results

All tests pass successfully:

  • ✅ oxc_transformer: 30 unit tests + 3 integration tests (es_target)
  • ✅ oxc_compat: 3 tests
  • ✅ No clippy warnings
  • ✅ Successfully merged with latest main

Resolved Conflicts

Merged with main and resolved conflicts in:

  • crates/oxc_compat/src/es_features.rs - kept both ES2020ArbitraryModuleNamespaceNames and ES2022TopLevelAwait features
  • crates/oxc_transformer/src/lib.rs - kept both import/export specifier methods and await expression method
  • crates/oxc_transformer/tests/integrations/es_target.rs - kept both test cases
  • crates/oxc_transformer/tests/integrations/snapshots/es_target.snap - updated test numbering to include both features
  • tasks/compat_data/data.json - kept both ArbitraryModuleNamespaceNames and TopLevelAwait entries

Fixes #14258

Original prompt

This section details on the original issue you should resolve

<issue_title>transformer: warn top level await usage if not supported</issue_title>
<issue_description>A warning is emitted when BigInt is used and the target does not support it (playground). Similar to that, it would be helpful if a warning is emitted for top-level await as well.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #14258

💡 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.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 1, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copilot AI changed the title [WIP] transformer: warn top level await usage if not supported transformer: warn top level await usage if not supported Oct 1, 2025
Copilot AI requested a review from sapphi-red October 1, 2025 12:19
Copilot finished work on behalf of sapphi-red October 1, 2025 12:19
Copilot AI requested a review from sapphi-red October 2, 2025 04:28
Copilot finished work on behalf of sapphi-red October 2, 2025 04:28
@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label Oct 2, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 2, 2025

CodSpeed Performance Report

Merging #14276 will not alter performance

Comparing copilot/fix-84bb58e5-a448-42e9-bd15-4c860fd78a4e (c2fd474) with main (8b14ec9)

Summary

✅ 33 untouched
⏩ 4 skipped1

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sapphi-red sapphi-red changed the base branch from main to graphite-base/14276 October 3, 2025 15:11
@sapphi-red sapphi-red force-pushed the copilot/fix-84bb58e5-a448-42e9-bd15-4c860fd78a4e branch from 94c757d to f5248f4 Compare October 3, 2025 15:11
@sapphi-red sapphi-red changed the base branch from graphite-base/14276 to 10-03-feat-compat-add-custom-compat-data-for-export-namespace-from October 3, 2025 15:11
Copy link
Member

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.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@sapphi-red sapphi-red force-pushed the copilot/fix-84bb58e5-a448-42e9-bd15-4c860fd78a4e branch from f5248f4 to 5d1a095 Compare October 3, 2025 15:15
@sapphi-red sapphi-red changed the title transformer: warn top level await usage if not supported feat(transformer): warn top level await usage if not supported Oct 3, 2025
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Oct 3, 2025
@sapphi-red sapphi-red force-pushed the copilot/fix-84bb58e5-a448-42e9-bd15-4c860fd78a4e branch from 5d1a095 to b59937c Compare October 3, 2025 15:16
@sapphi-red sapphi-red marked this pull request as ready for review October 3, 2025 15:22
@sapphi-red sapphi-red assigned Dunqing and unassigned sapphi-red Oct 3, 2025
@sapphi-red sapphi-red removed their request for review October 3, 2025 15:23
@graphite-app graphite-app bot changed the base branch from graphite-base/14276 to main October 7, 2025 07:53
@graphite-app graphite-app bot force-pushed the copilot/fix-84bb58e5-a448-42e9-bd15-4c860fd78a4e branch from 31a1bc4 to 081cb0f Compare October 7, 2025 07:54
Copilot AI and others added 4 commits October 31, 2025 14:16
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>
@Dunqing Dunqing force-pushed the copilot/fix-84bb58e5-a448-42e9-bd15-4c860fd78a4e branch from d8a7904 to 7ccf808 Compare October 31, 2025 06:16
Dunqing pushed a commit that referenced this pull request Oct 31, 2025
…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>
@Dunqing
Copy link
Member

Dunqing commented Oct 31, 2025

@copilot, please rebase and resolve conflicts

Copy link
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot, please rebase and resolve conflicts

Rebased onto latest main (aee6310) and resolved all conflicts. The branch now includes:

  • Your new arbitrary module namespace names warning feature
  • Our top-level await warning feature
  • All tests pass successfully

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 finished work on behalf of Dunqing October 31, 2025 06:37
@sapphi-red
Copy link
Member

@copilot instead of rebasing, merge the main branch to this PR, and resolve the conflicts

Copy link
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot instead of rebasing, merge the main branch to this PR, and resolve the conflicts

Done in 4fcbf6b. Merged main branch into this PR and resolved all conflicts. All tests pass.

Copilot AI requested a review from sapphi-red October 31, 2025 11:01
Copilot finished work on behalf of sapphi-red October 31, 2025 11:01
@Dunqing Dunqing merged commit 2c15353 into main Nov 3, 2025
26 checks passed
@Dunqing Dunqing deleted the copilot/fix-84bb58e5-a448-42e9-bd15-4c860fd78a4e branch November 3, 2025 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformer: warn top level await usage if not supported

3 participants