@swc/core 1.5.11 → 1.5.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.5.11",
3
+ "version": "1.5.20",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./src/index.js",
@@ -86,29 +86,17 @@
86
86
  "package.json",
87
87
  "src/spack.d.ts",
88
88
  "src/types.js",
89
- "src/postinstall.js",
89
+ "postinstall.js",
90
90
  "bindings/binding_core_wasm/pkg/binding_core_wasm.d.ts"
91
91
  ],
92
92
  "dependencies": {
93
93
  "@swc/counter": "^0.1.3",
94
- "@swc/types": "workspace:^"
94
+ "@swc/types": "^0.1.7"
95
95
  },
96
96
  "devDependencies": {
97
97
  "@napi-rs/cli": "^3.0.0-alpha.43",
98
98
  "cross-env": "^7.0.3",
99
99
  "jest": "^29.7.0",
100
100
  "typescript": "^5.3.3"
101
- },
102
- "optionalDependencies": {
103
- "@swc/core-darwin-x64": "1.5.11",
104
- "@swc/core-win32-x64-msvc": "1.5.11",
105
- "@swc/core-linux-x64-gnu": "1.5.11",
106
- "@swc/core-linux-x64-musl": "1.5.11",
107
- "@swc/core-win32-ia32-msvc": "1.5.11",
108
- "@swc/core-linux-arm-gnueabihf": "1.5.11",
109
- "@swc/core-linux-arm64-gnu": "1.5.11",
110
- "@swc/core-darwin-arm64": "1.5.11",
111
- "@swc/core-linux-arm64-musl": "1.5.11",
112
- "@swc/core-win32-arm64-msvc": "1.5.11"
113
101
  }
114
102
  }
package/postinstall.js ADDED
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc
11
+ ? !m.__esModule
12
+ : desc.writable || desc.configurable)
13
+ ) {
14
+ desc = {
15
+ enumerable: true,
16
+ get: function () {
17
+ return m[k];
18
+ },
19
+ };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }
23
+ : function (o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ });
27
+ var __setModuleDefault =
28
+ (this && this.__setModuleDefault) ||
29
+ (Object.create
30
+ ? function (o, v) {
31
+ Object.defineProperty(o, "default", {
32
+ enumerable: true,
33
+ value: v,
34
+ });
35
+ }
36
+ : function (o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar =
40
+ (this && this.__importStar) ||
41
+ function (mod) {
42
+ if (mod && mod.__esModule) return mod;
43
+ var result = {};
44
+ if (mod != null)
45
+ for (var k in mod)
46
+ if (
47
+ k !== "default" &&
48
+ Object.prototype.hasOwnProperty.call(mod, k)
49
+ )
50
+ __createBinding(result, mod, k);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ var __awaiter =
55
+ (this && this.__awaiter) ||
56
+ function (thisArg, _arguments, P, generator) {
57
+ function adopt(value) {
58
+ return value instanceof P
59
+ ? value
60
+ : new P(function (resolve) {
61
+ resolve(value);
62
+ });
63
+ }
64
+ return new (P || (P = Promise))(function (resolve, reject) {
65
+ function fulfilled(value) {
66
+ try {
67
+ step(generator.next(value));
68
+ } catch (e) {
69
+ reject(e);
70
+ }
71
+ }
72
+ function rejected(value) {
73
+ try {
74
+ step(generator["throw"](value));
75
+ } catch (e) {
76
+ reject(e);
77
+ }
78
+ }
79
+ function step(result) {
80
+ result.done
81
+ ? resolve(result.value)
82
+ : adopt(result.value).then(fulfilled, rejected);
83
+ }
84
+ step(
85
+ (generator = generator.apply(thisArg, _arguments || [])).next()
86
+ );
87
+ });
88
+ };
89
+ Object.defineProperty(exports, "__esModule", { value: true });
90
+ /**
91
+ * A postinstall script runs after `@swc/core` is installed.
92
+ *
93
+ * It checks if corresponding optional dependencies for native binary is installed and can be loaded properly.
94
+ * If it fails, it'll internally try to install `@swc/wasm` as fallback.
95
+ */
96
+ const fs_1 = require("fs");
97
+ const assert = __importStar(require("assert"));
98
+ const path = __importStar(require("path"));
99
+ const child_process = __importStar(require("child_process"));
100
+ const fs = __importStar(require("fs"));
101
+ function removeRecursive(dir) {
102
+ for (const entry of fs.readdirSync(dir)) {
103
+ const entryPath = path.join(dir, entry);
104
+ let stats;
105
+ try {
106
+ stats = fs.lstatSync(entryPath);
107
+ } catch (_a) {
108
+ continue; // Guard against https://github.com/nodejs/node/issues/4760
109
+ }
110
+ if (stats.isDirectory()) removeRecursive(entryPath);
111
+ else fs.unlinkSync(entryPath);
112
+ }
113
+ fs.rmdirSync(dir);
114
+ }
115
+ /**
116
+ * Trying to validate @swc/core's native binary installation, then installs if it is not supported.
117
+ */
118
+ const validateBinary = () =>
119
+ __awaiter(void 0, void 0, void 0, function* () {
120
+ var _a;
121
+ try {
122
+ const { name } = require(path.resolve(
123
+ process.env.INIT_CWD,
124
+ "package.json"
125
+ ));
126
+ if (name === "@swc/core" || name === "@swc/workspace") {
127
+ return;
128
+ }
129
+ } catch (_) {
130
+ return;
131
+ }
132
+ // TODO: We do not take care of the case if user try to install with `--no-optional`.
133
+ // For now, it is considered as deliberate decision.
134
+ let binding;
135
+ try {
136
+ binding = require("./binding.js");
137
+ // Check if binding binary actually works.
138
+ // For the latest version, checks target triple. If it's old version doesn't have target triple, use parseSync instead.
139
+ const triple = binding.getTargetTriple
140
+ ? binding.getTargetTriple()
141
+ : binding.parseSync(
142
+ "console.log()",
143
+ Buffer.from(JSON.stringify({ syntax: "ecmascript" }))
144
+ );
145
+ assert.ok(
146
+ triple,
147
+ "Failed to read target triple from native binary."
148
+ );
149
+ } catch (error) {
150
+ // if error is unsupported architecture, ignore to display.
151
+ if (
152
+ !((_a = error.message) === null || _a === void 0
153
+ ? void 0
154
+ : _a.includes("Unsupported architecture"))
155
+ ) {
156
+ console.warn(error);
157
+ }
158
+ console.warn(
159
+ `@swc/core was not able to resolve native bindings installation. It'll try to use @swc/wasm as fallback instead.`
160
+ );
161
+ }
162
+ if (!!binding) {
163
+ return;
164
+ }
165
+ // User choose to override the binary installation. Skip remanining validation.
166
+ if (!!process.env["SWC_BINARY_PATH"]) {
167
+ console.warn(
168
+ `@swc/core could not resolve native bindings installation, but found manual override config SWC_BINARY_PATH specified. Skipping remaning validation.`
169
+ );
170
+ return;
171
+ }
172
+ // Check if top-level package.json installs @swc/wasm separately already
173
+ let wasmBinding;
174
+ try {
175
+ wasmBinding = require.resolve(`@swc/wasm`);
176
+ } catch (_) {}
177
+ if (!!wasmBinding && (0, fs_1.existsSync)(wasmBinding)) {
178
+ return;
179
+ }
180
+ const env = Object.assign(Object.assign({}, process.env), {
181
+ npm_config_global: undefined,
182
+ });
183
+ const { version } = require(path.join(
184
+ path.dirname(require.resolve("@swc/core")),
185
+ "package.json"
186
+ ));
187
+ // We want to place @swc/wasm next to the @swc/core as if normal installation was done,
188
+ // but can't directly set cwd to INIT_CWD as npm seems to acquire lock to the working dir.
189
+ // Instead, create a temporary inner and move it out.
190
+ const coreDir = path.dirname(require.resolve("@swc/core"));
191
+ const installDir = path.join(coreDir, "npm-install");
192
+ try {
193
+ fs.mkdirSync(installDir);
194
+ fs.writeFileSync(path.join(installDir, "package.json"), "{}");
195
+ // Instead of carrying over own dependencies to download & resolve package which increases installation sizes of `@swc/core`,
196
+ // assume & relies on system's npm installation.
197
+ child_process.execSync(
198
+ `npm install --no-save --loglevel=error --prefer-offline --no-audit --progress=false @swc/wasm@${version}`,
199
+ { cwd: installDir, stdio: "pipe", env }
200
+ );
201
+ const installedBinPath = path.join(
202
+ installDir,
203
+ "node_modules",
204
+ `@swc/wasm`
205
+ );
206
+ // INIT_CWD is injected via npm. If it doesn't exists, can't proceed.
207
+ fs.renameSync(
208
+ installedBinPath,
209
+ path.resolve(process.env.INIT_CWD, "node_modules", `@swc/wasm`)
210
+ );
211
+ } catch (error) {
212
+ console.error(error);
213
+ console.error(`Failed to install fallback @swc/wasm@${version}. @swc/core will not properly.
214
+ Please install @swc/wasm manually, or retry whole installation.
215
+ If there are unexpected errors, please report at https://github.com/swc-project/swc/issues`);
216
+ } finally {
217
+ try {
218
+ removeRecursive(installDir);
219
+ } catch (_) {
220
+ // Gracefully ignore any failures. This'll make few leftover files but it shouldn't block installation.
221
+ }
222
+ }
223
+ });
224
+ validateBinary().catch((error) => {
225
+ // for now just throw the error as-is.
226
+ throw error;
227
+ });
@@ -0,0 +1,3 @@
1
+ # `@swc/core-darwin-arm64`
2
+
3
+ This is the **aarch64-apple-darwin** binary for `@swc/core`
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@swc/core-darwin-arm64",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "darwin"
6
+ ],
7
+ "cpu": [
8
+ "arm64"
9
+ ],
10
+ "main": "swc.darwin-arm64.node",
11
+ "files": [
12
+ "swc.darwin-arm64.node",
13
+ "swc"
14
+ ],
15
+ "description": "Super-fast alternative for babel",
16
+ "keywords": [
17
+ "swc",
18
+ "swcpack",
19
+ "babel",
20
+ "typescript",
21
+ "rust",
22
+ "webpack",
23
+ "tsc"
24
+ ],
25
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
26
+ "homepage": "https://swc.rs",
27
+ "license": "Apache-2.0 AND MIT",
28
+ "engines": {
29
+ "node": ">=10"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/",
33
+ "access": "public"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/swc-project/swc.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/swc-project/swc/issues"
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-darwin-x64`
2
+
3
+ This is the **x86_64-apple-darwin** binary for `@swc/core`
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@swc/core-darwin-x64",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "darwin"
6
+ ],
7
+ "cpu": [
8
+ "x64"
9
+ ],
10
+ "main": "swc.darwin-x64.node",
11
+ "files": [
12
+ "swc.darwin-x64.node",
13
+ "swc"
14
+ ],
15
+ "description": "Super-fast alternative for babel",
16
+ "keywords": [
17
+ "swc",
18
+ "swcpack",
19
+ "babel",
20
+ "typescript",
21
+ "rust",
22
+ "webpack",
23
+ "tsc"
24
+ ],
25
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
26
+ "homepage": "https://swc.rs",
27
+ "license": "Apache-2.0 AND MIT",
28
+ "engines": {
29
+ "node": ">=10"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/",
33
+ "access": "public"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/swc-project/swc.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/swc-project/swc/issues"
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-linux-arm-gnueabihf`
2
+
3
+ This is the **armv7-unknown-linux-gnueabihf** binary for `@swc/core`
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@swc/core-linux-arm-gnueabihf",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "linux"
6
+ ],
7
+ "cpu": [
8
+ "arm"
9
+ ],
10
+ "main": "swc.linux-arm-gnueabihf.node",
11
+ "files": [
12
+ "swc.linux-arm-gnueabihf.node",
13
+ "swc"
14
+ ],
15
+ "description": "Super-fast alternative for babel",
16
+ "keywords": [
17
+ "swc",
18
+ "swcpack",
19
+ "babel",
20
+ "typescript",
21
+ "rust",
22
+ "webpack",
23
+ "tsc"
24
+ ],
25
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
26
+ "homepage": "https://swc.rs",
27
+ "license": "Apache-2.0",
28
+ "engines": {
29
+ "node": ">=10"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/",
33
+ "access": "public"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/swc-project/swc.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/swc-project/swc/issues"
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-linux-arm64-gnu`
2
+
3
+ This is the **aarch64-unknown-linux-gnu** binary for `@swc/core`
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@swc/core-linux-arm64-gnu",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "linux"
6
+ ],
7
+ "cpu": [
8
+ "arm64"
9
+ ],
10
+ "main": "swc.linux-arm64-gnu.node",
11
+ "files": [
12
+ "swc.linux-arm64-gnu.node",
13
+ "swc"
14
+ ],
15
+ "libc": [
16
+ "glibc"
17
+ ],
18
+ "description": "Super-fast alternative for babel",
19
+ "keywords": [
20
+ "swc",
21
+ "swcpack",
22
+ "babel",
23
+ "typescript",
24
+ "rust",
25
+ "webpack",
26
+ "tsc"
27
+ ],
28
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
29
+ "homepage": "https://swc.rs",
30
+ "license": "Apache-2.0 AND MIT",
31
+ "engines": {
32
+ "node": ">=10"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/",
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/swc-project/swc.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/swc-project/swc/issues"
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-linux-arm64-musl`
2
+
3
+ This is the **aarch64-unknown-linux-musl** binary for `@swc/core`
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@swc/core-linux-arm64-musl",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "linux"
6
+ ],
7
+ "cpu": [
8
+ "arm64"
9
+ ],
10
+ "main": "swc.linux-arm64-musl.node",
11
+ "files": [
12
+ "swc.linux-arm64-musl.node",
13
+ "swc"
14
+ ],
15
+ "libc": [
16
+ "musl"
17
+ ],
18
+ "description": "Super-fast alternative for babel",
19
+ "keywords": [
20
+ "swc",
21
+ "swcpack",
22
+ "babel",
23
+ "typescript",
24
+ "rust",
25
+ "webpack",
26
+ "tsc"
27
+ ],
28
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
29
+ "homepage": "https://swc.rs",
30
+ "license": "Apache-2.0 AND MIT",
31
+ "engines": {
32
+ "node": ">=10"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/",
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/swc-project/swc.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/swc-project/swc/issues"
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-linux-x64-gnu`
2
+
3
+ This is the **x86_64-unknown-linux-gnu** binary for `@swc/core`
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@swc/core-linux-x64-gnu",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "linux"
6
+ ],
7
+ "cpu": [
8
+ "x64"
9
+ ],
10
+ "main": "swc.linux-x64-gnu.node",
11
+ "files": [
12
+ "swc.linux-x64-gnu.node",
13
+ "swc"
14
+ ],
15
+ "libc": [
16
+ "glibc"
17
+ ],
18
+ "description": "Super-fast alternative for babel",
19
+ "keywords": [
20
+ "swc",
21
+ "swcpack",
22
+ "babel",
23
+ "typescript",
24
+ "rust",
25
+ "webpack",
26
+ "tsc"
27
+ ],
28
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
29
+ "homepage": "https://swc.rs",
30
+ "license": "Apache-2.0 AND MIT",
31
+ "engines": {
32
+ "node": ">=10"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/",
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/swc-project/swc.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/swc-project/swc/issues"
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-linux-x64-musl`
2
+
3
+ This is the **x86_64-unknown-linux-musl** binary for `@swc/core`
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@swc/core-linux-x64-musl",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "linux"
6
+ ],
7
+ "cpu": [
8
+ "x64"
9
+ ],
10
+ "main": "swc.linux-x64-musl.node",
11
+ "files": [
12
+ "swc.linux-x64-musl.node",
13
+ "swc"
14
+ ],
15
+ "libc": [
16
+ "musl"
17
+ ],
18
+ "description": "Super-fast alternative for babel",
19
+ "keywords": [
20
+ "swc",
21
+ "swcpack",
22
+ "babel",
23
+ "typescript",
24
+ "rust",
25
+ "webpack",
26
+ "tsc"
27
+ ],
28
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
29
+ "homepage": "https://swc.rs",
30
+ "license": "Apache-2.0 AND MIT",
31
+ "engines": {
32
+ "node": ">=10"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/",
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/swc-project/swc.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/swc-project/swc/issues"
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-win32-arm64-msvc`
2
+
3
+ This is the **aarch64-pc-windows-msvc** binary for `@swc/core`
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@swc/core-win32-arm64-msvc",
3
+ "version": "1.5.20",
4
+ "os": [
5
+ "win32"
6
+ ],
7
+ "cpu": [
8
+ "arm64"
9
+ ],
10
+ "main": "swc.win32-arm64-msvc.node",
11
+ "files": [
12
+ "swc.win32-arm64-msvc.node",
13
+ "swc.exe"
14
+ ],
15
+ "description": "Super-fast alternative for babel",
16
+ "keywords": [
17
+ "swc",
18
+ "swcpack",
19
+ "babel",
20
+ "typescript",
21
+ "rust",
22
+ "webpack",
23
+ "tsc"
24
+ ],
25
+ "author": "강동윤 <kdy1997.dev@gmail.com>",
26
+ "homepage": "https://swc.rs",
27
+ "license": "Apache-2.0 AND MIT",
28
+ "engines": {
29
+ "node": ">=10"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/",
33
+ "access": "public"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/swc-project/swc.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/swc-project/swc/issues"
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ # `@swc/core-win32-ia32-msvc`
2
+
3
+ This is the **i686-pc-windows-msvc** binary for `@swc/core`