-
-
Notifications
You must be signed in to change notification settings - Fork 714
feat(transformer): add ES2020 export namespace from transformation #14277
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): add ES2020 export namespace from transformation #14277
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. |
export * as ns from "mod"; to import * as ns from "mod"; export { ns }
crates/oxc_transformer/tests/integrations/export_namespace_from.rs
Outdated
Show resolved
Hide resolved
crates/oxc_transformer/tests/integrations/export_namespace_from.rs
Outdated
Show resolved
Hide resolved
CodSpeed Performance ReportMerging #14277 will not alter performanceComparing Summary
Footnotes
|
206a446 to
da2a113
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. |
da2a113 to
e1775f4
Compare
bbbd512 to
ce11e1e
Compare
ce11e1e to
695cf4d
Compare
1686f42 to
da4b742
Compare
13f3e7b to
be53dad
Compare
da4b742 to
524a43b
Compare
be53dad to
f81e2bd
Compare
524a43b to
1c34540
Compare
f81e2bd to
d1ff718
Compare
1c34540 to
6f30b10
Compare
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.
I just noticed that we should improve the case where there is no export * as ns from "mod".
Additionally, we could try an alternative approach to implement this, which may have better performance than this in some scenarios.
How to implement it?
Do transform in exit_module_declaration. In this method, you can get a ModuleDeclaration, then check whether this is an ExportAllDeclaration whose exported is some, if so, you mutate it with the export part (export { _ns as ns }), and insert the import part (import * as _ns from "mod") by self.ctx.statement_injector.insert_before.
|
@copilot please check the requested changes |
- Import TransformCtx directly instead of using full path - Add early return to avoid unnecessary allocation when no export namespace declarations exist - Use exported_name.name() to get the identifier name directly - Simplify UID generation Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
Implement GatherNodeParts trait for ModuleExportName to avoid string allocation when generating UIDs. This allows using generate_uid_based_on_node instead of generate_uid with name().as_str(), eliminating unnecessary to_string() allocation. Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Signed-off-by: Dunqing <dengqing0821@gmail.com>

✅ Implementation Complete: ES2020 Export Namespace From Transformation
Successfully implemented the transformation for
export * as ns from "mod"to convert it to:Changes Made:
es2020/export_namespace_from.rsoxc_compat(auto-generated from custom compat data)transform-export-namespace-from)GatherNodePartsforModuleExportNameto avoid string allocationsCode Review Addressed:
ctx.ast.vec1()for single-element vectorsTransformCtxdirectlyGatherNodePartsforModuleExportNameand usegenerate_uid_based_on_nodeExample:
Input:
Output:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.