-
-
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 blanket converted to import attributes #7908
Comments
The option should be removed or renamed, I think, but this is not a bug. |
Sorry @kdy1 I wasn't sure what to label it as. I just went for bug as it was causing me issues. I figure it shouldn't be too much of a challenge to check whether the dev used I have tried changing the target version but it seems as though the compiler just wants to always output code with |
@kwonoj @alexander-akait @magic-akari @Austaras |
swc/crates/swc_ecma_ast/src/module_decl.rs Lines 74 to 88 in 766d3e8
During the process of parsing code into an AST, we lose the information required to differentiate whether it represents a "with" statement or an "assert" statement. There are two potential solutions:
|
Seems to me that adding an option to codegen would be the most logical solution. |
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
When using the
jsc.experiment.keepImportAssertions
flag the SWC compiler simply takes all assertions and outputs the newwith { type: "some-type" }
syntax regardless of what the input was.This causes issues with Node being able to run the code and generates a syntax error when trying to run the generated code. As it has been accepted that the
assert
syntax will not be getting removed there is no need to blanket change the syntax as this causes more issues than it solves.Input code
Config
Playground link
https://play.swc.rs/?version=1.3.82&code=H4sIAAAAAAAAA8vMLcgvKlEoSEzOTkxP9Qr291NIK8rPVVDS04eK6WUV5%2BcpKSQWF6cCFVaXVBakWikogQVrrbmS8%2FOK83NS9XLy0zWQDNG0BgDW5p%2FHWQAAAA%3D%3D&config=H4sIAAAAAAAAA0VOOw7CMAzdc4rIMwPKwMDGyMAhomKhQNNYtiu1qnL3OrSUze%2FvxXkPb%2Bng6hc7DVBkQT6wMTIPGidjQGdC6TiRwlespy2jkV%2BozYESziHAzuNEyCmj5fvW6OGDSPdMhfUmNqOpDGKK8oi%2Bur0RcnmOPf5%2Fartb%2BwUOU5LHz9birroVVF6is80AAAA%3D
SWC Info output
No response
Expected behavior
The type of assertion is preserved.
Actual behavior
The assertion is transformed into the newer
with
syntax.Version
1.3.82
Additional context
I have solved this issue for me by downgrading to swc version
1.3.80
. However, I think a more flexible solution is required.The text was updated successfully, but these errors were encountered: