@swc/core 1.2.119 → 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 +3536 -0
- package/{LICENSE-APACHE → LICENSE} +0 -0
- package/binding.d.ts +14 -0
- package/binding.js +231 -0
- package/index.js +2 -3
- package/package.json +25 -18
- package/types.d.ts +1 -1
- package/LICENSE-MIT +0 -25
- package/jest.config.js +0 -11
|
File without changes
|
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)) :
|
|
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.
|
|
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,31 +51,34 @@
|
|
|
50
51
|
"@node-rs/helper": "^1.0.0"
|
|
51
52
|
},
|
|
52
53
|
"optionalDependencies": {
|
|
53
|
-
"@swc/core-win32-x64-msvc": "
|
|
54
|
-
"@swc/core-darwin-x64": "
|
|
55
|
-
"@swc/core-linux-x64-gnu": "
|
|
56
|
-
"@swc/core-linux-x64-musl": "
|
|
57
|
-
"@swc/core-freebsd-x64": "
|
|
58
|
-
"@swc/core-win32-ia32-msvc": "
|
|
59
|
-
"@swc/core-linux-arm64-gnu": "
|
|
60
|
-
"@swc/core-linux-arm-gnueabihf": "
|
|
61
|
-
"@swc/core-darwin-arm64": "
|
|
62
|
-
"@swc/core-android-arm64": "
|
|
63
|
-
"@swc/core-linux-arm64-musl": "
|
|
64
|
-
"@swc/core-win32-arm64-msvc": "
|
|
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": {
|
|
70
|
+
"changelog": "git cliff --output CHANGELOG.md",
|
|
68
71
|
"prepare": "husky install && git config feature.manyFiles true",
|
|
69
72
|
"artifacts": "napi artifacts --dist scripts/npm",
|
|
70
73
|
"prepublishOnly": "tsc -d && napi prepublish -p scripts/npm --tagstyle npm",
|
|
71
|
-
"build": "tsc -d && napi build --platform --
|
|
72
|
-
"build:dev": "tsc -d && napi build --platform --cargo-name 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",
|
|
73
76
|
"build:ts": "tsc -d",
|
|
74
77
|
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest node-swc/__tests__",
|
|
75
78
|
"version": "napi version -p scripts/npm"
|
|
76
79
|
},
|
|
77
80
|
"devDependencies": {
|
|
81
|
+
"@babel/compat-data": "^7.16.4",
|
|
78
82
|
"@babel/core": "^7.13.16",
|
|
79
83
|
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
80
84
|
"@babel/plugin-proposal-decorators": "^7.13.15",
|
|
@@ -83,7 +87,7 @@
|
|
|
83
87
|
"@babel/preset-react": "^7.13.13",
|
|
84
88
|
"@babel/preset-typescript": "^7.13.0",
|
|
85
89
|
"@babel/types": "^7.14.0",
|
|
86
|
-
"@napi-rs/cli": "^
|
|
90
|
+
"@napi-rs/cli": "^2.0.0",
|
|
87
91
|
"@swc/helpers": "^0.2.10",
|
|
88
92
|
"@types/jest": "^26.0.23",
|
|
89
93
|
"@types/node": "^14.14.41",
|
|
@@ -96,18 +100,21 @@
|
|
|
96
100
|
"core-js": "^2.6.11",
|
|
97
101
|
"cross-env": "^7.0.3",
|
|
98
102
|
"cspell": "^5.12.3",
|
|
103
|
+
"expect": "^27.4.2",
|
|
99
104
|
"husky": "^7.0.2",
|
|
100
105
|
"jest": "^27.0.1",
|
|
101
106
|
"lodash": "^4.17.21",
|
|
107
|
+
"mocha": "^9.1.3",
|
|
102
108
|
"progress": "^2.0.3",
|
|
103
109
|
"prop-types": "^15.7.2",
|
|
104
110
|
"react": "^17.0.2",
|
|
111
|
+
"reflect-metadata": "^0.1.13",
|
|
105
112
|
"regenerator-runtime": "^0.13.9",
|
|
106
113
|
"source-map": "^0.7.3",
|
|
107
114
|
"source-map-support": "^0.5.19",
|
|
108
115
|
"sourcemap-validator": "^2.1.0",
|
|
109
116
|
"terser": "^5.7.1",
|
|
110
|
-
"typescript": "^4.2
|
|
117
|
+
"typescript": "^4.5.2"
|
|
111
118
|
},
|
|
112
119
|
"funding": {
|
|
113
120
|
"type": "opencollective",
|
package/types.d.ts
CHANGED
package/LICENSE-MIT
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2017 The swc Project Developers
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any
|
|
4
|
-
person obtaining a copy of this software and associated
|
|
5
|
-
documentation files (the "Software"), to deal in the
|
|
6
|
-
Software without restriction, including without
|
|
7
|
-
limitation the rights to use, copy, modify, merge,
|
|
8
|
-
publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software
|
|
10
|
-
is furnished to do so, subject to the following
|
|
11
|
-
conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice
|
|
14
|
-
shall be included in all copies or substantial portions
|
|
15
|
-
of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
18
|
-
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
20
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
21
|
-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
24
|
-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
25
|
-
DEALINGS IN THE SOFTWARE.
|
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
|
-
}
|