-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Milestone
Description
Describe the bug
When using the jsc.experiment.keepImportAssertions flag the SWC compiler simply takes all assertions and outputs the new with { 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
import packageJSON from "./package.json" assert { type: "json" };Config
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2022",
"experimental": { "keepImportAssertions": true }
},
"module": {
"type": "es6"
},
"isModule": true
}Playground link
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.