@swc/core 1.2.122 → 1.2.123

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,49 @@
5
5
 
6
6
 
7
7
 
8
+ - **(es/compat)** Fix handling of class methods with a big int as a key (#3118) ([a1cb4a4](https://github.com/swc-project/swc/commit/a1cb4a4aa57bd54e6718f293a65361952f4ef11d))
9
+
10
+ ## [1.2.123] - 2021-12-25
11
+
12
+ ### Bug Fixes
13
+
14
+
15
+
16
+ - **(es/ast)** Fix `Ident::verify_symbol` (#3108) ([e5971f7](https://github.com/swc-project/swc/commit/e5971f77d5861038f7dcd905a9aca72c84b1a035))
17
+
18
+
19
+ - **(es/compat)** Fix `classes` pass (#3107) ([d923f89](https://github.com/swc-project/swc/commit/d923f89db19b4343034569595dc3bbbce29b86b0))
20
+
21
+
22
+ - **(es/compat)** Fix `destructuring` (#3104) ([9f5a8f7](https://github.com/swc-project/swc/commit/9f5a8f728ade23640430d82f9f4bbcb341e30e2a))
23
+
24
+
25
+ - **(es/helpers)** Fix decorators (#3105) ([f66c2cd](https://github.com/swc-project/swc/commit/f66c2cd375f78711fdf6a058003010bce8999aed))
26
+
27
+ ### Features
28
+
29
+
30
+
31
+ - **(es/bundler)** Add an option to disable tree-shaking (#3102) ([d98a593](https://github.com/swc-project/swc/commit/d98a59339a0fa2a14f2bcb92c6deeb810ec339be))
32
+
33
+
34
+ - **(es/diff)** Initialize a diff tool for ecmascript (#3101) ([ff0b55b](https://github.com/swc-project/swc/commit/ff0b55b7782cfa9c428d88d366520b53307bca42))
35
+
36
+
37
+ - **(node)** Upgrade `napi` to v2 (#2958) ([206da12](https://github.com/swc-project/swc/commit/206da128a1f1ecd43c7580a7ad5f58ebc363c812))
38
+
39
+ ### Miscellaneous Tasks
40
+
41
+
42
+
43
+ - **(ci)** Fix script for publishing ([f51314c](https://github.com/swc-project/swc/commit/f51314cd51990b2caf8b18a7d8a647236a0ec893))
44
+
45
+ ## [1.2.122] - 2021-12-22
46
+
47
+ ### Bug Fixes
48
+
49
+
50
+
8
51
  - **(es/compat)** Fix handling of union of the legacy decorator pass (#3057) ([938e544](https://github.com/swc-project/swc/commit/938e544ac55503e91811cfc4e0c333deb2ccc7ed))
9
52
 
10
53
 
@@ -50,9 +93,15 @@
50
93
 
51
94
 
52
95
 
96
+ - **(node)** Publish v1.2.122 ([f4cc323](https://github.com/swc-project/swc/commit/f4cc323e08c73f10bd4cc323a81dd5d3778395df))
97
+
98
+
53
99
  - **(repo)** Make `git` faster (#3075) ([8afb5af](https://github.com/swc-project/swc/commit/8afb5af517e87b85ae1bdd8156509850c53fa276))
54
100
 
55
101
 
102
+ - **(repo)** Add section for the actual behavior to the issue template (#3100) ([0472199](https://github.com/swc-project/swc/commit/047219932fd18e7e78131f44ab5fb3be0518dc04))
103
+
104
+
56
105
  - **(scripts)** Use `cargo profile instruments` instead of `cargo instruments` (#3086) ([d482d61](https://github.com/swc-project/swc/commit/d482d61b9fd9997367d0dd27e3b90c662064ae3d))
57
106
 
58
107
  ### Performance
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.122",
3
+ "version": "1.2.123",
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.122",
54
- "@swc/core-darwin-x64": "^1.2.122",
55
- "@swc/core-linux-x64-gnu": "^1.2.122",
56
- "@swc/core-linux-x64-musl": "^1.2.122",
57
- "@swc/core-freebsd-x64": "^1.2.122",
58
- "@swc/core-win32-ia32-msvc": "^1.2.122",
59
- "@swc/core-linux-arm64-gnu": "^1.2.122",
60
- "@swc/core-linux-arm-gnueabihf": "^1.2.122",
61
- "@swc/core-darwin-arm64": "^1.2.122",
62
- "@swc/core-android-arm64": "^1.2.122",
63
- "@swc/core-linux-arm64-musl": "^1.2.122",
64
- "@swc/core-win32-arm64-msvc": "^1.2.122"
54
+ "@swc/core-win32-x64-msvc": "1.2.123",
55
+ "@swc/core-darwin-x64": "1.2.123",
56
+ "@swc/core-linux-x64-gnu": "1.2.123",
57
+ "@swc/core-linux-x64-musl": "1.2.123",
58
+ "@swc/core-freebsd-x64": "1.2.123",
59
+ "@swc/core-win32-ia32-msvc": "1.2.123",
60
+ "@swc/core-linux-arm64-gnu": "1.2.123",
61
+ "@swc/core-linux-arm-gnueabihf": "1.2.123",
62
+ "@swc/core-darwin-arm64": "1.2.123",
63
+ "@swc/core-android-arm64": "1.2.123",
64
+ "@swc/core-linux-arm64-musl": "1.2.123",
65
+ "@swc/core-win32-arm64-msvc": "1.2.123",
66
+ "@swc/core-android-arm-eabi": "1.2.123"
65
67
  },
66
68
  "types": "./index.d.ts",
67
69
  "scripts": {
@@ -69,8 +71,8 @@
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"
@@ -85,7 +87,7 @@
85
87
  "@babel/preset-react": "^7.13.13",
86
88
  "@babel/preset-typescript": "^7.13.0",
87
89
  "@babel/types": "^7.14.0",
88
- "@napi-rs/cli": "^1.0.4",
90
+ "@napi-rs/cli": "^2.0.0",
89
91
  "@swc/helpers": "^0.2.10",
90
92
  "@types/jest": "^26.0.23",
91
93
  "@types/node": "^14.14.41",
@@ -112,7 +114,7 @@
112
114
  "source-map-support": "^0.5.19",
113
115
  "sourcemap-validator": "^2.1.0",
114
116
  "terser": "^5.7.1",
115
- "typescript": "^4.2.0-beta"
117
+ "typescript": "^4.5.2"
116
118
  },
117
119
  "funding": {
118
120
  "type": "opencollective",