Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

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

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

Original prompt

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.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 28, 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 and others added 3 commits October 28, 2025 12:31
- 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>
Copilot AI changed the title [WIP] Add warning for arbitrary module namespace identifier names feat(transformer): Add warning for arbitrary module namespace identifier names Oct 28, 2025
Copilot AI requested a review from sapphi-red October 28, 2025 12:37
- 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>
@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-enhancement Category - New feature or request labels Oct 28, 2025
Signed-off-by: 翠 <green@sapphi.red>
@sapphi-red sapphi-red changed the title feat(transformer): Add warning for arbitrary module namespace identifier names feat(transformer): add warning for arbitrary module namespace identifier names Oct 28, 2025
@sapphi-red
Copy link
Member

@copilot fix the lint error

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 28, 2025

CodSpeed Performance Report

Merging #15035 will not alter performance

Comparing copilot/add-warning-for-arbitrary-namespace (57048f7) with main (1611b4f)

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.

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>
Copy link
Contributor Author

Copilot AI commented Oct 28, 2025

@copilot fix the lint error

Fixed in 57048f7. Collapsed nested if statements using && with let patterns to resolve clippy::collapsible_if warnings.

@sapphi-red sapphi-red marked this pull request as ready for review October 28, 2025 16:12
Copilot AI review requested due to automatic review settings October 28, 2025 16:12
@sapphi-red sapphi-red assigned Dunqing and unassigned sapphi-red Oct 28, 2025
Copy link
Contributor

Copilot AI left a 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.

@Dunqing Dunqing merged commit aee6310 into main Oct 31, 2025
45 of 47 checks passed
@Dunqing Dunqing deleted the copilot/add-warning-for-arbitrary-namespace branch October 31, 2025 06:17
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.

3 participants