@swc/core 1.2.128 → 1.2.133

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,221 @@
5
5
 
6
6
 
7
7
 
8
+ - **(css)** Fix parsing of media queries (#3318) ([0723ee2](https://github.com/swc-project/swc/commit/0723ee282861a1e648490989c122d5f4e683dc35))
9
+
10
+
11
+ - **(es/minifier)** Don't inline functions used as arguments (#3320) ([57204e3](https://github.com/swc-project/swc/commit/57204e39cd24ecdb190a671bd3e163ff0c2ab983))
12
+
13
+ ### Documentation
14
+
15
+
16
+
17
+ - **(repo)** Update contributing docs (#3298) ([5af79f6](https://github.com/swc-project/swc/commit/5af79f634b7431e886b254992e7fbdbe044d1e9d))
18
+
19
+ ### Miscellaneous Tasks
20
+
21
+
22
+
23
+ - **(rustc)** Downgrade rustc ([041bf00](https://github.com/swc-project/swc/commit/041bf003627e55cdef2839a31cbb3149e161eb6e))
24
+
25
+ ### Build
26
+
27
+
28
+
29
+ - **(node-swc)** Fix GLIBC < 2.18 compatible issues and android arm binary loading issue (#3314) ([9608605](https://github.com/swc-project/swc/commit/9608605772351a2406870e19ed8738adf2147374))
30
+
31
+ ## [1.2.131] - 2022-01-19
32
+
33
+ ### Bug Fixes
34
+
35
+
36
+
37
+ - **(common)** Use `siphasher` directly and upgrade transitive dependencies to avoid UB (#3299) ([641265b](https://github.com/swc-project/swc/commit/641265b147da9478f5d205ddc0c7c16ed94b8676))
38
+
39
+
40
+ - **(es/compat)** Apply `static_blocks` before `class_properties` (#3292) ([89235b8](https://github.com/swc-project/swc/commit/89235b8294dedb4dd50c85e2a3b3ce41bddac85e))
41
+
42
+
43
+ - **(es/minifier)** Fix analysis of unary expressions (#3286) ([b55ae4b](https://github.com/swc-project/swc/commit/b55ae4b312b5677efeb9f3e9697dc2bcff81e322))
44
+
45
+
46
+ - **(es/minifier)** Inline into interpolations in tagged template literals (#3287) ([fa5c063](https://github.com/swc-project/swc/commit/fa5c063144246ce634305399787e08498765eb8f))
47
+
48
+
49
+ - **(es/minifier)** Remove more side-effect-free expressions. (#3301) ([18a11d7](https://github.com/swc-project/swc/commit/18a11d7c8f6582df2a486ef8fdafca85d323bee7))
50
+
51
+
52
+ - **(es/minifier)** Don't emit invalid code (#3302) ([8e796cd](https://github.com/swc-project/swc/commit/8e796cdc0ac59d7cab7e9e845afc2f98ee89c3ae))
53
+
54
+
55
+ - **(es/minifier)** Fix logic for checking `arguments` (#3313) ([1aa494b](https://github.com/swc-project/swc/commit/1aa494b1c0d26151c56500dd2bab283b7a4222c5))
56
+
57
+
58
+ - **(es/minifier)** Prevent infinite loop due to negation (#3310) ([b4d21bf](https://github.com/swc-project/swc/commit/b4d21bf0778d973d651b6f1825c4eb27dc150ea2))
59
+
60
+
61
+ - **(es/resolver)** Ignore names of jsx attributes (#3289) ([9a89895](https://github.com/swc-project/swc/commit/9a898951bc14e96af926e8a47a87d9220eaf4826))
62
+
63
+ ### Documentation
64
+
65
+
66
+
67
+ - **(swc)** Document `typescript::strip` (#3305) ([18cd98e](https://github.com/swc-project/swc/commit/18cd98e54cdd3c651fc12815aa59a6640a1c0dcb))
68
+
69
+ ### Features
70
+
71
+
72
+
73
+ - **(es/compat)** Use remove useless source map entries generated by `classes` (#3242) ([2352920](https://github.com/swc-project/swc/commit/2352920889c217be41dd5d18c2af6088e1cd0473))
74
+
75
+
76
+ - **(es/minifier)** Drop more expressions from parallel optimizer (#3303) ([210ecf8](https://github.com/swc-project/swc/commit/210ecf83bb2d23d72f903243c173a249cf4ffccb))
77
+
78
+
79
+ - **(plugin)** Add `PluginError` (#3300) ([c6ffdc8](https://github.com/swc-project/swc/commit/c6ffdc87172e504adff5757ebbb6ec2014136cf1))
80
+
81
+ ### Refactor
82
+
83
+
84
+
85
+ - **(es)** Add `visit_obj_and_computed` macro (#3304) ([9e636c7](https://github.com/swc-project/swc/commit/9e636c7e582ff898ca2e374f0b3938dda98a5b67))
86
+
87
+
88
+ - **(es/minifier)** Fix clippy warnings (#3312) ([2891220](https://github.com/swc-project/swc/commit/289122009bff1e8d57178ca2cc1706f52335d1c5))
89
+
90
+ ### Testing
91
+
92
+
93
+
94
+ - **(plugin/runner)** Pin dependencies for the integration test (#3306) ([7ba8a83](https://github.com/swc-project/swc/commit/7ba8a838819ae40f54801808a41af3d5334421b6))
95
+
96
+ ## [1.2.130] - 2022-01-17
97
+
98
+ ### Bug Fixes
99
+
100
+
101
+
102
+ - **(css/lexer)** Resolve a `TODO` (#3260) ([ade8ab8](https://github.com/swc-project/swc/commit/ade8ab8c35b9d1c61d740f42672fb4d27977346d))
103
+
104
+
105
+ - **(es/ast)** Update `EsVersion::latest()` (#3261) ([6997851](https://github.com/swc-project/swc/commit/69978518c9f6be3797f401dcaf9a429de88e8ce1))
106
+
107
+
108
+ - **(es/minifier)** Preserve side effects in correct position (#3263) ([efd8671](https://github.com/swc-project/swc/commit/efd86715c9827197278914df5dbc9f4fab1a35d9))
109
+
110
+
111
+ - **(es/parser)** Throw an error when function body has use strict and paramaters is not simple (#3278) ([6406b49](https://github.com/swc-project/swc/commit/6406b49df259eb10424ecbcc7fbbc9e4acdd37db))
112
+
113
+
114
+ - **(es/react)** Fix `createElement` (#3277) ([88a258a](https://github.com/swc-project/swc/commit/88a258a5fb91a58feb571096c4a73d6779b3128d))
115
+
116
+
117
+ - **(es/resolver)** Treat a switch statement as a block scope (#3275) ([f4b3cb7](https://github.com/swc-project/swc/commit/f4b3cb714aac1f936523f4d95467b67e554e583d))
118
+
119
+
120
+ - **(es/transforms)** Fix `this` in async arrow class properties (#3252) ([7c19e26](https://github.com/swc-project/swc/commit/7c19e26d0f41002a35c1695c259172916e578eab))
121
+
122
+
123
+ - **(es/transforms)** Remove unsafe `new String("...")` optimization (#3284) ([162c1fe](https://github.com/swc-project/swc/commit/162c1fe047631c35f8b8105c1a40ad6728e6edff))
124
+
125
+
126
+ - **(es/transforms)** Handle template literals within `jsonify` pass (#3282) ([b76d1da](https://github.com/swc-project/swc/commit/b76d1da699ab0475d349a0c9d5b06ffdd7a6b48f))
127
+
128
+
129
+ - **(swc)** Remove `wrong-target` (#3251) ([0843f74](https://github.com/swc-project/swc/commit/0843f742c5db3e0a8dc2fc2767b96fe0fad76bd1))
130
+
131
+ ### Documentation
132
+
133
+
134
+
135
+ - **(adr)** Configure adr and add `00001-plugin` (#3249) ([8652b2d](https://github.com/swc-project/swc/commit/8652b2df99c37527fcd973bd8f0cd3c54bfa9485))
136
+
137
+ ### Features
138
+
139
+
140
+
141
+ - **(css)** Support `@layer` at-rule (#3258) ([c195335](https://github.com/swc-project/swc/commit/c1953350121a0703f6b71474e348bc9408de085c))
142
+
143
+
144
+ - **(es/ast)** Improve AST api for plugin authors (#3281) ([9dd0647](https://github.com/swc-project/swc/commit/9dd0647e3ae6c00a4fcea3bdb82c269ebb1e61ca))
145
+
146
+
147
+ - **(es/compat)** Use `var` for `_len` and `args` in rest parameters (#3267) ([d3cc488](https://github.com/swc-project/swc/commit/d3cc488ac1f41bc752903a3e15a123a909a2b765))
148
+
149
+
150
+ - **(plugin/runner)** Free allocated memory on errors (#3270) ([66d1a92](https://github.com/swc-project/swc/commit/66d1a92635c4e04041af1c106dbda8b4d692ba8a))
151
+
152
+
153
+ - **(plugin/runnner)** Support `wasm32-wasi` targets (#3271) ([a4c4974](https://github.com/swc-project/swc/commit/a4c497464da5691fee1aff1246d3d36d1b3579af))
154
+
155
+ ### Miscellaneous Tasks
156
+
157
+
158
+
159
+ - **(ci)** Configure `clippy` (#3250) ([978de59](https://github.com/swc-project/swc/commit/978de5943e60a09b5596b20b9c96596d392393c9))
160
+
161
+ ### Refactor
162
+
163
+
164
+
165
+ - **(*)** Fix some clippy warnings (#3257) ([15b604b](https://github.com/swc-project/swc/commit/15b604b6d6f55353a0df13293333367851962f6c))
166
+
167
+
168
+ - **(*)** Cleanup (#3274) ([357a350](https://github.com/swc-project/swc/commit/357a35039082c79ba698ce64a69e9022d790632d))
169
+
170
+
171
+ - **(es)** More fix for clippy (#3280) ([e8670b3](https://github.com/swc-project/swc/commit/e8670b3383b4baf02a94702bc92a6dcdcd647755))
172
+
173
+
174
+ - **(es/transforms)** Cleanup (#3273) ([2690742](https://github.com/swc-project/swc/commit/2690742db0bf59246d0d9b96dfc5f6248fcbb3a0))
175
+
176
+
177
+ - **(es/utils)** Merge the super field visitor with `FnEnvHoister` (#3279) ([90a62bb](https://github.com/swc-project/swc/commit/90a62bb21528035eef02fe7fa99de6f6e014d0ca))
178
+
179
+ ### Build
180
+
181
+
182
+
183
+ - **(node)** Fix glibc issue on linux gnu arm (#3255) ([2144271](https://github.com/swc-project/swc/commit/214427157ddf155da14b2bede3b315d3f6ce1e77))
184
+
185
+ ## [1.2.129] - 2022-01-13
186
+
187
+ ### Bug Fixes
188
+
189
+
190
+
191
+ - **(es/compat)** Transform `&&=` operator (#3225) ([2e5150d](https://github.com/swc-project/swc/commit/2e5150d2b714ba86bd228506eb0f008d9f5859e1))
192
+
193
+
194
+ - **(es/minifier)** Fix handling of inlined call to a hoisted function (#3223) ([78720c4](https://github.com/swc-project/swc/commit/78720c4c91530165b24585dab635f13eea9997a3))
195
+
196
+
197
+ - **(es/minifier)** Fix optimization of assignment expressions (#3231) ([12dd0a6](https://github.com/swc-project/swc/commit/12dd0a6c1fb6eeaf603f0f1a6da3a4231c8c47f6))
198
+
199
+
200
+ - **(es/minifier)** Fix bugs (#3238) ([74fd353](https://github.com/swc-project/swc/commit/74fd3530535813023b77739dd8f37a682269be67))
201
+
202
+
203
+ - **(es/parser)** Fix span of `ComputedPropName` (#3234) ([105cbc2](https://github.com/swc-project/swc/commit/105cbc2017e20a7c6a5d7dfdd7a9a4c396032be9))
204
+
205
+
206
+ - **(es/typescript)** Remove rogue `println` (#3244) ([282232c](https://github.com/swc-project/swc/commit/282232c9958309e70a18799449802ef5d7e88123))
207
+
208
+ ### Features
209
+
210
+
211
+
212
+ - **(plugin)** Don't serialize/deserialize needlessly (#3227) ([a2f2b5a](https://github.com/swc-project/swc/commit/a2f2b5ac8924ce635fc9547057da287864fe188a))
213
+
214
+
215
+ - **(plugin/macro)** Add safe API for plugins based on a proc-macro (#3240) ([432d5d3](https://github.com/swc-project/swc/commit/432d5d3fb7d870b08f8c16e4147c3f5421693d2b))
216
+
217
+ ## [1.2.128] - 2022-01-11
218
+
219
+ ### Bug Fixes
220
+
221
+
222
+
8
223
  - **(es/helpers)** Don't transpile `_typeof` helper (#3208) ([54353a6](https://github.com/swc-project/swc/commit/54353a6fb5ab53ed4762161ecdda1a3ec0d77c62))
9
224
 
10
225
 
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/clippy.toml ADDED
@@ -0,0 +1,2 @@
1
+ cognitive-complexity-threshold = 50
2
+ type-complexity-threshold = 25000
@@ -0,0 +1 @@
1
+ ### This adr attempts to describe 10,000ft view for the swc project itself. To be filled gradually.
@@ -0,0 +1,94 @@
1
+ # Support transform plugin in native rust binaries
2
+
3
+ - Status: accepted <!-- optional -->
4
+ - Deciders: @kdy1, @kwonoj <!-- optional -->
5
+ - Date: 2021-01-01 <!-- optional -->
6
+
7
+ Technical Story: [Issue](https://github.com/swc-project/swc/issues/2635) <!-- optional -->
8
+
9
+ ## Context and Problem Statement
10
+
11
+ SWC wants to support load, run plugins in the native binary for the custom transform behavior. SWC already have priliminary support to load plugins in its node.js JS bindings but it has known limitations.
12
+
13
+ ## Decision Drivers <!-- optional -->
14
+
15
+ - Allow to write a plugin binary can be loaded in the SWC's native binary without involving JS binding interop.
16
+ - Provide good, satisfactory performance while loading, running plugin's custom transformation.
17
+ - Keep abi stability as much, plugin binary should work across different versions of SWC host binary except intended breaking changes.
18
+ - Allow to write a plugin without caring much around the native platform targets binaries.
19
+
20
+ ## Considered Options
21
+
22
+ - [option 1] JS-based plugins, including babel plugins
23
+
24
+ - [option 2] Plugins based on `abi_stable` and native dynamic libraries
25
+
26
+ - [option 3] Wasm plugins based on `wasmtime`
27
+
28
+ - **[option 4]** Wasm plugins based on `wasmer`
29
+
30
+ ## Decision Outcome
31
+
32
+ Chosen option: **[option 4] Wasm plugins based on `wasmer`**
33
+
34
+ This decision is taken because
35
+
36
+ - It was relatively easy plugin author to generate single binary works across most of platforms SWC's host binary supports, without concern of cross-target compilations.
37
+ - It was relatively easy to achieve abi-stable between SWC host to plugin binaries.
38
+ - It doesn't require to have separate, specialized AST struct (named `plugin_ast`) to pass into ffi boundary of the plugin.
39
+ - Its serialization / deserialization performance is near identical or faster than `abi_stable` based ffi
40
+
41
+ ## Pros and Cons of the Options <!-- optional -->
42
+
43
+ ### [option 1] JS-based plugins, including babel plugins
44
+
45
+ SWC allow implementing plugins using javascript, and call it from worker threads as required.
46
+ This includes babel plugins, to make migration from babel more convenient.
47
+
48
+ - Good, because users can use rich ecosystem of babel.
49
+ - Good, because users are used to javascript.
50
+ - Good, because all platforms are supported.
51
+ - Bad, because passing data to and from javascript is very costly. ([SWC issue: Speed up `parse`](https://github.com/swc-project/swc/issues/2175))
52
+ - Bad, because js plugins require and block the main javascript thread.
53
+ - Bad, because the main javascript is singled threaded and be bottleneck.
54
+ - Bad, because `napi` (renamed to `node-api`) does not provide a way to get the return value of a function called from other thread than js thread. To workaround this, we should implement a complex request-response system based using lots of mutex.
55
+ - Bad, because node js worker thread is not an event loop. This means worker we cannot `yield` from a worker thread when we need to call js plugin. As a result, the when main js thread is busy because of js plugins, worker threads are also blocked without doing any task.
56
+
57
+ ### [option 2] Plugins based on `abi_stable` and native dynamic libraries
58
+
59
+ Plugins are written in rust, and built as native libraries for each platforms. SWC pass data to plugin using special form of AST, which has stable memory representation regardless of the version of `rustc`.
60
+
61
+ - Good, because it's fast, even on the first run.
62
+ - Good, because it does not require very complex request-response system.
63
+ - Good, because plugin authors can use all features of rust.
64
+ - Bad, because configuring CI for publishing plugins is very hard.
65
+ - Bad, because plugin developer cannot publish a plugin from a single machine.
66
+ - Bad, because loading of plugins is complex. Path for dynamic libraries are platform-dependant.
67
+ - Bad, because we have to handle quirks of each platforms.
68
+ - Bad, because `@swc/wasm` has no way to support plugins.
69
+
70
+ ### [option 3] Wasm plugins based on `wasmtime`
71
+
72
+ SWC embeds `wasmtime`, loads plugin built as web assembly.
73
+
74
+ - Good, because it's fast except the first run.
75
+ - Good, because configuring CI is simple.
76
+ - Good, because plugin authors can publish a plugin without CI, even with a single machine.
77
+ - Bad, because `@swc/wasm` has no way to support plugins.
78
+ - Bad, because first run is slow.
79
+ - Bad, because we have to manage the cache of compiled wasm files.
80
+ - Bad, because `wasmtime` does not support all platforms.
81
+
82
+ ### [option 4] Wasm plugins based on `wasmer`
83
+
84
+ SWC embeds web assembly runtime (https://wasmer.io/), loads plugin built as web assembly.
85
+
86
+ - Good, because it's fast except the first run.
87
+ - Good, because configuring CI is simple.
88
+ - Good, because plugin authors can publish a plugin without CI, even with a single machine.
89
+ - Good, because `@swc/wasm` can support plugins in future as `wasmer` officially supports using it within a wasm file.
90
+ - Bad, because first run is slow.
91
+ - Bad, because we have to manage the cache of compiled wasm files.
92
+ - Bad, because `wasmer` does not support all platforms.
93
+
94
+ ## Links
@@ -0,0 +1,13 @@
1
+ # Architectural Decision Records
2
+
3
+ This directory contains a series of [Architectural Decision Records](https://adr.github.io/)
4
+ or "ADRs" for the `swc` project. We're going to try to use it as a kind of collective
5
+ memory of the decisions we've made and the path we've taken to get the project to its current
6
+ point.
7
+
8
+ Note that these are *historical references* that do not supersede (but might enhance) the living
9
+ documentation of the project itself, which you can find inline in the source code.
10
+
11
+ Proposing a non-trivial change to the way `swc` works? You might like to start with an ADR
12
+ by copying `template.md` into a new file, filling out a first version of the proposal, and
13
+ posting it as a PR on the github repo for discussion.
@@ -0,0 +1,72 @@
1
+ # [short title of solved problem and solution]
2
+
3
+ * Status: [proposed | rejected | accepted | deprecated | … | superseded by [ADR-0005](0005-example.md)] <!-- optional -->
4
+ * Deciders: [list everyone involved in the decision] <!-- optional -->
5
+ * Date: [YYYY-MM-DD when the decision was last updated] <!-- optional -->
6
+
7
+ Technical Story: [description | ticket/issue URL] <!-- optional -->
8
+
9
+ ## Context and Problem Statement
10
+
11
+ [Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.]
12
+
13
+ ## Decision Drivers <!-- optional -->
14
+
15
+ * [driver 1, e.g., a force, facing concern, …]
16
+ * [driver 2, e.g., a force, facing concern, …]
17
+ * … <!-- numbers of drivers can vary -->
18
+
19
+ ## Considered Options
20
+
21
+ * [option 1]
22
+ * [option 2]
23
+ * [option 3]
24
+ * … <!-- numbers of options can vary -->
25
+
26
+ ## Decision Outcome
27
+
28
+ Chosen option: "[option 1]", because [justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force force | … | comes out best (see below)].
29
+
30
+ ### Positive Consequences <!-- optional -->
31
+
32
+ * [e.g., improvement of quality attribute satisfaction, follow-up decisions required, …]
33
+ * …
34
+
35
+ ### Negative Consequences <!-- optional -->
36
+
37
+ * [e.g., compromising quality attribute, follow-up decisions required, …]
38
+ * …
39
+
40
+ ## Pros and Cons of the Options <!-- optional -->
41
+
42
+ ### [option 1]
43
+
44
+ [example | description | pointer to more information | …] <!-- optional -->
45
+
46
+ * Good, because [argument a]
47
+ * Good, because [argument b]
48
+ * Bad, because [argument c]
49
+ * … <!-- numbers of pros and cons can vary -->
50
+
51
+ ### [option 2]
52
+
53
+ [example | description | pointer to more information | …] <!-- optional -->
54
+
55
+ * Good, because [argument a]
56
+ * Good, because [argument b]
57
+ * Bad, because [argument c]
58
+ * … <!-- numbers of pros and cons can vary -->
59
+
60
+ ### [option 3]
61
+
62
+ [example | description | pointer to more information | …] <!-- optional -->
63
+
64
+ * Good, because [argument a]
65
+ * Good, because [argument b]
66
+ * Bad, because [argument c]
67
+ * … <!-- numbers of pros and cons can vary -->
68
+
69
+ ## Links <!-- optional -->
70
+
71
+ * [Link type] [Link to ADR] <!-- example: Refined by [ADR-0005](0005-example.md) -->
72
+ * … <!-- numbers of links can vary -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.128",
3
+ "version": "1.2.133",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
@@ -47,23 +47,21 @@
47
47
  "registry": "https://registry.npmjs.org/",
48
48
  "access": "public"
49
49
  },
50
- "dependencies": {
51
- "@node-rs/helper": "^1.0.0"
52
- },
50
+ "dependencies": {},
53
51
  "optionalDependencies": {
54
- "@swc/core-win32-x64-msvc": "1.2.128",
55
- "@swc/core-darwin-x64": "1.2.128",
56
- "@swc/core-linux-x64-gnu": "1.2.128",
57
- "@swc/core-linux-x64-musl": "1.2.128",
58
- "@swc/core-freebsd-x64": "1.2.128",
59
- "@swc/core-win32-ia32-msvc": "1.2.128",
60
- "@swc/core-linux-arm64-gnu": "1.2.128",
61
- "@swc/core-linux-arm-gnueabihf": "1.2.128",
62
- "@swc/core-darwin-arm64": "1.2.128",
63
- "@swc/core-android-arm64": "1.2.128",
64
- "@swc/core-linux-arm64-musl": "1.2.128",
65
- "@swc/core-win32-arm64-msvc": "1.2.128",
66
- "@swc/core-android-arm-eabi": "1.2.128"
52
+ "@swc/core-win32-x64-msvc": "1.2.133",
53
+ "@swc/core-darwin-x64": "1.2.133",
54
+ "@swc/core-linux-x64-gnu": "1.2.133",
55
+ "@swc/core-linux-x64-musl": "1.2.133",
56
+ "@swc/core-freebsd-x64": "1.2.133",
57
+ "@swc/core-win32-ia32-msvc": "1.2.133",
58
+ "@swc/core-linux-arm64-gnu": "1.2.133",
59
+ "@swc/core-linux-arm-gnueabihf": "1.2.133",
60
+ "@swc/core-darwin-arm64": "1.2.133",
61
+ "@swc/core-android-arm64": "1.2.133",
62
+ "@swc/core-linux-arm64-musl": "1.2.133",
63
+ "@swc/core-win32-arm64-msvc": "1.2.133",
64
+ "@swc/core-android-arm-eabi": "1.2.133"
67
65
  },
68
66
  "types": "./index.d.ts",
69
67
  "scripts": {
@@ -87,7 +85,7 @@
87
85
  "@babel/preset-react": "^7.13.13",
88
86
  "@babel/preset-typescript": "^7.13.0",
89
87
  "@babel/types": "^7.14.0",
90
- "@napi-rs/cli": "^2.0.0",
88
+ "@napi-rs/cli": "^2.4.2",
91
89
  "@swc/helpers": "^0.2.10",
92
90
  "@types/jest": "^26.0.23",
93
91
  "@types/node": "^14.14.41",