-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(es/codegen): Implement codegen for static import assertions #3113
fix(es/codegen): Implement codegen for static import assertions #3113
Conversation
swc_ecma_codegen: * Implement codegen for static import assertions. swc_ecma_parser: * Make static import assertions a syntax error for ES versions under ES2022 Fixes swc-project#3110.
looks like this will fix #2802 too |
use a field in `JscExperimental` rather than a variant in `EsVersion` to enable import assertions in the output.
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.
Other changes except this LGTM. Thank you!
I think this can make users think it's an option to enable
instead of to keep
.
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.
Thank you!
Thank you for the review! |
This configuration doesn't seem to apply through the |
@guybedford Ah, my bad. I think it's because there's no code to handle the field in swc/crates/swc/src/config/mod.rs Lines 985 to 991 in a4e93eb
|
swc_ecma_codegen:
swc_ecma_transforms_proposal:
import_assertions
transform to support assertions in exports.swc:
keep_import_assertions
option toJscExperimental
that will keep import assertions in the compiled output.node-swc:
keepImportAssertions
option to the typings forJscConfig.experimental
.JscConfig.experimental
was spelled as "experimetal".Description:
Currently import assertions are correctly parsed if the input is TypeScript, or EcmaScript with
import_assertions: true
, but the codegen step strips them no matter what. This PR adds akeep_import_assertions
option toJscConfig
to keep them.BREAKING CHANGE:
None
Related issue (if exists):
Fixes #2802.