-
-
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
Import assertions are skipped when transpiled from TS to JS #3110
Comments
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.
Closing as duplicate of #2802 |
@kdy1 It seems like the solution in #2802 involved a new flag that only applies to the ECMAScript parser. Also, maybe I'm doing something wrong, but when I attempted to add the flag to the example in the playground in the JSON editor (after updating the version to the latest available version and switching to ECMAScript), it still seems to strip it out. |
@wycats TypeScript supports it unconditionally. swc/crates/swc_ecma_parser/src/lib.rs Lines 167 to 174 in 7407f21
|
Also, I tested and import is stripped out because imported identifier isn't used. This is related to preserving imports not used as value ( I don't remember the name of the option for preserving such imports) |
Great! Consider this solved. I'm not sure why it was causing me trouble in my real app (it wasn't this problem), but I can dig in if I reproduce it again. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
Import assertions affect whether a module is valid in the module graph, depending on the JS runtime, and so should not be stripped when transpiling.
Input code
Config
Playground link
https://play.swc.rs/?version=1.2.122&code=H4sIAAAAAAAAA8vMLcgvKlFISSxJVEgrys9VUNLTL0ktLtHLKs7PU1JILC5OBUpXK5RUFqRaKShBRGutubiS8%2FOK83NS9XLy0zVAujWtAVSAl05LAAAA&config=H4sIAAAAAAAAA0WNSwrDMAxE76J1FsWLLnKHHsK4SnDxD40CDcZ3rx1cspNmnp4qfeBorVSsgGVMOJPaL62kZ2E48UVpIUWPNhvArS9WdtaOMMzDmF6HnMETWCj65LdzyFyORRi4K5v28Cdbd8X8PkZQr3%2BX80ntdsw7j9cEVQ5uPx%2Bqcl%2B4AAAA
Expected behavior
Actual behavior
Version
1.2.122
Additional context
No response
The text was updated successfully, but these errors were encountered: