Skip to content

Commit f2ef29b

Browse files
committed
Bump min swc version to 1.3.85
Fix issue introduced by swc 1.3.85 with module options that are now forbidden instead of ignored for certain module types remove failing useDefineForClassFields case because I forgot that implicit compiler options were in effect, so default target is actually much higher than I expected
1 parent 1439318 commit f2ef29b

4 files changed

Lines changed: 82 additions & 83 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@
116116
"@cspotcode/ava-lib": "https://github.com/cspotcode/ava-lib#805aab17b2b89c388596b6dc2b4eece403c5fb87",
117117
"@cspotcode/expect-stream": "https://github.com/cspotcode/node-expect-stream#4e425ff1eef240003af8716291e80fbaf3e3ae8f",
118118
"@microsoft/api-extractor": "^7.19.4",
119-
"@swc/core": "1.3.84",
120-
"@swc/wasm": "1.3.84",
119+
"@swc/core": "1.3.85",
120+
"@swc/wasm": "1.3.85",
121121
"@types/diff": "^4.0.2",
122122
"@types/lodash": "^4.14.151",
123123
"@types/node": "13.13.5",
@@ -145,8 +145,8 @@
145145
"workaround-broken-npm-prepack-behavior": "https://github.com/cspotcode/workaround-broken-npm-prepack-behavior#1a7adbbb8a527784daf97edad6ba42d6e96611f6"
146146
},
147147
"peerDependencies": {
148-
"@swc/core": ">=1.2.50",
149-
"@swc/wasm": ">=1.2.50",
148+
"@swc/core": ">=1.3.85",
149+
"@swc/wasm": ">=1.3.85",
150150
"@types/node": "*",
151151
"typescript": ">=4.4"
152152
},

src/test/transpilers.spec.ts

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ test.suite('swc', (test) => {
8787
.create({
8888
swc: true,
8989
skipProject: true,
90-
compilerOptions: {
91-
module: 'esnext',
92-
...compilerOptions,
93-
},
90+
compilerOptions,
9491
})
9592
.compile(input, 'input.tsx');
9693
expect(code.replace(/\/\/# sourceMappingURL.*/, '').trim()).toBe(expectedOutput);
@@ -102,12 +99,17 @@ test.suite('swc', (test) => {
10299
const div = <div></div>;
103100
`;
104101

105-
test(compileMacro, { jsx: 'react' }, input, `const div = /*#__PURE__*/ React.createElement("div", null);`);
102+
test(
103+
compileMacro,
104+
{ module: 'esnext', jsx: 'react' },
105+
input,
106+
`const div = /*#__PURE__*/ React.createElement("div", null);`
107+
);
106108
test.suite('react 17 jsx factories', (test) => {
107109
test.if(tsSupportsReact17JsxFactories);
108110
test(
109111
compileMacro,
110-
{ jsx: 'react-jsx' },
112+
{ module: 'esnext', jsx: 'react-jsx' },
111113
input,
112114
outdent`
113115
import { jsx as _jsx } from "react/jsx-runtime";
@@ -116,7 +118,7 @@ test.suite('swc', (test) => {
116118
);
117119
test(
118120
compileMacro,
119-
{ jsx: 'react-jsxdev' },
121+
{ module: 'esnext', jsx: 'react-jsxdev' },
120122
input,
121123
outdent`
122124
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
@@ -190,41 +192,29 @@ test.suite('swc', (test) => {
190192
test(
191193
'useDefineForClassFields unset, should default to true and emit native property assignment b/c `next` target',
192194
compileMacro,
193-
{
194-
target: 'ESNext',
195-
},
195+
{ module: 'esnext', target: 'ESNext' },
196196
input,
197197
outputNative
198198
);
199199
test(
200200
'useDefineForClassFields unset, should default to true and emit native property assignment b/c new target',
201201
compileMacro,
202-
{
203-
target: 'ES2022',
204-
},
202+
{ module: 'esnext', target: 'ES2022' },
205203
input,
206204
outputNative
207205
);
208206
test(
209207
'useDefineForClassFields unset, should default to false b/c old target',
210208
compileMacro,
211-
{
212-
target: 'ES2021',
213-
},
214-
input,
215-
outputCtorAssignment
216-
);
217-
test(
218-
'useDefineForClassFields unset, should default to false b/c no target',
219-
compileMacro,
220-
{},
209+
{ module: 'esnext', target: 'ES2021' },
221210
input,
222211
outputCtorAssignment
223212
);
224213
test(
225214
'useDefineForClassFields=true, should emit native property assignment b/c new target',
226215
compileMacro,
227216
{
217+
module: 'esnext',
228218
useDefineForClassFields: true,
229219
target: 'ES2022',
230220
},
@@ -235,6 +225,7 @@ test.suite('swc', (test) => {
235225
'useDefineForClassFields=true, should emit define b/c old target',
236226
compileMacro,
237227
{
228+
module: 'esnext',
238229
useDefineForClassFields: true,
239230
target: 'ES2021',
240231
},
@@ -245,6 +236,7 @@ test.suite('swc', (test) => {
245236
'useDefineForClassFields=false, new target, should still emit legacy property assignment in ctor',
246237
compileMacro,
247238
{
239+
module: 'esnext',
248240
useDefineForClassFields: false,
249241
target: 'ES2022',
250242
},
@@ -255,6 +247,7 @@ test.suite('swc', (test) => {
255247
'useDefineForClassFields=false, old target, should emit legacy property assignment in ctor',
256248
compileMacro,
257249
{
250+
module: 'esnext',
258251
useDefineForClassFields: false,
259252
},
260253
input,
@@ -267,6 +260,7 @@ test.suite('swc', (test) => {
267260
'jsx=react-jsx',
268261
compileMacro,
269262
{
263+
module: 'esnext',
270264
jsx: 'react-jsx',
271265
},
272266
outdent`
@@ -281,6 +275,7 @@ test.suite('swc', (test) => {
281275
'jsx=react-jsx w/custom jsxImportSource',
282276
compileMacro,
283277
{
278+
module: 'esnext',
284279
jsx: 'react-jsx',
285280
jsxImportSource: 'foo',
286281
},

src/transpilers/swc.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,15 @@ export function createSwcOptions(
208208
// isModule: true,
209209
module: moduleType
210210
? {
211-
noInterop: !esModuleInterop,
212211
type: moduleType,
213-
strictMode,
214-
// For NodeNext and Node12, emit as CJS but do not transform dynamic imports
215-
ignoreDynamic: nodeModuleEmitKind === 'nodecjs',
212+
...(moduleType === 'amd' || moduleType === 'commonjs' || moduleType === 'umd'
213+
? {
214+
noInterop: !esModuleInterop,
215+
strictMode,
216+
// For NodeNext and Node12, emit as CJS but do not transform dynamic imports
217+
ignoreDynamic: nodeModuleEmitKind === 'nodecjs',
218+
}
219+
: {}),
216220
}
217221
: undefined,
218222
swcrc: false,

yarn.lock

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -511,90 +511,90 @@ __metadata:
511511
languageName: node
512512
linkType: hard
513513

514-
"@swc/core-darwin-arm64@npm:1.3.84":
515-
version: 1.3.84
516-
resolution: "@swc/core-darwin-arm64@npm:1.3.84"
514+
"@swc/core-darwin-arm64@npm:1.3.85":
515+
version: 1.3.85
516+
resolution: "@swc/core-darwin-arm64@npm:1.3.85"
517517
conditions: os=darwin & cpu=arm64
518518
languageName: node
519519
linkType: hard
520520

521-
"@swc/core-darwin-x64@npm:1.3.84":
522-
version: 1.3.84
523-
resolution: "@swc/core-darwin-x64@npm:1.3.84"
521+
"@swc/core-darwin-x64@npm:1.3.85":
522+
version: 1.3.85
523+
resolution: "@swc/core-darwin-x64@npm:1.3.85"
524524
conditions: os=darwin & cpu=x64
525525
languageName: node
526526
linkType: hard
527527

528-
"@swc/core-linux-arm-gnueabihf@npm:1.3.84":
529-
version: 1.3.84
530-
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.84"
528+
"@swc/core-linux-arm-gnueabihf@npm:1.3.85":
529+
version: 1.3.85
530+
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.85"
531531
conditions: os=linux & cpu=arm
532532
languageName: node
533533
linkType: hard
534534

535-
"@swc/core-linux-arm64-gnu@npm:1.3.84":
536-
version: 1.3.84
537-
resolution: "@swc/core-linux-arm64-gnu@npm:1.3.84"
535+
"@swc/core-linux-arm64-gnu@npm:1.3.85":
536+
version: 1.3.85
537+
resolution: "@swc/core-linux-arm64-gnu@npm:1.3.85"
538538
conditions: os=linux & cpu=arm64 & libc=glibc
539539
languageName: node
540540
linkType: hard
541541

542-
"@swc/core-linux-arm64-musl@npm:1.3.84":
543-
version: 1.3.84
544-
resolution: "@swc/core-linux-arm64-musl@npm:1.3.84"
542+
"@swc/core-linux-arm64-musl@npm:1.3.85":
543+
version: 1.3.85
544+
resolution: "@swc/core-linux-arm64-musl@npm:1.3.85"
545545
conditions: os=linux & cpu=arm64 & libc=musl
546546
languageName: node
547547
linkType: hard
548548

549-
"@swc/core-linux-x64-gnu@npm:1.3.84":
550-
version: 1.3.84
551-
resolution: "@swc/core-linux-x64-gnu@npm:1.3.84"
549+
"@swc/core-linux-x64-gnu@npm:1.3.85":
550+
version: 1.3.85
551+
resolution: "@swc/core-linux-x64-gnu@npm:1.3.85"
552552
conditions: os=linux & cpu=x64 & libc=glibc
553553
languageName: node
554554
linkType: hard
555555

556-
"@swc/core-linux-x64-musl@npm:1.3.84":
557-
version: 1.3.84
558-
resolution: "@swc/core-linux-x64-musl@npm:1.3.84"
556+
"@swc/core-linux-x64-musl@npm:1.3.85":
557+
version: 1.3.85
558+
resolution: "@swc/core-linux-x64-musl@npm:1.3.85"
559559
conditions: os=linux & cpu=x64 & libc=musl
560560
languageName: node
561561
linkType: hard
562562

563-
"@swc/core-win32-arm64-msvc@npm:1.3.84":
564-
version: 1.3.84
565-
resolution: "@swc/core-win32-arm64-msvc@npm:1.3.84"
563+
"@swc/core-win32-arm64-msvc@npm:1.3.85":
564+
version: 1.3.85
565+
resolution: "@swc/core-win32-arm64-msvc@npm:1.3.85"
566566
conditions: os=win32 & cpu=arm64
567567
languageName: node
568568
linkType: hard
569569

570-
"@swc/core-win32-ia32-msvc@npm:1.3.84":
571-
version: 1.3.84
572-
resolution: "@swc/core-win32-ia32-msvc@npm:1.3.84"
570+
"@swc/core-win32-ia32-msvc@npm:1.3.85":
571+
version: 1.3.85
572+
resolution: "@swc/core-win32-ia32-msvc@npm:1.3.85"
573573
conditions: os=win32 & cpu=ia32
574574
languageName: node
575575
linkType: hard
576576

577-
"@swc/core-win32-x64-msvc@npm:1.3.84":
578-
version: 1.3.84
579-
resolution: "@swc/core-win32-x64-msvc@npm:1.3.84"
577+
"@swc/core-win32-x64-msvc@npm:1.3.85":
578+
version: 1.3.85
579+
resolution: "@swc/core-win32-x64-msvc@npm:1.3.85"
580580
conditions: os=win32 & cpu=x64
581581
languageName: node
582582
linkType: hard
583583

584-
"@swc/core@npm:1.3.84":
585-
version: 1.3.84
586-
resolution: "@swc/core@npm:1.3.84"
584+
"@swc/core@npm:1.3.85":
585+
version: 1.3.85
586+
resolution: "@swc/core@npm:1.3.85"
587587
dependencies:
588-
"@swc/core-darwin-arm64": 1.3.84
589-
"@swc/core-darwin-x64": 1.3.84
590-
"@swc/core-linux-arm-gnueabihf": 1.3.84
591-
"@swc/core-linux-arm64-gnu": 1.3.84
592-
"@swc/core-linux-arm64-musl": 1.3.84
593-
"@swc/core-linux-x64-gnu": 1.3.84
594-
"@swc/core-linux-x64-musl": 1.3.84
595-
"@swc/core-win32-arm64-msvc": 1.3.84
596-
"@swc/core-win32-ia32-msvc": 1.3.84
597-
"@swc/core-win32-x64-msvc": 1.3.84
588+
"@swc/core-darwin-arm64": 1.3.85
589+
"@swc/core-darwin-x64": 1.3.85
590+
"@swc/core-linux-arm-gnueabihf": 1.3.85
591+
"@swc/core-linux-arm64-gnu": 1.3.85
592+
"@swc/core-linux-arm64-musl": 1.3.85
593+
"@swc/core-linux-x64-gnu": 1.3.85
594+
"@swc/core-linux-x64-musl": 1.3.85
595+
"@swc/core-win32-arm64-msvc": 1.3.85
596+
"@swc/core-win32-ia32-msvc": 1.3.85
597+
"@swc/core-win32-x64-msvc": 1.3.85
598598
"@swc/types": ^0.1.4
599599
peerDependencies:
600600
"@swc/helpers": ^0.5.0
@@ -622,7 +622,7 @@ __metadata:
622622
peerDependenciesMeta:
623623
"@swc/helpers":
624624
optional: true
625-
checksum: dee45823923c29dde579ed1121c4392c937826d575c87f62399ba7a0b27cacfeb05da97b65cf49a721a50127bb1e22ca5c07defa784ec2a47fed33e3498ef1b9
625+
checksum: af9ec7d88fd9ad3dd876c8fea812b20ba734c2ed917c9f8281fd57c68ab57d5931ccb841f4467332b84c0cd522682737a770dfc8c3f9e0cc88cdce713971978c
626626
languageName: node
627627
linkType: hard
628628

@@ -633,10 +633,10 @@ __metadata:
633633
languageName: node
634634
linkType: hard
635635

636-
"@swc/wasm@npm:1.3.84":
637-
version: 1.3.84
638-
resolution: "@swc/wasm@npm:1.3.84"
639-
checksum: 85239cbee0b5aed83ff96fe884ae512a1e77be2c7400041babfda404a2161090f80360cbf659cef2871f17518b9aa844d3188dcce4d3b262396720a8aaa86966
636+
"@swc/wasm@npm:1.3.85":
637+
version: 1.3.85
638+
resolution: "@swc/wasm@npm:1.3.85"
639+
checksum: e4937fa9278eb11e7fd336937b3b5043a34a9236560e45df4d587566bafb6baedce68afbf34a984398bf33cffaf05b48a7662283fec2cfc7a93057845b68acb0
640640
languageName: node
641641
linkType: hard
642642

@@ -3828,8 +3828,8 @@ __metadata:
38283828
"@cspotcode/expect-stream": "https://github.com/cspotcode/node-expect-stream#4e425ff1eef240003af8716291e80fbaf3e3ae8f"
38293829
"@cspotcode/source-map-support": ^0.8.0
38303830
"@microsoft/api-extractor": ^7.19.4
3831-
"@swc/core": 1.3.84
3832-
"@swc/wasm": 1.3.84
3831+
"@swc/core": 1.3.85
3832+
"@swc/wasm": 1.3.85
38333833
"@tsconfig/node14": "*"
38343834
"@tsconfig/node16": "*"
38353835
"@tsconfig/node18": "*"
@@ -3866,8 +3866,8 @@ __metadata:
38663866
v8-compile-cache-lib: ^3.0.1
38673867
workaround-broken-npm-prepack-behavior: "https://github.com/cspotcode/workaround-broken-npm-prepack-behavior#1a7adbbb8a527784daf97edad6ba42d6e96611f6"
38683868
peerDependencies:
3869-
"@swc/core": ">=1.2.50"
3870-
"@swc/wasm": ">=1.2.50"
3869+
"@swc/core": ">=1.3.85"
3870+
"@swc/wasm": ">=1.3.85"
38713871
"@types/node": "*"
38723872
typescript: ">=4.4"
38733873
peerDependenciesMeta:

0 commit comments

Comments
 (0)