-
-
Notifications
You must be signed in to change notification settings - Fork 781
feat(transformer): add warning for arbitrary module namespace identifier names #15035
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
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. |
- Added ArbitraryModuleNamespaceNames to custom-compat-data.js with browser support info - Regenerated es_features.rs with the new ES2020ArbitraryModuleNamespaceNames feature - Added arbitrary_module_namespace_names option to ES2020Options - Implemented warning logic in ES2020 transformer for string literal module export names - Added delegation in main transformer for import/export specifiers - Added tests to verify warnings are emitted correctly - Updated snapshot tests Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
- Test that Chrome 90 (which supports the feature) does not emit warnings - Test that multiple string literals emit multiple warnings - Test that normal identifiers do not trigger warnings - All tests passing Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
- Remove tasks/compat_data/package-lock.json as requested - Fix browser compatibility versions to correct values (Chrome 88, Opera 74, Edge 88, Deno 1.6, Opera Mobile 63) - Change test case from chrome89 to es2019 for consistency - Update all test cases to use chrome87 (unsupported version) - Regenerate es_features.rs with corrected compatibility data - All tests passing Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Signed-off-by: 翠 <green@sapphi.red>
Signed-off-by: 翠 <green@sapphi.red>
|
@copilot fix the lint error |
CodSpeed Performance ReportMerging #15035 will not alter performanceComparing Summary
Footnotes
|
Fixed clippy::collapsible_if warnings by combining nested if statements with let patterns using && operator in: - enter_import_specifier - enter_export_all_declaration Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements warnings for the ES2020 "Arbitrary module namespace identifier names" feature, which allows string literals as import/export specifiers (e.g., export { foo as "kebab-case" }). When targeting environments that don't support this feature, the transformer will emit warnings.
Key Changes:
- Added browser/runtime compatibility data for the feature (Chrome 88+, Firefox 87+, Safari 14.1+, etc.)
- Implemented warning logic in the ES2020 transformer for string literal specifiers in import/export statements
- Added configuration option and environment target mapping
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/compat_data/data.json | Added compatibility data entry for ArbitraryModuleNamespaceNames with browser/runtime versions |
| tasks/compat_data/custom-compat-data.js | Added custom compatibility data definition with TC39 proposal reference |
| crates/oxc_transformer/tests/integrations/snapshots/es_target.snap | Added snapshot test showing warning output for ES2019 target |
| crates/oxc_transformer/tests/integrations/es_target.rs | Added integration test case for arbitrary module namespace names |
| crates/oxc_transformer/src/options/mod.rs | Added arbitrary_module_namespace_names option mapping from Babel options |
| crates/oxc_transformer/src/options/env.rs | Added environment target configuration for the feature |
| crates/oxc_transformer/src/lib.rs | Added traverse hooks for import/export specifiers and export all declarations |
| crates/oxc_transformer/src/es2020/options.rs | Added arbitrary_module_namespace_names boolean option to ES2020Options |
| crates/oxc_transformer/src/es2020/mod.rs | Implemented warning logic for string literal specifiers in import/export nodes |
| crates/oxc_compat/src/es_features.rs | Added ES2020ArbitraryModuleNamespaceNames feature enum and compatibility targets |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
ArbitraryModuleNamespaceNamestotasks/compat_data/custom-compat-data.jswith browser support (Chrome 88+, Edge 88+, Opera 74+, Firefox 87+, Safari 14.1+, Node 16.0+, Deno 1.6+)ES2020for string literals inImportSpecifier,ExportSpecifier, andExportAllDeclarationnodesarbitrary_module_namespace_namesoption and environment target mappingExample
Warning message:
Testing
Added integration tests covering supported/unsupported targets, multiple literals, and normal identifiers.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.