Skip to content

Commit 670d0ea

Browse files
committed
remove swc experimental options
This removes support for keeping import assertions, which were broken in swc at some point, and unconditionally transpiled into import attributes. (Ie, `import/with` instead of `import/assert`.) No version of node supports import attributes with this syntax yet, so anyone using swc to import json in ESM is out of luck no matter what. And swc 1.3.83 broke the option that ts-node was using. The position of the swc project is that experimental features are not supported, and may change in patch versions without warning, making them unsafe to rely on (as evidenced here, and the reason why this behavior changed unexpectedly in the first place). Better to just not use experimental swc features, and let it remove import assertions rather than transpile them into something that node can't run. Fix: #2056
1 parent 47d4f45 commit 670d0ea

File tree

2 files changed

+0
-22
lines changed

2 files changed

+0
-22
lines changed

src/test/transpilers.spec.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,4 @@ test.suite('swc', (test) => {
120120
);
121121
});
122122
});
123-
124-
test.suite('preserves import assertions for json imports', (test) => {
125-
test.if(tsSupportsImportAssertions);
126-
test(
127-
'basic json import',
128-
compileMacro,
129-
{ module: 'esnext' },
130-
outdent`
131-
import document from './document.json' assert {type: 'json'};
132-
document;
133-
`,
134-
outdent`
135-
import document from './document.json' assert {
136-
type: 'json'
137-
};
138-
document;
139-
`
140-
);
141-
});
142123
});

src/transpilers/swc.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ export function createSwcOptions(
235235
},
236236
},
237237
keepClassNames,
238-
experimental: {
239-
keepImportAssertions: true,
240-
},
241238
},
242239
};
243240

0 commit comments

Comments
 (0)