@swc/core 1.2.121 → 1.2.125

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,257 @@
5
5
 
6
6
 
7
7
 
8
+ - **(es/compat)** Visit all private class methods (#3150) ([35b6461](https://github.com/swc-project/swc/commit/35b64613bb1f6de52d7362e66d28c50513dbbe12))
9
+
10
+
11
+ - **(es/compat)** Fix length of async functions (#3136) ([f78d005](https://github.com/swc-project/swc/commit/f78d005a9587d2ea44741c4cef80fa711e8a1d26))
12
+
13
+
14
+ - **(es/compat)** Fix `new.target` in class properties (#3156) ([e112103](https://github.com/swc-project/swc/commit/e11210309cf2aab4aae77a76e4cdfba0bf9efa40))
15
+
16
+
17
+ - **(es/minifier)** Fix for modules (#3170) ([790c506](https://github.com/swc-project/swc/commit/790c50631ba1daa124e62bcee299f89031a4ec3d))
18
+
19
+
20
+ - **(es/typescript)** Fix handling of references in a TypeScript enum (#3163) ([e02307d](https://github.com/swc-project/swc/commit/e02307d4c82e043079131b414198ee5b4b7560e5))
21
+
22
+
23
+ - **(es/typescript)** Declare the exported variables in a namespace (#3162) ([366dc0e](https://github.com/swc-project/swc/commit/366dc0eec3e19b4e608dc4df8eb728f6d710f9b7))
24
+
25
+
26
+ - **(es/utils)** Fix handling of `new.target` (#3145) ([356082a](https://github.com/swc-project/swc/commit/356082ad84fa69cf09b5627598a2576bd1b27c36))
27
+
28
+ ### Documentation
29
+
30
+
31
+
32
+ - **(es/ast)** Improve rustdoc (#3142) ([333acb5](https://github.com/swc-project/swc/commit/333acb56223139817c1df0c8b3763190b55a6295))- **general**: Update discord link (#3161) ([fb20480](https://github.com/swc-project/swc/commit/fb2048035f0aa67761aa213c58795accfde7a6d0))
33
+
34
+ ### Features
35
+
36
+
37
+
38
+ - **(es/ast)** Add `rkyv` support (#3166) ([bf751cb](https://github.com/swc-project/swc/commit/bf751cb6905c7520f0846b9f0a6f4f44edecbdb3))
39
+
40
+
41
+ - **(es/codegen)** Make the output for empty objects and empty statements pretty (#3171) ([5296180](https://github.com/swc-project/swc/commit/52961804d19c413c09ff4e08c327647ffc3d0bea))
42
+
43
+
44
+ - **(es/diff)** Add a internal CLI program for debugging minifier (#3168) ([1aa55e6](https://github.com/swc-project/swc/commit/1aa55e616a7bc2ffa791600e908ddb10a4009e7b))
45
+
46
+ ### Miscellaneous Tasks
47
+
48
+
49
+
50
+ - **(ci)** Update `github-action-benchmark` (#3148) ([5a3bdc9](https://github.com/swc-project/swc/commit/5a3bdc9ed37ba39a0591c66bd89eddb95f6df850))- **general**: Add `enhancement` label to `feature_request` template (#3164) ([360ad7b](https://github.com/swc-project/swc/commit/360ad7b41c6fa35ce3afc81c2237d9acdae9a549))
51
+
52
+ ### Performance
53
+
54
+
55
+
56
+ - **(es/ast/serde)** Make deserialization faster (#3160) ([7a83c0c](https://github.com/swc-project/swc/commit/7a83c0cb575b0ec6510d8dff6d1bd44d9c97fdb9))
57
+
58
+ ### Refactor
59
+
60
+
61
+
62
+ - **(*)** Drop unused dependencies (#3138) ([72c9636](https://github.com/swc-project/swc/commit/72c963662d63338235378d71ee856c782cdeddfe))
63
+
64
+
65
+ - **(*)** Use 2021 edition (#3151) ([194b3e9](https://github.com/swc-project/swc/commit/194b3e9b67fb096dee8dbd12fff9167e4217174b))
66
+
67
+
68
+ - **(bundler)** Improve test suite (#3144) ([8a1016f](https://github.com/swc-project/swc/commit/8a1016fb406dd04dcf432ccf4e07036f81d4c9c6))
69
+
70
+ ### Testing
71
+
72
+
73
+
74
+ - **(es/parser)** Add tests about null escape (#3147) ([a4e8e53](https://github.com/swc-project/swc/commit/a4e8e53c1958f842206916eade24a269d582d69c))
75
+
76
+ ## [1.2.124] - 2021-12-29
77
+
78
+ ### Bug Fixes
79
+
80
+
81
+
82
+ - **(es)** Handle import assertions correctly (#3113) ([c9adf03](https://github.com/swc-project/swc/commit/c9adf0333811b2830fe3f3c06d6fd9706f7bb9ae))
83
+
84
+
85
+ - **(es/compat)** Fix handling of hoisted functions in regenerator (#3119) ([ac78a52](https://github.com/swc-project/swc/commit/ac78a527ebba3e8df2342e65b4fd5c2d36240ff0))
86
+
87
+
88
+ - **(es/compat)** Fix private methods of a class (#3123) ([1b6ac25](https://github.com/swc-project/swc/commit/1b6ac25d5c6c009c38a7097b910f7b6838ab560b))
89
+
90
+
91
+ - **(es/compat)** Fix `computed_properties` (#3120) ([27d3fd9](https://github.com/swc-project/swc/commit/27d3fd93b0ad2b5e305ded8145100b060ac6c2a3))
92
+
93
+
94
+ - **(es/optimization)** Fix inlining (#3132) ([693c22a](https://github.com/swc-project/swc/commit/693c22aa93ce115aca294f61feefe4582336ada3))
95
+
96
+
97
+ - **(es/parser)** Support import assertions in specifier-less imports (#3134) ([2f3ca22](https://github.com/swc-project/swc/commit/2f3ca22ecf7f567256695c39a904f02ff75e2c85))
98
+
99
+
100
+ - **(es/renamer)** Fix renamer (#3139) ([43c8cda](https://github.com/swc-project/swc/commit/43c8cda31a89bfc027ea3948bd9653d97d3fc29c))
101
+
102
+
103
+ - **(es/utils)** Fix `is_valid_ident` (#3133) ([ec7e0ae](https://github.com/swc-project/swc/commit/ec7e0aee256cc7cc13f81ef22164c29f42bb43be))
104
+
105
+
106
+ - **(node-swc)** Recover from `ldd` not found (#3125) ([054a195](https://github.com/swc-project/swc/commit/054a19518ce77f36520a17e146c65632aeab3080))
107
+
108
+ ### Features
109
+
110
+
111
+
112
+ - **(es/preset-env)** Upgrade `browserslist-rs` (#3122) ([83f71c2](https://github.com/swc-project/swc/commit/83f71c2c0b8382e70172b1e2d4d9a18852e7a995))
113
+
114
+ ### Miscellaneous Tasks
115
+
116
+
117
+
118
+ - **(ci)** Reduce CI time (#3128) ([61cd7da](https://github.com/swc-project/swc/commit/61cd7da265bd775605a0e48346f70b41adf9a225))
119
+
120
+ ### Refactor
121
+
122
+
123
+
124
+ - **(es/react/fast-refresh)** Use `VisitMut` (#3129) ([f8f04e0](https://github.com/swc-project/swc/commit/f8f04e031e218393abd8ae5ca6469484b0fe90d3))
125
+
126
+ ### Security
127
+
128
+
129
+
130
+ - **(repo)** Configure `cargo-crev` (#3124) ([cec325b](https://github.com/swc-project/swc/commit/cec325be6329bbdc175d7850443de8aabfcf31d6))
131
+
132
+ ## [1.2.123] - 2021-12-26
133
+
134
+ ### Bug Fixes
135
+
136
+
137
+
138
+ - **(es/ast)** Fix `Ident::verify_symbol` (#3108) ([e5971f7](https://github.com/swc-project/swc/commit/e5971f77d5861038f7dcd905a9aca72c84b1a035))
139
+
140
+
141
+ - **(es/compat)** Fix `classes` pass (#3107) ([d923f89](https://github.com/swc-project/swc/commit/d923f89db19b4343034569595dc3bbbce29b86b0))
142
+
143
+
144
+ - **(es/compat)** Fix `destructuring` (#3104) ([9f5a8f7](https://github.com/swc-project/swc/commit/9f5a8f728ade23640430d82f9f4bbcb341e30e2a))
145
+
146
+
147
+ - **(es/compat)** Fix handling of class methods with a big int as a key (#3118) ([a1cb4a4](https://github.com/swc-project/swc/commit/a1cb4a4aa57bd54e6718f293a65361952f4ef11d))
148
+
149
+
150
+ - **(es/helpers)** Fix decorators (#3105) ([f66c2cd](https://github.com/swc-project/swc/commit/f66c2cd375f78711fdf6a058003010bce8999aed))
151
+
152
+ ### Features
153
+
154
+
155
+
156
+ - **(es/bundler)** Add an option to disable tree-shaking (#3102) ([d98a593](https://github.com/swc-project/swc/commit/d98a59339a0fa2a14f2bcb92c6deeb810ec339be))
157
+
158
+
159
+ - **(es/diff)** Initialize a diff tool for ecmascript (#3101) ([ff0b55b](https://github.com/swc-project/swc/commit/ff0b55b7782cfa9c428d88d366520b53307bca42))
160
+
161
+
162
+ - **(node)** Upgrade `napi` to v2 (#2958) ([206da12](https://github.com/swc-project/swc/commit/206da128a1f1ecd43c7580a7ad5f58ebc363c812))
163
+
164
+ ### Miscellaneous Tasks
165
+
166
+
167
+
168
+ - **(ci)** Fix script for publishing ([f51314c](https://github.com/swc-project/swc/commit/f51314cd51990b2caf8b18a7d8a647236a0ec893))
169
+
170
+
171
+ - **(xi)** Fix publishing script ([e0e7f74](https://github.com/swc-project/swc/commit/e0e7f749551c15eae875457d584b869088794aea))- **general**: Fix `package.json` ([999df43](https://github.com/swc-project/swc/commit/999df436f7b9317167a822d6e0602324c8871dae))
172
+
173
+ ## [1.2.122] - 2021-12-22
174
+
175
+ ### Bug Fixes
176
+
177
+
178
+
179
+ - **(es/compat)** Fix handling of union of the legacy decorator pass (#3057) ([938e544](https://github.com/swc-project/swc/commit/938e544ac55503e91811cfc4e0c333deb2ccc7ed))
180
+
181
+
182
+ - **(es/loader)** Prefer ESM (#3089) ([ba2563f](https://github.com/swc-project/swc/commit/ba2563f59ed819e67a56e39cdcf38a7ccabd8f47))
183
+
184
+
185
+ - **(es/loader)** Update `lru` (#3092) ([15cbe4f](https://github.com/swc-project/swc/commit/15cbe4fcaad7b7b2f7bcc9fd413594a18ede25d8))
186
+
187
+
188
+ - **(es/transforms)** Fix `descturcturing` (#3098) ([df87c2b](https://github.com/swc-project/swc/commit/df87c2b30221f990cdd63125c9ef6036f370145e))
189
+
190
+
191
+ - **(es/typescript)** Export destructured properties in typescript namespaces (#3084) ([31dea3d](https://github.com/swc-project/swc/commit/31dea3dd319a19b75554b061cb1374d12718af24))
192
+
193
+ ### Features
194
+
195
+
196
+
197
+ - **(cli)** Setup packages for CLI (#3070) ([2e89a4f](https://github.com/swc-project/swc/commit/2e89a4f5a8fda133a8d990ecfc0104e64075d15c))
198
+
199
+
200
+ - **(es/dep-graph)** Add `DependencyDescriptor::dynamic_import_assertions` (#3095) ([7d57eb2](https://github.com/swc-project/swc/commit/7d57eb2dc490b4dd7c24c35f4a4df9c13f267d56))
201
+
202
+
203
+ - **(es/lints)** Implement simple validations (#2763) ([f21af5b](https://github.com/swc-project/swc/commit/f21af5bcd600aa94f8bd99b1250524bbc823662c))
204
+
205
+
206
+ - **(es/preset-env)** Upgrade `browserslist-rs` (#3069) ([a1b315a](https://github.com/swc-project/swc/commit/a1b315a114d63aa06856de63d02070d471c271d0))
207
+
208
+
209
+ - **(es/preset-env)** Add ES2022 features to `preset-env` (#3072) ([7beaabd](https://github.com/swc-project/swc/commit/7beaabd533c9f5f368da8baa7365c7e1a30f9512))
210
+
211
+
212
+ - **(es/preset-env)** Add `.js` to generated imports (#3077) ([7d125f5](https://github.com/swc-project/swc/commit/7d125f5cdb0c078cb02958c6d168f9c993f3e830))
213
+
214
+
215
+ - **(node)** Report correct error when `swc_v1` and `swc_v2` is enabled at the same time (#3080) ([f1b8126](https://github.com/swc-project/swc/commit/f1b81266cf895dac28f68151b9c16eaa9401ec43))
216
+
217
+
218
+ - **(node/core)** Include noop swc binaries (#3088) ([42046e1](https://github.com/swc-project/swc/commit/42046e104dfa301a803f3dfd85da2801b0ebad66))
219
+
220
+ ### Miscellaneous Tasks
221
+
222
+
223
+
224
+ - **(node)** Publish v1.2.122 ([f4cc323](https://github.com/swc-project/swc/commit/f4cc323e08c73f10bd4cc323a81dd5d3778395df))
225
+
226
+
227
+ - **(repo)** Make `git` faster (#3075) ([8afb5af](https://github.com/swc-project/swc/commit/8afb5af517e87b85ae1bdd8156509850c53fa276))
228
+
229
+
230
+ - **(repo)** Add section for the actual behavior to the issue template (#3100) ([0472199](https://github.com/swc-project/swc/commit/047219932fd18e7e78131f44ab5fb3be0518dc04))
231
+
232
+
233
+ - **(scripts)** Use `cargo profile instruments` instead of `cargo instruments` (#3086) ([d482d61](https://github.com/swc-project/swc/commit/d482d61b9fd9997367d0dd27e3b90c662064ae3d))
234
+
235
+ ### Performance
236
+
237
+
238
+
239
+ - **(es/hygiene)** Fix performance bug (#3090) ([a81661c](https://github.com/swc-project/swc/commit/a81661c74a59376b15b1211385e95891102d2928))
240
+
241
+ ### Refactor
242
+
243
+
244
+
245
+ - **(es/minifier)** Use `swc_timer` (#3087) ([0e4dce6](https://github.com/swc-project/swc/commit/0e4dce694da75f6fb3848a2f0479410bf3076412))
246
+
247
+ ### Testing
248
+
249
+
250
+
251
+ - **(es/codegen)** Add some tests for sourcemap (#3078) ([0e58950](https://github.com/swc-project/swc/commit/0e5895043ffdc76857f798e0daabc05797ff22ac))
252
+
253
+ ## [1.2.121] - 2021-12-19
254
+
255
+ ### Bug Fixes
256
+
257
+
258
+
8
259
  - **(es/compat)** Fix `block_scoping` (#3058) ([a381fb8](https://github.com/swc-project/swc/commit/a381fb8bce0ed82e7b0a201bb175acb13ce90205))
9
260
 
10
261
 
@@ -43,6 +294,9 @@
43
294
 
44
295
  - **(crates)** Use interactive bump ([276d74f](https://github.com/swc-project/swc/commit/276d74f2e9b508cd96e53c6798f28a7bb47afaed))
45
296
 
297
+
298
+ - **(node)** Publish v1.2.121 ([806c9db](https://github.com/swc-project/swc/commit/806c9db1a1c40e26402a08010ca74bc0f4221dab))
299
+
46
300
  ### Performance
47
301
 
48
302
 
package/binding.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export const bundle: any;
2
+ export const minify: any;
3
+ export const minifySync: any;
4
+ export const parse: any;
5
+ export const parseSync: any;
6
+ export const parseFileSync: any;
7
+ export const parseFile: any;
8
+ export const print: any;
9
+ export const printSync: any;
10
+ export const transform: any;
11
+ export const transformSync: any;
12
+ export const transformFile: any;
13
+ export const transformFileSync: any;
14
+ export const Compiler: any;
package/binding.js ADDED
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ const { existsSync, readFileSync } = require('fs');
3
+ const { join } = require('path');
4
+ const { platform, arch } = process;
5
+ let nativeBinding = null;
6
+ let localFileExisted = false;
7
+ let isMusl = false;
8
+ let loadError = null;
9
+ switch (platform) {
10
+ case 'android':
11
+ if (arch !== 'arm64') {
12
+ throw new Error(`Unsupported architecture on Android ${arch}`);
13
+ }
14
+ localFileExisted = existsSync(join(__dirname, 'swc.android-arm64.node'));
15
+ try {
16
+ if (localFileExisted) {
17
+ nativeBinding = require('./swc.android-arm64.node');
18
+ }
19
+ else {
20
+ nativeBinding = require('@swc/core-android-arm64');
21
+ }
22
+ }
23
+ catch (e) {
24
+ loadError = e;
25
+ }
26
+ break;
27
+ case 'win32':
28
+ switch (arch) {
29
+ case 'x64':
30
+ localFileExisted = existsSync(join(__dirname, 'swc.win32-x64-msvc.node'));
31
+ try {
32
+ if (localFileExisted) {
33
+ nativeBinding = require('./swc.win32-x64-msvc.node');
34
+ }
35
+ else {
36
+ nativeBinding = require('@swc/core-win32-x64-msvc');
37
+ }
38
+ }
39
+ catch (e) {
40
+ loadError = e;
41
+ }
42
+ break;
43
+ case 'ia32':
44
+ localFileExisted = existsSync(join(__dirname, 'swc.win32-ia32-msvc.node'));
45
+ try {
46
+ if (localFileExisted) {
47
+ nativeBinding = require('./swc.win32-ia32-msvc.node');
48
+ }
49
+ else {
50
+ nativeBinding = require('@swc/core-win32-ia32-msvc');
51
+ }
52
+ }
53
+ catch (e) {
54
+ loadError = e;
55
+ }
56
+ break;
57
+ case 'arm64':
58
+ localFileExisted = existsSync(join(__dirname, 'swc.win32-arm64-msvc.node'));
59
+ try {
60
+ if (localFileExisted) {
61
+ nativeBinding = require('./swc.win32-arm64-msvc.node');
62
+ }
63
+ else {
64
+ nativeBinding = require('@swc/core-win32-arm64-msvc');
65
+ }
66
+ }
67
+ catch (e) {
68
+ loadError = e;
69
+ }
70
+ break;
71
+ default:
72
+ throw new Error(`Unsupported architecture on Windows: ${arch}`);
73
+ }
74
+ break;
75
+ case 'darwin':
76
+ switch (arch) {
77
+ case 'x64':
78
+ localFileExisted = existsSync(join(__dirname, 'swc.darwin-x64.node'));
79
+ try {
80
+ if (localFileExisted) {
81
+ nativeBinding = require('./swc.darwin-x64.node');
82
+ }
83
+ else {
84
+ nativeBinding = require('@swc/core-darwin-x64');
85
+ }
86
+ }
87
+ catch (e) {
88
+ loadError = e;
89
+ }
90
+ break;
91
+ case 'arm64':
92
+ localFileExisted = existsSync(join(__dirname, 'swc.darwin-arm64.node'));
93
+ try {
94
+ if (localFileExisted) {
95
+ nativeBinding = require('./swc.darwin-arm64.node');
96
+ }
97
+ else {
98
+ nativeBinding = require('@swc/core-darwin-arm64');
99
+ }
100
+ }
101
+ catch (e) {
102
+ loadError = e;
103
+ }
104
+ break;
105
+ default:
106
+ throw new Error(`Unsupported architecture on macOS: ${arch}`);
107
+ }
108
+ break;
109
+ case 'freebsd':
110
+ if (arch !== 'x64') {
111
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
112
+ }
113
+ localFileExisted = existsSync(join(__dirname, 'swc.freebsd-x64.node'));
114
+ try {
115
+ if (localFileExisted) {
116
+ nativeBinding = require('./swc.freebsd-x64.node');
117
+ }
118
+ else {
119
+ nativeBinding = require('@swc/core-freebsd-x64');
120
+ }
121
+ }
122
+ catch (e) {
123
+ loadError = e;
124
+ }
125
+ break;
126
+ case 'linux':
127
+ switch (arch) {
128
+ case 'x64':
129
+ isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl');
130
+ if (isMusl) {
131
+ localFileExisted = existsSync(join(__dirname, 'swc.linux-x64-musl.node'));
132
+ try {
133
+ if (localFileExisted) {
134
+ nativeBinding = require('./swc.linux-x64-musl.node');
135
+ }
136
+ else {
137
+ nativeBinding = require('@swc/core-linux-x64-musl');
138
+ }
139
+ }
140
+ catch (e) {
141
+ loadError = e;
142
+ }
143
+ }
144
+ else {
145
+ localFileExisted = existsSync(join(__dirname, 'swc.linux-x64-gnu.node'));
146
+ try {
147
+ if (localFileExisted) {
148
+ nativeBinding = require('./swc.linux-x64-gnu.node');
149
+ }
150
+ else {
151
+ nativeBinding = require('@swc/core-linux-x64-gnu');
152
+ }
153
+ }
154
+ catch (e) {
155
+ loadError = e;
156
+ }
157
+ }
158
+ break;
159
+ case 'arm64':
160
+ isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl');
161
+ if (isMusl) {
162
+ localFileExisted = existsSync(join(__dirname, 'swc.linux-arm64-musl.node'));
163
+ try {
164
+ if (localFileExisted) {
165
+ nativeBinding = require('./swc.linux-arm64-musl.node');
166
+ }
167
+ else {
168
+ nativeBinding = require('@swc/core-linux-arm64-musl');
169
+ }
170
+ }
171
+ catch (e) {
172
+ loadError = e;
173
+ }
174
+ }
175
+ else {
176
+ localFileExisted = existsSync(join(__dirname, 'swc.linux-arm64-gnu.node'));
177
+ try {
178
+ if (localFileExisted) {
179
+ nativeBinding = require('./swc.linux-arm64-gnu.node');
180
+ }
181
+ else {
182
+ nativeBinding = require('@swc/core-linux-arm64-gnu');
183
+ }
184
+ }
185
+ catch (e) {
186
+ loadError = e;
187
+ }
188
+ }
189
+ break;
190
+ case 'arm':
191
+ localFileExisted = existsSync(join(__dirname, 'swc.linux-arm-gnueabihf.node'));
192
+ try {
193
+ if (localFileExisted) {
194
+ nativeBinding = require('./swc.linux-arm-gnueabihf.node');
195
+ }
196
+ else {
197
+ nativeBinding = require('@swc/core-linux-arm-gnueabihf');
198
+ }
199
+ }
200
+ catch (e) {
201
+ loadError = e;
202
+ }
203
+ break;
204
+ default:
205
+ throw new Error(`Unsupported architecture on Linux: ${arch}`);
206
+ }
207
+ break;
208
+ default:
209
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
210
+ }
211
+ if (!nativeBinding) {
212
+ if (loadError) {
213
+ throw loadError;
214
+ }
215
+ throw new Error(`Failed to load native binding`);
216
+ }
217
+ const { bundle, minify, minifySync, parse, parseSync, parseFileSync, parseFile, print, printSync, transform, transformSync, transformFile, transformFileSync, Compiler } = nativeBinding;
218
+ module.exports.bundle = bundle;
219
+ module.exports.minify = minify;
220
+ module.exports.minifySync = minifySync;
221
+ module.exports.parse = parse;
222
+ module.exports.parseSync = parseSync;
223
+ module.exports.parseFileSync = parseFileSync;
224
+ module.exports.parseFile = parseFile;
225
+ module.exports.print = print;
226
+ module.exports.printSync = printSync;
227
+ module.exports.transform = transform;
228
+ module.exports.transformSync = transformSync;
229
+ module.exports.transformFile = transformFile;
230
+ module.exports.transformFileSync = transformFileSync;
231
+ module.exports.Compiler = Compiler;
package/index.js CHANGED
@@ -34,10 +34,9 @@ exports.DEFAULT_EXTENSIONS = exports.minifySync = exports.minify = exports.bundl
34
34
  const path_1 = require("path");
35
35
  __exportStar(require("./types"), exports);
36
36
  const spack_1 = require("./spack");
37
- const helper_1 = require("@node-rs/helper");
38
37
  // Allow overrides to the location of the .node binding file
39
38
  const bindingsOverride = process.env["SWC_BINARY_PATH"];
40
- const bindings = !!bindingsOverride ? require(path_1.resolve(bindingsOverride)) : helper_1.loadBinding(__dirname, "swc", "@swc/core");
39
+ const bindings = !!bindingsOverride ? require((0, path_1.resolve)(bindingsOverride)) : require('./binding');
41
40
  /**
42
41
  * Version of the swc binding.
43
42
  */
@@ -169,7 +168,7 @@ class Compiler {
169
168
  }
170
169
  bundle(options) {
171
170
  return __awaiter(this, void 0, void 0, function* () {
172
- const opts = yield spack_1.compileBundleOptions(options);
171
+ const opts = yield (0, spack_1.compileBundleOptions)(options);
173
172
  if (Array.isArray(opts)) {
174
173
  const all = yield Promise.all(opts.map((opt) => __awaiter(this, void 0, void 0, function* () {
175
174
  return this.bundle(opt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.121",
3
+ "version": "1.2.125",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
@@ -38,7 +38,8 @@
38
38
  "aarch64-apple-darwin",
39
39
  "aarch64-linux-android",
40
40
  "aarch64-unknown-linux-musl",
41
- "aarch64-pc-windows-msvc"
41
+ "aarch64-pc-windows-msvc",
42
+ "armv7-linux-androideabi"
42
43
  ]
43
44
  }
44
45
  },
@@ -50,18 +51,19 @@
50
51
  "@node-rs/helper": "^1.0.0"
51
52
  },
52
53
  "optionalDependencies": {
53
- "@swc/core-win32-x64-msvc": "^1.2.121",
54
- "@swc/core-darwin-x64": "^1.2.121",
55
- "@swc/core-linux-x64-gnu": "^1.2.121",
56
- "@swc/core-linux-x64-musl": "^1.2.121",
57
- "@swc/core-freebsd-x64": "^1.2.121",
58
- "@swc/core-win32-ia32-msvc": "^1.2.121",
59
- "@swc/core-linux-arm64-gnu": "^1.2.121",
60
- "@swc/core-linux-arm-gnueabihf": "^1.2.121",
61
- "@swc/core-darwin-arm64": "^1.2.121",
62
- "@swc/core-android-arm64": "^1.2.121",
63
- "@swc/core-linux-arm64-musl": "^1.2.121",
64
- "@swc/core-win32-arm64-msvc": "^1.2.121"
54
+ "@swc/core-win32-x64-msvc": "1.2.125",
55
+ "@swc/core-darwin-x64": "1.2.125",
56
+ "@swc/core-linux-x64-gnu": "1.2.125",
57
+ "@swc/core-linux-x64-musl": "1.2.125",
58
+ "@swc/core-freebsd-x64": "1.2.125",
59
+ "@swc/core-win32-ia32-msvc": "1.2.125",
60
+ "@swc/core-linux-arm64-gnu": "1.2.125",
61
+ "@swc/core-linux-arm-gnueabihf": "1.2.125",
62
+ "@swc/core-darwin-arm64": "1.2.125",
63
+ "@swc/core-android-arm64": "1.2.125",
64
+ "@swc/core-linux-arm64-musl": "1.2.125",
65
+ "@swc/core-win32-arm64-msvc": "1.2.125",
66
+ "@swc/core-android-arm-eabi": "1.2.125"
65
67
  },
66
68
  "types": "./index.d.ts",
67
69
  "scripts": {
@@ -69,13 +71,14 @@
69
71
  "prepare": "husky install && git config feature.manyFiles true",
70
72
  "artifacts": "napi artifacts --dist scripts/npm",
71
73
  "prepublishOnly": "tsc -d && napi prepublish -p scripts/npm --tagstyle npm",
72
- "build": "tsc -d && napi build --platform --release --cargo-name node --cargo-flags=\"-p node\"",
73
- "build:dev": "tsc -d && napi build --platform --cargo-name node --cargo-flags=\"-p node\"",
74
+ "build": "tsc -d && napi build --platform --cargo-name node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts -p node --release",
75
+ "build:dev": "tsc -d && napi build --platform --cargo-name node --js ./node-swc/src/binding.js --dts ./node-swc/src/binding.d.ts -p node",
74
76
  "build:ts": "tsc -d",
75
77
  "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest node-swc/__tests__",
76
78
  "version": "napi version -p scripts/npm"
77
79
  },
78
80
  "devDependencies": {
81
+ "@babel/compat-data": "^7.16.4",
79
82
  "@babel/core": "^7.13.16",
80
83
  "@babel/plugin-proposal-class-properties": "^7.13.0",
81
84
  "@babel/plugin-proposal-decorators": "^7.13.15",
@@ -84,7 +87,7 @@
84
87
  "@babel/preset-react": "^7.13.13",
85
88
  "@babel/preset-typescript": "^7.13.0",
86
89
  "@babel/types": "^7.14.0",
87
- "@napi-rs/cli": "^1.0.4",
90
+ "@napi-rs/cli": "^2.0.0",
88
91
  "@swc/helpers": "^0.2.10",
89
92
  "@types/jest": "^26.0.23",
90
93
  "@types/node": "^14.14.41",
@@ -111,7 +114,7 @@
111
114
  "source-map-support": "^0.5.19",
112
115
  "sourcemap-validator": "^2.1.0",
113
116
  "terser": "^5.7.1",
114
- "typescript": "^4.2.0-beta"
117
+ "typescript": "^4.5.2"
115
118
  },
116
119
  "funding": {
117
120
  "type": "opencollective",
package/types.d.ts CHANGED
@@ -325,8 +325,9 @@ export interface JscConfig {
325
325
  * Keep class names.
326
326
  */
327
327
  keepClassNames?: boolean;
328
- experimetal?: {
328
+ experimental?: {
329
329
  optimizeHygiene?: boolean;
330
+ keepImportAssertions?: boolean;
330
331
  };
331
332
  baseUrl?: string;
332
333
  paths?: {
package/.mocha.setup.js DELETED
@@ -1,3 +0,0 @@
1
- // Inject jest's assertion (expect) into global scope for the Mocha
2
- // to use same assertion between node-swc & rest.
3
- global.expect = require('expect');
package/.mocharc.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * https://github.com/swc-project/swc/pull/3009
3
- *
4
- * There are 2 test runners in this repo:
5
- * - jest is being used for unit testing node-swc packages with javascript test cases
6
- * - mocha is being used for cargo's test requires js runtime to validate its transform.
7
- *
8
- * This config is for the mocha test runner invoked by cargo to resolve its global setup file.
9
- */
10
- module.exports = {
11
- require: require.resolve('./.mocha.setup.js')
12
- };
package/cliff.toml DELETED
@@ -1,71 +0,0 @@
1
- # configuration file for git-cliff (0.1.0)
2
-
3
- [changelog]
4
- # changelog header
5
- header = """
6
- # Changelog
7
- """
8
- # template for the changelog body
9
- # https://tera.netlify.app/docs/#introduction
10
- body = """
11
- {% if version %}\
12
- ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
13
- {% else %}\
14
- ## [unreleased]
15
- {% endif %}\
16
- {% for group, commits in commits | group_by(attribute="group") %}
17
- ### {{ group | upper_first }}
18
- {% for commit in commits
19
- | filter(attribute="scope")
20
- | sort(attribute="scope") %}
21
- \n
22
- - **({{commit.scope}})** {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/swc-project/swc/commit/{{ commit.id }}))
23
- {%- if commit.breaking %}
24
- {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
25
- {%- endif -%}
26
- {%- endfor -%}
27
- \n\n
28
- {%- for commit in commits %}
29
- {%- if commit.scope -%}
30
- {% else -%}
31
- \n
32
- - **general**: {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/swc-project/swc/commit/{{ commit.id }}))
33
- {%- if commit.breaking %}
34
- {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}}
35
- {%- endif -%}
36
- {% endif -%}
37
- {% endfor -%}
38
- {% raw %}\n{% endraw %}\
39
- {% endfor %}\n
40
- """
41
- # remove the leading and trailing whitespaces from the template
42
- trim = true
43
- # changelog footer
44
- footer = """
45
- <!-- generated by git-cliff -->
46
- """
47
-
48
- [git]
49
- # allow only conventional commits
50
- # https://www.conventionalcommits.org
51
- conventional_commits = true
52
- filter_unconventional = false
53
- # regex for parsing and grouping commits
54
- commit_parsers = [
55
- {message = "^feat", group = "Features"},
56
- {message = "^fix", group = "Bug Fixes"},
57
- {message = "^doc", group = "Documentation"},
58
- {message = "^perf", group = "Performance"},
59
- {message = "^refactor", group = "Refactor"},
60
- {message = "^style", group = "Styling"},
61
- {message = "^test", group = "Testing"},
62
- {message = "^chore: Publish", skip = true},
63
- {message = "^chore", group = "Miscellaneous Tasks"},
64
- {body = ".*security", group = "Security"},
65
- ]
66
- # filter out the commits that are not matched by commit parsers
67
- filter_commits = false
68
- # glob pattern for matching git tags
69
- tag_pattern = "v[0-9]*"
70
- # regex for skipping tags
71
- skip_tags = "v0.1.0-beta.1"
package/jest.config.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- testMatch: ["**/__tests__/**/*.[jt]s?(x)", "**/__tests__/**/*.m[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
3
- transform: {
4
- },
5
- // transform: {
6
- // "^.+\\.jsx?$": "babel-jest",
7
- // "^.+\\.mjs$": "babel-jest",
8
- // },
9
- testPathIgnorePatterns: ["<rootDir>/build/", "<rootDir>/node_modules/"],
10
- moduleFileExtensions: ["js", "jsx", "mjs"]
11
- }