@swc/core 1.2.131 → 1.2.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +365 -0
  2. package/binding.js +94 -71
  3. package/package.json +16 -16
package/CHANGELOG.md CHANGED
@@ -5,6 +5,371 @@
5
5
 
6
6
 
7
7
 
8
+ - **(css)** Fix parsing of `@page` at-rule (#3356) ([4853821](https://github.com/swc-project/swc/commit/4853821d004f366c89c1b9122786e26ff923df05))
9
+
10
+
11
+ - **(css/ast)** Fix type definitions for `@document` at-rule (#3468) ([df08e4c](https://github.com/swc-project/swc/commit/df08e4cfd7ed76fcfd00cc8245b13cc328513938))
12
+
13
+
14
+ - **(css/parser)** Report errors of at-rules (#3461) ([e732250](https://github.com/swc-project/swc/commit/e732250cdf74c47faf5321b650a9cea6bd1ab4d4))
15
+
16
+
17
+ - **(es/compat)** Handle private fields in nested classes (#3431) ([01500a5](https://github.com/swc-project/swc/commit/01500a54e04b88d08edff09f218166c862763657))
18
+
19
+
20
+ - **(es/compat)** Handle initializer hole in array patterns (#3442) ([3bb2a6c](https://github.com/swc-project/swc/commit/3bb2a6ccca4e78412f80aea4fe6c22d04d345a00))
21
+
22
+
23
+ - **(es/compat)** Fix legacy decorator pass (#3459) ([4f5e87b](https://github.com/swc-project/swc/commit/4f5e87b66b42a5672e00edcfa22234f1cde79580))
24
+
25
+
26
+ - **(es/fixer)** Handle more expressions in the super class position (#3452) ([032f397](https://github.com/swc-project/swc/commit/032f397b52415378ede985be35713a3482093958))
27
+
28
+
29
+ - **(es/minifier)** Fix `codemirror` (#3462) ([5812c3c](https://github.com/swc-project/swc/commit/5812c3c10fc224fbb33a17302491c5f7c2bd0a0b))
30
+
31
+
32
+ - **(es/minifier)** Fix `mapbox` (#3463) ([0371c41](https://github.com/swc-project/swc/commit/0371c41b7cb9d505705a956b84b8e4dbe626a17c))
33
+
34
+
35
+ - **(es/modules)** Allow using a dynamic import with an expression from another import (#3450) ([745604b](https://github.com/swc-project/swc/commit/745604b26d9151732d2572307dbeb22b2d10ca66))
36
+
37
+
38
+ - **(es/parser)** Fix parsing of decorators (#3449) ([5a806c5](https://github.com/swc-project/swc/commit/5a806c5b817c63b7c4f7730b538831b1cea62711))
39
+
40
+
41
+ - **(es/resolver)** Fix handling of for statements (#3446) ([2af5096](https://github.com/swc-project/swc/commit/2af5096e83229df1e5ccfe62659360c0392ef0ba))
42
+
43
+ ### Features
44
+
45
+
46
+
47
+ - **(css/ast)** Improve types related to `url` tokens (#3444) ([49564d9](https://github.com/swc-project/swc/commit/49564d9b5d627b38b2faa63b55076cb55ba8d1a7))
48
+
49
+
50
+ - **(css/codegen)** Implement minification of hex colors (#3453) ([eeedd71](https://github.com/swc-project/swc/commit/eeedd71705dc9b94363ec4e002ec647a3addba2d))
51
+
52
+
53
+ - **(css/codegen)** Implement minification of identifiers (#3466) ([81850c2](https://github.com/swc-project/swc/commit/81850c2b30693061428569c9a6ebd4a3f07d7683))
54
+
55
+
56
+ - **(css/codegen)** Improve minification for page rules (#3467) ([0ca036a](https://github.com/swc-project/swc/commit/0ca036a962042727e362b91748aa10547c87fc63))
57
+
58
+
59
+ - **(css/lexer)** Implement error recovery for functions (#3445) ([f1410fc](https://github.com/swc-project/swc/commit/f1410fc09b4838fa8113c9b2041f58d7d752c519))
60
+
61
+
62
+ - **(es/lints)** Implement `prefer-regex-literals` (#3399) ([8166275](https://github.com/swc-project/swc/commit/81662751666b5d49458ab8dad15f3c73e89ef2f6))
63
+
64
+
65
+ - **(es/lints)** Implement linter for quotes of string literals (#3443) ([5d6143a](https://github.com/swc-project/swc/commit/5d6143a53c03d0caefc76ea54d6975126984d84d))
66
+
67
+
68
+ - **(es/parser)** Add an option to allow `super` outside of class methods (#3427) ([cc185f0](https://github.com/swc-project/swc/commit/cc185f01cb249634d144830db702a281674f48da))
69
+
70
+ ### Miscellaneous Tasks
71
+
72
+
73
+
74
+ - **(es/lints)** Fix CI ([b06a5ab](https://github.com/swc-project/swc/commit/b06a5abe5868c3652fe89927acd3a56ea437b113))
75
+
76
+ ### Refactor
77
+
78
+
79
+
80
+ - **(css/ast)** Refactor types related to `@keyframes` at-rule (#3441) ([5c1b021](https://github.com/swc-project/swc/commit/5c1b02182df9ee2f59b8b83f58b5d0b1ae04af35))
81
+
82
+
83
+ - **(css/ast)** Change AST for `!important` (#3440) ([38879de](https://github.com/swc-project/swc/commit/38879de8deec6a45882252104fdcbb33cc3116a9))
84
+
85
+
86
+ - **(css/ast)** Refactor types related to selectors (#3460) ([cd87d96](https://github.com/swc-project/swc/commit/cd87d965f35155748ec0e3b22deae3d8a5ebdb5b))
87
+
88
+
89
+ - **(css/ast)** Remove unused types (#3465) ([69660fd](https://github.com/swc-project/swc/commit/69660fd161e0cce5eca7b7f5d436d4bb67dea64f))
90
+
91
+ ### Testing
92
+
93
+
94
+
95
+ - **(css/parser)** Add more tests for the selector parser (#3455) ([479b509](https://github.com/swc-project/swc/commit/479b50984513296439af2814f990eb88486b82d5))
96
+
97
+
98
+ - **(es)** Update tsc test suite (#3448) ([8b7c38c](https://github.com/swc-project/swc/commit/8b7c38c80ceeb8fc41ad4c60eb427dab9c06ba6e))
99
+
100
+
101
+ - **(es/parser)** Fix crlf (#3451) ([397a96a](https://github.com/swc-project/swc/commit/397a96a1cf4a0d540db6e766890ed874f7818a65))
102
+
103
+ ## [1.2.136] - 2022-02-03
104
+
105
+ ### Bug Fixes
106
+
107
+
108
+
109
+ - **(css)** Allow empty `@media` at-rule (#3404) ([75a14f9](https://github.com/swc-project/swc/commit/75a14f98b7370226115ee24eec6eb8c802bd4837))
110
+
111
+
112
+ - **(css/parser)** Fix parser logic related to case insensivity (#3382) ([3ded88b](https://github.com/swc-project/swc/commit/3ded88bffca4abd0bb77a52b0dfb32d8c8520581))
113
+
114
+
115
+ - **(css/parser)** Fix bugs related to `url` (#3403) ([3c8d985](https://github.com/swc-project/swc/commit/3c8d985a07baf5a52f40221fcc73344b3ca48d15))
116
+
117
+
118
+ - **(es/codegen)** Fix bugs (#3436) ([ea8dfd8](https://github.com/swc-project/swc/commit/ea8dfd872ced8e264ad3d6da7f07c0043dacfb27))
119
+
120
+
121
+ - **(es/compat)** Add the missing span in `optional_chaining` (#3384) ([9eb7773](https://github.com/swc-project/swc/commit/9eb77738fd1049022693f52843483623553856dd))
122
+
123
+
124
+ - **(es/minifier)** Fix evaluator (#3391) ([38c2499](https://github.com/swc-project/swc/commit/38c2499358e2dc4df5b6acee25da54fe411f6e8a))
125
+
126
+
127
+ - **(es/modules)** Allow using dynamic import with a name from another import (#3390) ([1dcc188](https://github.com/swc-project/swc/commit/1dcc188dd8230954e2801f7c6e3034b0c0215bc4))
128
+
129
+
130
+ - **(es/modules)** Fix span of imports (#3418) ([2c99ca1](https://github.com/swc-project/swc/commit/2c99ca1bab353668f5c475ab6cb223186701927a))
131
+
132
+
133
+ - **(swc)** Run `resolver` before everything (#3400) ([cebc5dc](https://github.com/swc-project/swc/commit/cebc5dc148fa4c03a536a841a106955de18b010b))
134
+
135
+ ### Features
136
+
137
+
138
+
139
+ - **(css)** Improve codegen where `minify: true` (#3414) ([30c29a3](https://github.com/swc-project/swc/commit/30c29a30cfbcc9f41adb83a8fe7d277084dd8053))
140
+
141
+
142
+ - **(css/ast)** Add `/` to the delimiters (#3402) ([2dc31d9](https://github.com/swc-project/swc/commit/2dc31d9d142a4e76529507596bc476590b4a26e9))
143
+
144
+
145
+ - **(css/codegen)** Implement `minify: true` (#3369) ([0537ef1](https://github.com/swc-project/swc/commit/0537ef1a1170da5c693a36cd20fd2b089a8a3618))
146
+
147
+
148
+ - **(css/codegen)** Improve minification of numbers (#3423) ([340844a](https://github.com/swc-project/swc/commit/340844ae6eb2617d8bec07e7c27ade9f320184b8))
149
+
150
+
151
+ - **(css/parser)** Improve selector parser (#3386) ([c73835b](https://github.com/swc-project/swc/commit/c73835bfebe56518e107a3666fe95ca649d33a24))
152
+
153
+
154
+ - **(css/parser)** Improve parsing of math functions (#3415) ([1b1cae0](https://github.com/swc-project/swc/commit/1b1cae037279be2e1f66788f0cb1539b7b8d6721))
155
+
156
+
157
+ - **(es/codegen)** Improve compression of numbers (#3425) ([e8b64a9](https://github.com/swc-project/swc/commit/e8b64a9871ccfda5f5fb1f03662650f3500e6634))
158
+
159
+
160
+ - **(es/lints)** Implement `no-debugger` rule (#3398) ([9dec923](https://github.com/swc-project/swc/commit/9dec9236f7b3c95c803571404d7abae71e173936))
161
+
162
+
163
+ - **(es/lints)** Add `no-alert` and a feature gate (#3394) ([5cbe4fe](https://github.com/swc-project/swc/commit/5cbe4fe512c67dd6017e0142b12465e20a2153a5))
164
+
165
+
166
+ - **(es/minifier)** Implement `drop_console` (#3392) ([91d7800](https://github.com/swc-project/swc/commit/91d78000ea445575f9ac30d0f36299ab4f0cbf5c))
167
+
168
+ ### Miscellaneous Tasks
169
+
170
+
171
+
172
+ - **(repo)** Add `clippy` to git push hook (#3383) ([78e83a3](https://github.com/swc-project/swc/commit/78e83a386b62abaf9b38b58b5dd942de2333e3a6))
173
+
174
+ ### Performance
175
+
176
+
177
+
178
+ - **(node-swc)** Speed up `parse` and `parseFile` (#3380) ([0359deb](https://github.com/swc-project/swc/commit/0359deb4841be743d73db4536d4a22ac797d7f65))
179
+
180
+ ### Refactor
181
+
182
+
183
+
184
+ - **(css/ast)** Refactor delimited values (#3397) ([b31619d](https://github.com/swc-project/swc/commit/b31619d48e2caa29ae581331eaf2ed4c4bb93683))
185
+
186
+
187
+ - **(css/ast)** Use `Dimension` instead of `UnitValue` (#3401) ([1904944](https://github.com/swc-project/swc/commit/1904944bf7767183a667a533a9f2089447f06c48))
188
+
189
+
190
+ - **(css/ast)** Use `Color` instead of `HashValue` (#3411) ([6b921ca](https://github.com/swc-project/swc/commit/6b921cac02e801318529ad5511104ddb4ac6a6c6))
191
+
192
+
193
+ - **(css/ast)** Rename `property` to `name` (#3410) ([eeedd9a](https://github.com/swc-project/swc/commit/eeedd9adf573b75435ecf7c87a71f9d8c5b64b20))
194
+
195
+
196
+ - **(es/minifier)** Remove unused crates (#3395) ([74b4330](https://github.com/swc-project/swc/commit/74b433080bf79026fbcb905d7f0fba435822df68))
197
+
198
+
199
+ - **(es/parser)** Flatten tests to make `git` faster (#3393) ([839d0ac](https://github.com/swc-project/swc/commit/839d0ac480f0a702ac40bf14ba84d192cde47ec6))
200
+
201
+ ### Testing
202
+
203
+
204
+
205
+ - **(css/codegen)** Add more tests (#3405) ([64383e3](https://github.com/swc-project/swc/commit/64383e385cc6a5b735273218f31a4430a772c941))
206
+
207
+
208
+ - **(css/codegen)** Verify AST is not broken after minification (#3430) ([73efd72](https://github.com/swc-project/swc/commit/73efd72cbe03f3f386dadf3c969763f15bb9b41d))
209
+
210
+
211
+ - **(swc)** Add tests (#3435) ([9e4cea0](https://github.com/swc-project/swc/commit/9e4cea017c2230e3d8db8dc48c3196116e90198a))
212
+
213
+ ## [1.2.135] - 2022-01-27
214
+
215
+ ### Bug Fixes
216
+
217
+
218
+
219
+ - **(css)** Fix the type definition of `@support` at-rules (#3330) ([34943ff](https://github.com/swc-project/swc/commit/34943ffa15ddecb56ee0889a598dfd3d0aa4025c))
220
+
221
+
222
+ - **(css)** Fix `@keyframes` at-rule (#3331) ([f89ffa6](https://github.com/swc-project/swc/commit/f89ffa67aea6c99ec61a961754001e7fa85b86b5))
223
+
224
+
225
+ - **(css)** Fix `@supports` at-rule (#3329) ([9f38060](https://github.com/swc-project/swc/commit/9f3806029c4aa47944f38e1b1c4c8feac4ace4c1))
226
+
227
+
228
+ - **(css/parser)** Fix parsing of at rules (#3328) ([506a310](https://github.com/swc-project/swc/commit/506a31078aaebf50129658f096bbd5929995205f))
229
+
230
+
231
+ - **(es/block-scoping)** Pop scope correctly on early returns (#3360) ([b1a8db6](https://github.com/swc-project/swc/commit/b1a8db61943d022bcbed583eb3562510d1ed727c))
232
+
233
+
234
+ - **(es/compat)** Fix regression of `destructuring` (#3326) ([6d1ad36](https://github.com/swc-project/swc/commit/6d1ad368aca53ee64a63ae565cd015909f2f4458))
235
+
236
+
237
+ - **(es/compat)** Handle nested functions in `private_field` (#3355) ([29aaac1](https://github.com/swc-project/swc/commit/29aaac1f15f747ea3f938bcab1d536168e9d36a6))
238
+
239
+
240
+ - **(es/loader)** Add an option to resolve symlinks with `true` as a default (#3340) ([afdb168](https://github.com/swc-project/swc/commit/afdb168aad9096e4653580a52cc7736915cd2b69))
241
+
242
+
243
+ - **(es/minifier)** Consider capturing while inlining (#3322) ([4f23d65](https://github.com/swc-project/swc/commit/4f23d651d1a8855f9383c5306d5e417c273c5c22))
244
+
245
+
246
+ - **(es/minifier)** Don't inline a var if the initializer is reassigned (#3333) ([d52a1f3](https://github.com/swc-project/swc/commit/d52a1f3899d7d782917ea1c8701e951fcd6c214f))
247
+
248
+
249
+ - **(es/minifier)** Respect block scoping while negating if statements (#3344) ([6921ffb](https://github.com/swc-project/swc/commit/6921ffbbda110384524114dc2d3230b8432e34cc))
250
+
251
+
252
+ - **(es/minifier)** Prepend/append correctly (#3367) ([703972d](https://github.com/swc-project/swc/commit/703972dc296fbdfc319d48d43ef3841ebfa56eb3))
253
+
254
+
255
+ - **(es/minifier)** Improve minifier (#3350) ([68e9017](https://github.com/swc-project/swc/commit/68e90173762feb2aa6744ca46f5d1185a89da271))
256
+
257
+
258
+ - **(es/module)** Remove `.jsx` file extension (#3334) ([b2bf38d](https://github.com/swc-project/swc/commit/b2bf38d025064a42c398ab321fc2e69401a3f74b))
259
+
260
+
261
+ - **(es/typescript)** Handle typescript enums with string values (#3339) ([da709fe](https://github.com/swc-project/swc/commit/da709fe3d351f76b51b526cfd0718d8e6cb8f2a0))
262
+
263
+
264
+ - **(swc)** Respect `jsc.experimental.keepImportAssertions` (#3352) ([d9dc2b9](https://github.com/swc-project/swc/commit/d9dc2b99dde69792db4f5a31ffc983f8b04c0bef))
265
+
266
+ ### Documentation
267
+
268
+
269
+
270
+ - **(contributing)** Fix formatting (#3376) ([90cf073](https://github.com/swc-project/swc/commit/90cf073ab91d44718235d8e0bc38953f7a4c1970))
271
+
272
+ ### Features
273
+
274
+
275
+
276
+ - **(css/ast)** Add `Ratio`, which is defined by spec (#3335) ([c7e5fae](https://github.com/swc-project/swc/commit/c7e5faea5c49333a3141111f92e3b36e29f6202c))
277
+
278
+
279
+ - **(css/ast)** Add types for dashed identifiers and `@color-profile` at-rules (#3364) ([dfa0286](https://github.com/swc-project/swc/commit/dfa0286aca8aeca49820ebb6a3b0e4461d30fe29))
280
+
281
+
282
+ - **(css/parser)** Improve parsing of urls (#3362) ([50521d8](https://github.com/swc-project/swc/commit/50521d8ffa3425ad26eb4630698f06b69c41ef2b))
283
+
284
+
285
+ - **(es/bugfix)** Add `bugfix-safari-id-destructuring-collision-in-function-expression` (#3109) ([d1c90a4](https://github.com/swc-project/swc/commit/d1c90a4e5f2ddfc71c6143ef07e16af352da25fa))
286
+
287
+
288
+ - **(es/codegen)** Emit comments of `Module` and `Script` (#3358) ([fcb7288](https://github.com/swc-project/swc/commit/fcb7288eb66e027fa7278b8f028e4486059241cd))
289
+
290
+
291
+ - **(es/lints)** Implement "no-console" rule (#3269) ([9872137](https://github.com/swc-project/swc/commit/987213797f71f9b5e0a0ac19edfbd18fe96a7ce5))
292
+
293
+
294
+ - **(es/minifier)** Handle array literals in `sequences` (#3348) ([8007b2d](https://github.com/swc-project/swc/commit/8007b2dc9338e34a1e9780606fd35181890af990))
295
+
296
+
297
+ - **(es/preset-env)** Upgrade `browserslist-rs` (#3375) ([d3d754b](https://github.com/swc-project/swc/commit/d3d754bd174bfbd0f6fc25276c40e46e3a3da01f))
298
+
299
+
300
+ - **(plugin)** Pass host context to plugins for diagnostics emission (#3359) ([a8debc1](https://github.com/swc-project/swc/commit/a8debc17f6082c033d3734a8e2c0cccc598c1d08))
301
+
302
+ ### Miscellaneous Tasks
303
+
304
+
305
+
306
+ - **(ci)** Update `thread_local` (#3357) ([a635e9f](https://github.com/swc-project/swc/commit/a635e9f35bb2a718abad56286d7b6fcecdfe4e58))
307
+
308
+
309
+ - **(ci)** Fix FreeBSD build (#3379) ([464c15b](https://github.com/swc-project/swc/commit/464c15b7757aedd50c80d955d7f2c78133a7f994))
310
+
311
+ ### Performance
312
+
313
+
314
+
315
+ - **(node)** Avoid cloning options (#3325) ([8a76935](https://github.com/swc-project/swc/commit/8a76935ca261579f23519d1e2c3b7849ba75a6e0))
316
+
317
+ ### Refactor
318
+
319
+
320
+
321
+ - **(css/ast)** Merge several kinds of blocks into a single type (#3336) ([c664eaf](https://github.com/swc-project/swc/commit/c664eafdefe2b8a65d3d745e4538063a33f93346))
322
+
323
+
324
+ - **(css/ast)** Fix type definitions related to `@import` at-rule (#3351) ([7787f90](https://github.com/swc-project/swc/commit/7787f90da02d198b26bc2236229446a19628c794))
325
+
326
+
327
+ - **(css/ast)** Rename `PercentValue` to `Percent` (#3363) ([6fc7562](https://github.com/swc-project/swc/commit/6fc7562686b0915c7a1280620ffe183de66e113f))
328
+
329
+
330
+ - **(es/minifier)** Merge execution tests into a file to make `git` faster (#3377) ([7ef3bfa](https://github.com/swc-project/swc/commit/7ef3bfa5b617bffeeb91240dbc2d842dcd48826c))
331
+
332
+
333
+ - **(plugin)** Remove multivalue polyfill (#3346) ([4386498](https://github.com/swc-project/swc/commit/438649818fb7e7b1ef6cddf5ba244f80cf7e69a9))
334
+
335
+ ## [1.2.133] - 2022-01-20
336
+
337
+ ### Bug Fixes
338
+
339
+
340
+
341
+ - **(css)** Fix parsing of media queries (#3318) ([0723ee2](https://github.com/swc-project/swc/commit/0723ee282861a1e648490989c122d5f4e683dc35))
342
+
343
+
344
+ - **(es/minifier)** Don't inline functions used as arguments (#3320) ([57204e3](https://github.com/swc-project/swc/commit/57204e39cd24ecdb190a671bd3e163ff0c2ab983))
345
+
346
+ ### Documentation
347
+
348
+
349
+
350
+ - **(repo)** Update contributing docs (#3298) ([5af79f6](https://github.com/swc-project/swc/commit/5af79f634b7431e886b254992e7fbdbe044d1e9d))
351
+
352
+ ### Miscellaneous Tasks
353
+
354
+
355
+
356
+ - **(rustc)** Downgrade rustc ([041bf00](https://github.com/swc-project/swc/commit/041bf003627e55cdef2839a31cbb3149e161eb6e))
357
+
358
+ ### Build
359
+
360
+
361
+
362
+ - **(node-swc)** Fix GLIBC < 2.18 compatible issues and android arm binary loading issue (#3314) ([9608605](https://github.com/swc-project/swc/commit/9608605772351a2406870e19ed8738adf2147374))
363
+
364
+
365
+ - **(node-swc)** Fix Windows arm64 build OOM (#3324) ([c069c78](https://github.com/swc-project/swc/commit/c069c78b21b9b4bf150d22e8ff333053f2039e3b))
366
+
367
+ ## [1.2.131] - 2022-01-19
368
+
369
+ ### Bug Fixes
370
+
371
+
372
+
8
373
  - **(common)** Use `siphasher` directly and upgrade transitive dependencies to avoid UB (#3299) ([641265b](https://github.com/swc-project/swc/commit/641265b147da9478f5d205ddc0c7c16ed94b8676))
9
374
 
10
375
 
package/binding.js CHANGED
@@ -1,75 +1,98 @@
1
1
  "use strict";
2
- const { existsSync, readFileSync } = require('fs');
3
- const { join } = require('path');
2
+ const { existsSync, readFileSync } = require("fs");
3
+ const { join } = require("path");
4
4
  const { platform, arch } = process;
5
5
  let nativeBinding = null;
6
6
  let localFileExisted = false;
7
7
  let loadError = null;
8
- const isMusl = () => {
9
- try {
10
- const isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl');
11
- return isMusl;
12
- }
13
- catch (e) {
14
- return false;
15
- }
16
- };
17
- switch (platform) {
18
- case 'android':
19
- if (arch !== 'arm64') {
20
- throw new Error(`Unsupported architecture on Android ${arch}`);
21
- }
22
- localFileExisted = existsSync(join(__dirname, 'swc.android-arm64.node'));
8
+ function isMusl() {
9
+ // For Node 10
10
+ if (!process.report || typeof process.report.getReport !== "function") {
23
11
  try {
24
- if (localFileExisted) {
25
- nativeBinding = require('./swc.android-arm64.node');
26
- }
27
- else {
28
- nativeBinding = require('@swc/core-android-arm64');
29
- }
12
+ return readFileSync("/usr/bin/ldd", "utf8").includes("musl");
30
13
  }
31
14
  catch (e) {
32
- loadError = e;
15
+ return true;
16
+ }
17
+ }
18
+ else {
19
+ const { glibcVersionRuntime } = process.report.getReport().header;
20
+ return !glibcVersionRuntime;
21
+ }
22
+ }
23
+ switch (platform) {
24
+ case "android":
25
+ switch (arch) {
26
+ case "arm64":
27
+ localFileExisted = existsSync(join(__dirname, "swc.android-arm64.node"));
28
+ try {
29
+ if (localFileExisted) {
30
+ nativeBinding = require("./swc.android-arm64.node");
31
+ }
32
+ else {
33
+ nativeBinding = require("@swc/core-android-arm64");
34
+ }
35
+ }
36
+ catch (e) {
37
+ loadError = e;
38
+ }
39
+ break;
40
+ case "arm":
41
+ localFileExisted = existsSync(join(__dirname, "swc.android-arm-eabi.node"));
42
+ try {
43
+ if (localFileExisted) {
44
+ nativeBinding = require("./swc.android-arm-eabi.node");
45
+ }
46
+ else {
47
+ nativeBinding = require("@swc/core-android-arm-eabi");
48
+ }
49
+ }
50
+ catch (e) {
51
+ loadError = e;
52
+ }
53
+ break;
54
+ default:
55
+ throw new Error(`Unsupported architecture on Android ${arch}`);
33
56
  }
34
57
  break;
35
- case 'win32':
58
+ case "win32":
36
59
  switch (arch) {
37
- case 'x64':
38
- localFileExisted = existsSync(join(__dirname, 'swc.win32-x64-msvc.node'));
60
+ case "x64":
61
+ localFileExisted = existsSync(join(__dirname, "swc.win32-x64-msvc.node"));
39
62
  try {
40
63
  if (localFileExisted) {
41
- nativeBinding = require('./swc.win32-x64-msvc.node');
64
+ nativeBinding = require("./swc.win32-x64-msvc.node");
42
65
  }
43
66
  else {
44
- nativeBinding = require('@swc/core-win32-x64-msvc');
67
+ nativeBinding = require("@swc/core-win32-x64-msvc");
45
68
  }
46
69
  }
47
70
  catch (e) {
48
71
  loadError = e;
49
72
  }
50
73
  break;
51
- case 'ia32':
52
- localFileExisted = existsSync(join(__dirname, 'swc.win32-ia32-msvc.node'));
74
+ case "ia32":
75
+ localFileExisted = existsSync(join(__dirname, "swc.win32-ia32-msvc.node"));
53
76
  try {
54
77
  if (localFileExisted) {
55
- nativeBinding = require('./swc.win32-ia32-msvc.node');
78
+ nativeBinding = require("./swc.win32-ia32-msvc.node");
56
79
  }
57
80
  else {
58
- nativeBinding = require('@swc/core-win32-ia32-msvc');
81
+ nativeBinding = require("@swc/core-win32-ia32-msvc");
59
82
  }
60
83
  }
61
84
  catch (e) {
62
85
  loadError = e;
63
86
  }
64
87
  break;
65
- case 'arm64':
66
- localFileExisted = existsSync(join(__dirname, 'swc.win32-arm64-msvc.node'));
88
+ case "arm64":
89
+ localFileExisted = existsSync(join(__dirname, "swc.win32-arm64-msvc.node"));
67
90
  try {
68
91
  if (localFileExisted) {
69
- nativeBinding = require('./swc.win32-arm64-msvc.node');
92
+ nativeBinding = require("./swc.win32-arm64-msvc.node");
70
93
  }
71
94
  else {
72
- nativeBinding = require('@swc/core-win32-arm64-msvc');
95
+ nativeBinding = require("@swc/core-win32-arm64-msvc");
73
96
  }
74
97
  }
75
98
  catch (e) {
@@ -80,30 +103,30 @@ switch (platform) {
80
103
  throw new Error(`Unsupported architecture on Windows: ${arch}`);
81
104
  }
82
105
  break;
83
- case 'darwin':
106
+ case "darwin":
84
107
  switch (arch) {
85
- case 'x64':
86
- localFileExisted = existsSync(join(__dirname, 'swc.darwin-x64.node'));
108
+ case "x64":
109
+ localFileExisted = existsSync(join(__dirname, "swc.darwin-x64.node"));
87
110
  try {
88
111
  if (localFileExisted) {
89
- nativeBinding = require('./swc.darwin-x64.node');
112
+ nativeBinding = require("./swc.darwin-x64.node");
90
113
  }
91
114
  else {
92
- nativeBinding = require('@swc/core-darwin-x64');
115
+ nativeBinding = require("@swc/core-darwin-x64");
93
116
  }
94
117
  }
95
118
  catch (e) {
96
119
  loadError = e;
97
120
  }
98
121
  break;
99
- case 'arm64':
100
- localFileExisted = existsSync(join(__dirname, 'swc.darwin-arm64.node'));
122
+ case "arm64":
123
+ localFileExisted = existsSync(join(__dirname, "swc.darwin-arm64.node"));
101
124
  try {
102
125
  if (localFileExisted) {
103
- nativeBinding = require('./swc.darwin-arm64.node');
126
+ nativeBinding = require("./swc.darwin-arm64.node");
104
127
  }
105
128
  else {
106
- nativeBinding = require('@swc/core-darwin-arm64');
129
+ nativeBinding = require("@swc/core-darwin-arm64");
107
130
  }
108
131
  }
109
132
  catch (e) {
@@ -114,34 +137,34 @@ switch (platform) {
114
137
  throw new Error(`Unsupported architecture on macOS: ${arch}`);
115
138
  }
116
139
  break;
117
- case 'freebsd':
118
- if (arch !== 'x64') {
140
+ case "freebsd":
141
+ if (arch !== "x64") {
119
142
  throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
120
143
  }
121
- localFileExisted = existsSync(join(__dirname, 'swc.freebsd-x64.node'));
144
+ localFileExisted = existsSync(join(__dirname, "swc.freebsd-x64.node"));
122
145
  try {
123
146
  if (localFileExisted) {
124
- nativeBinding = require('./swc.freebsd-x64.node');
147
+ nativeBinding = require("./swc.freebsd-x64.node");
125
148
  }
126
149
  else {
127
- nativeBinding = require('@swc/core-freebsd-x64');
150
+ nativeBinding = require("@swc/core-freebsd-x64");
128
151
  }
129
152
  }
130
153
  catch (e) {
131
154
  loadError = e;
132
155
  }
133
156
  break;
134
- case 'linux':
157
+ case "linux":
135
158
  switch (arch) {
136
- case 'x64':
159
+ case "x64":
137
160
  if (isMusl()) {
138
- localFileExisted = existsSync(join(__dirname, 'swc.linux-x64-musl.node'));
161
+ localFileExisted = existsSync(join(__dirname, "swc.linux-x64-musl.node"));
139
162
  try {
140
163
  if (localFileExisted) {
141
- nativeBinding = require('./swc.linux-x64-musl.node');
164
+ nativeBinding = require("./swc.linux-x64-musl.node");
142
165
  }
143
166
  else {
144
- nativeBinding = require('@swc/core-linux-x64-musl');
167
+ nativeBinding = require("@swc/core-linux-x64-musl");
145
168
  }
146
169
  }
147
170
  catch (e) {
@@ -149,13 +172,13 @@ switch (platform) {
149
172
  }
150
173
  }
151
174
  else {
152
- localFileExisted = existsSync(join(__dirname, 'swc.linux-x64-gnu.node'));
175
+ localFileExisted = existsSync(join(__dirname, "swc.linux-x64-gnu.node"));
153
176
  try {
154
177
  if (localFileExisted) {
155
- nativeBinding = require('./swc.linux-x64-gnu.node');
178
+ nativeBinding = require("./swc.linux-x64-gnu.node");
156
179
  }
157
180
  else {
158
- nativeBinding = require('@swc/core-linux-x64-gnu');
181
+ nativeBinding = require("@swc/core-linux-x64-gnu");
159
182
  }
160
183
  }
161
184
  catch (e) {
@@ -163,15 +186,15 @@ switch (platform) {
163
186
  }
164
187
  }
165
188
  break;
166
- case 'arm64':
189
+ case "arm64":
167
190
  if (isMusl()) {
168
- localFileExisted = existsSync(join(__dirname, 'swc.linux-arm64-musl.node'));
191
+ localFileExisted = existsSync(join(__dirname, "swc.linux-arm64-musl.node"));
169
192
  try {
170
193
  if (localFileExisted) {
171
- nativeBinding = require('./swc.linux-arm64-musl.node');
194
+ nativeBinding = require("./swc.linux-arm64-musl.node");
172
195
  }
173
196
  else {
174
- nativeBinding = require('@swc/core-linux-arm64-musl');
197
+ nativeBinding = require("@swc/core-linux-arm64-musl");
175
198
  }
176
199
  }
177
200
  catch (e) {
@@ -179,13 +202,13 @@ switch (platform) {
179
202
  }
180
203
  }
181
204
  else {
182
- localFileExisted = existsSync(join(__dirname, 'swc.linux-arm64-gnu.node'));
205
+ localFileExisted = existsSync(join(__dirname, "swc.linux-arm64-gnu.node"));
183
206
  try {
184
207
  if (localFileExisted) {
185
- nativeBinding = require('./swc.linux-arm64-gnu.node');
208
+ nativeBinding = require("./swc.linux-arm64-gnu.node");
186
209
  }
187
210
  else {
188
- nativeBinding = require('@swc/core-linux-arm64-gnu');
211
+ nativeBinding = require("@swc/core-linux-arm64-gnu");
189
212
  }
190
213
  }
191
214
  catch (e) {
@@ -193,14 +216,14 @@ switch (platform) {
193
216
  }
194
217
  }
195
218
  break;
196
- case 'arm':
197
- localFileExisted = existsSync(join(__dirname, 'swc.linux-arm-gnueabihf.node'));
219
+ case "arm":
220
+ localFileExisted = existsSync(join(__dirname, "swc.linux-arm-gnueabihf.node"));
198
221
  try {
199
222
  if (localFileExisted) {
200
- nativeBinding = require('./swc.linux-arm-gnueabihf.node');
223
+ nativeBinding = require("./swc.linux-arm-gnueabihf.node");
201
224
  }
202
225
  else {
203
- nativeBinding = require('@swc/core-linux-arm-gnueabihf');
226
+ nativeBinding = require("@swc/core-linux-arm-gnueabihf");
204
227
  }
205
228
  }
206
229
  catch (e) {
@@ -220,7 +243,7 @@ if (!nativeBinding) {
220
243
  }
221
244
  throw new Error(`Failed to load native binding`);
222
245
  }
223
- const { bundle, minify, minifySync, parse, parseSync, parseFileSync, parseFile, print, printSync, transform, transformSync, transformFile, transformFileSync, Compiler } = nativeBinding;
246
+ const { bundle, minify, minifySync, parse, parseSync, parseFileSync, parseFile, print, printSync, transform, transformSync, transformFile, transformFileSync, Compiler, } = nativeBinding;
224
247
  module.exports.bundle = bundle;
225
248
  module.exports.minify = minify;
226
249
  module.exports.minifySync = minifySync;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.131",
3
+ "version": "1.2.137",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
@@ -48,22 +48,22 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@node-rs/helper": "^1.0.0"
51
+ "ts-node": "^10.4.0"
52
52
  },
53
53
  "optionalDependencies": {
54
- "@swc/core-win32-x64-msvc": "1.2.131",
55
- "@swc/core-darwin-x64": "1.2.131",
56
- "@swc/core-linux-x64-gnu": "1.2.131",
57
- "@swc/core-linux-x64-musl": "1.2.131",
58
- "@swc/core-freebsd-x64": "1.2.131",
59
- "@swc/core-win32-ia32-msvc": "1.2.131",
60
- "@swc/core-linux-arm64-gnu": "1.2.131",
61
- "@swc/core-linux-arm-gnueabihf": "1.2.131",
62
- "@swc/core-darwin-arm64": "1.2.131",
63
- "@swc/core-android-arm64": "1.2.131",
64
- "@swc/core-linux-arm64-musl": "1.2.131",
65
- "@swc/core-win32-arm64-msvc": "1.2.131",
66
- "@swc/core-android-arm-eabi": "1.2.131"
54
+ "@swc/core-win32-x64-msvc": "1.2.137",
55
+ "@swc/core-darwin-x64": "1.2.137",
56
+ "@swc/core-linux-x64-gnu": "1.2.137",
57
+ "@swc/core-linux-x64-musl": "1.2.137",
58
+ "@swc/core-freebsd-x64": "1.2.137",
59
+ "@swc/core-win32-ia32-msvc": "1.2.137",
60
+ "@swc/core-linux-arm64-gnu": "1.2.137",
61
+ "@swc/core-linux-arm-gnueabihf": "1.2.137",
62
+ "@swc/core-darwin-arm64": "1.2.137",
63
+ "@swc/core-android-arm64": "1.2.137",
64
+ "@swc/core-linux-arm64-musl": "1.2.137",
65
+ "@swc/core-win32-arm64-msvc": "1.2.137",
66
+ "@swc/core-android-arm-eabi": "1.2.137"
67
67
  },
68
68
  "types": "./index.d.ts",
69
69
  "scripts": {
@@ -87,7 +87,7 @@
87
87
  "@babel/preset-react": "^7.13.13",
88
88
  "@babel/preset-typescript": "^7.13.0",
89
89
  "@babel/types": "^7.14.0",
90
- "@napi-rs/cli": "^2.0.0",
90
+ "@napi-rs/cli": "^2.4.2",
91
91
  "@swc/helpers": "^0.2.10",
92
92
  "@types/jest": "^26.0.23",
93
93
  "@types/node": "^14.14.41",