@soda-gql/swc 0.11.0
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/README.md +79 -0
- package/dist/index.cjs +915 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +91 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +91 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +913 -0
- package/dist/index.mjs.map +1 -0
- package/dist/native/index.d.ts +42 -0
- package/dist/native/index.js +316 -0
- package/dist/native/swc.linux-x64-gnu.node +0 -0
- package/dist/native.cjs +254 -0
- package/dist/native.cjs.map +1 -0
- package/dist/native.d.cts +46 -0
- package/dist/native.d.cts.map +1 -0
- package/dist/native.d.mts +46 -0
- package/dist/native.d.mts.map +1 -0
- package/dist/native.mjs +256 -0
- package/dist/native.mjs.map +1 -0
- package/package.json +80 -0
- package/src/index.ts +290 -0
- package/src/lib.rs +87 -0
- package/src/native/index.d.ts +42 -0
- package/src/native/index.js +316 -0
- package/src/native/swc.linux-x64-gnu.node +0 -0
- package/src/transform/analysis.rs +240 -0
- package/src/transform/imports.rs +285 -0
- package/src/transform/metadata.rs +371 -0
- package/src/transform/mod.rs +7 -0
- package/src/transform/runtime.rs +197 -0
- package/src/transform/transformer.rs +438 -0
- package/src/transformer.test.ts +209 -0
- package/src/types/artifact.rs +107 -0
- package/src/types/config.rs +72 -0
- package/src/types/error.rs +132 -0
- package/src/types/mod.rs +12 -0
package/dist/native.cjs
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
24
|
+
if (symbols) {
|
|
25
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
26
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
27
|
+
}
|
|
28
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
31
|
+
value: mod,
|
|
32
|
+
enumerable: true
|
|
33
|
+
}) : target, mod));
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
|
|
37
|
+
//#region packages/swc/src/native/index.js
|
|
38
|
+
var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
39
|
+
const { existsSync, readFileSync } = require("fs");
|
|
40
|
+
const { join } = require("path");
|
|
41
|
+
const { platform, arch } = process;
|
|
42
|
+
let nativeBinding = null;
|
|
43
|
+
let localFileExisted = false;
|
|
44
|
+
let loadError = null;
|
|
45
|
+
function isMusl() {
|
|
46
|
+
if (!process.report || typeof process.report.getReport !== "function") try {
|
|
47
|
+
return readFileSync(require("child_process").execSync("which ldd").toString().trim(), "utf8").includes("musl");
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
53
|
+
return !glibcVersionRuntime;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
switch (platform) {
|
|
57
|
+
case "android":
|
|
58
|
+
switch (arch) {
|
|
59
|
+
case "arm64":
|
|
60
|
+
localFileExisted = existsSync(join(__dirname, "swc.android-arm64.node"));
|
|
61
|
+
try {
|
|
62
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "android-arm64.node");
|
|
63
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "android-arm64");
|
|
64
|
+
} catch (e) {
|
|
65
|
+
loadError = e;
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case "arm":
|
|
69
|
+
localFileExisted = existsSync(join(__dirname, "swc.android-arm-eabi.node"));
|
|
70
|
+
try {
|
|
71
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "android-arm-eabi.node");
|
|
72
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "android-arm-eabi");
|
|
73
|
+
} catch (e) {
|
|
74
|
+
loadError = e;
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
default: throw new Error(`Unsupported architecture on Android ${arch}`);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case "win32":
|
|
81
|
+
switch (arch) {
|
|
82
|
+
case "x64":
|
|
83
|
+
localFileExisted = existsSync(join(__dirname, "swc.win32-x64-msvc.node"));
|
|
84
|
+
try {
|
|
85
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "win32-x64-msvc.node");
|
|
86
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "win32-x64-msvc");
|
|
87
|
+
} catch (e) {
|
|
88
|
+
loadError = e;
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "ia32":
|
|
92
|
+
localFileExisted = existsSync(join(__dirname, "swc.win32-ia32-msvc.node"));
|
|
93
|
+
try {
|
|
94
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "win32-ia32-msvc.node");
|
|
95
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "win32-ia32-msvc");
|
|
96
|
+
} catch (e) {
|
|
97
|
+
loadError = e;
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
case "arm64":
|
|
101
|
+
localFileExisted = existsSync(join(__dirname, "swc.win32-arm64-msvc.node"));
|
|
102
|
+
try {
|
|
103
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "win32-arm64-msvc.node");
|
|
104
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "win32-arm64-msvc");
|
|
105
|
+
} catch (e) {
|
|
106
|
+
loadError = e;
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
default: throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case "darwin":
|
|
113
|
+
localFileExisted = existsSync(join(__dirname, "swc.darwin-universal.node"));
|
|
114
|
+
try {
|
|
115
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "darwin-universal.node");
|
|
116
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "darwin-universal");
|
|
117
|
+
break;
|
|
118
|
+
} catch {}
|
|
119
|
+
switch (arch) {
|
|
120
|
+
case "x64":
|
|
121
|
+
localFileExisted = existsSync(join(__dirname, "swc.darwin-x64.node"));
|
|
122
|
+
try {
|
|
123
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "darwin-x64.node");
|
|
124
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "darwin-x64");
|
|
125
|
+
} catch (e) {
|
|
126
|
+
loadError = e;
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
case "arm64":
|
|
130
|
+
localFileExisted = existsSync(join(__dirname, "swc.darwin-arm64.node"));
|
|
131
|
+
try {
|
|
132
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "darwin-arm64.node");
|
|
133
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "darwin-arm64");
|
|
134
|
+
} catch (e) {
|
|
135
|
+
loadError = e;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
default: throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
case "freebsd":
|
|
142
|
+
if (arch !== "x64") throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
|
|
143
|
+
localFileExisted = existsSync(join(__dirname, "swc.freebsd-x64.node"));
|
|
144
|
+
try {
|
|
145
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "freebsd-x64.node");
|
|
146
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "freebsd-x64");
|
|
147
|
+
} catch (e) {
|
|
148
|
+
loadError = e;
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
case "linux":
|
|
152
|
+
switch (arch) {
|
|
153
|
+
case "x64":
|
|
154
|
+
if (isMusl()) {
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-x64-musl.node"));
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-x64-musl.node");
|
|
158
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-x64-musl");
|
|
159
|
+
} catch (e) {
|
|
160
|
+
loadError = e;
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-x64-gnu.node"));
|
|
164
|
+
try {
|
|
165
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-x64-gnu.node");
|
|
166
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-x64-gnu");
|
|
167
|
+
} catch (e) {
|
|
168
|
+
loadError = e;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
case "arm64":
|
|
173
|
+
if (isMusl()) {
|
|
174
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm64-musl.node"));
|
|
175
|
+
try {
|
|
176
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-arm64-musl.node");
|
|
177
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-arm64-musl");
|
|
178
|
+
} catch (e) {
|
|
179
|
+
loadError = e;
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm64-gnu.node"));
|
|
183
|
+
try {
|
|
184
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-arm64-gnu.node");
|
|
185
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-arm64-gnu");
|
|
186
|
+
} catch (e) {
|
|
187
|
+
loadError = e;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
case "arm":
|
|
192
|
+
if (isMusl()) {
|
|
193
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm-musleabihf.node"));
|
|
194
|
+
try {
|
|
195
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-arm-musleabihf.node");
|
|
196
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-arm-musleabihf");
|
|
197
|
+
} catch (e) {
|
|
198
|
+
loadError = e;
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm-gnueabihf.node"));
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-arm-gnueabihf.node");
|
|
204
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-arm-gnueabihf");
|
|
205
|
+
} catch (e) {
|
|
206
|
+
loadError = e;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case "riscv64":
|
|
211
|
+
if (isMusl()) {
|
|
212
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-riscv64-musl.node"));
|
|
213
|
+
try {
|
|
214
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-riscv64-musl.node");
|
|
215
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-riscv64-musl");
|
|
216
|
+
} catch (e) {
|
|
217
|
+
loadError = e;
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-riscv64-gnu.node"));
|
|
221
|
+
try {
|
|
222
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-riscv64-gnu.node");
|
|
223
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-riscv64-gnu");
|
|
224
|
+
} catch (e) {
|
|
225
|
+
loadError = e;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
case "s390x":
|
|
230
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-s390x-gnu.node"));
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) nativeBinding = require("./swc.".slice(0) + "linux-s390x-gnu.node");
|
|
233
|
+
else nativeBinding = require("@soda-gql/swc-".slice(0) + "linux-s390x-gnu");
|
|
234
|
+
} catch (e) {
|
|
235
|
+
loadError = e;
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
default: throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
default: throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
242
|
+
}
|
|
243
|
+
if (!nativeBinding) {
|
|
244
|
+
if (loadError) throw loadError;
|
|
245
|
+
throw new Error(`Failed to load native binding`);
|
|
246
|
+
}
|
|
247
|
+
const { transform, SwcTransformer } = nativeBinding;
|
|
248
|
+
module.exports.transform = transform;
|
|
249
|
+
module.exports.SwcTransformer = SwcTransformer;
|
|
250
|
+
}));
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
exports.__toESM = __toESM;
|
|
254
|
+
//# sourceMappingURL=native.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.cjs","names":[],"sources":["../src/native/index.js"],"sourcesContent":["/* tslint:disable */\n/* eslint-disable */\n/* prettier-ignore */\n\n/* auto-generated by NAPI-RS */\n\nconst { existsSync, readFileSync } = require('fs')\nconst { join } = require('path')\n\nconst { platform, arch } = process\n\nlet nativeBinding = null\nlet localFileExisted = false\nlet loadError = null\n\nfunction isMusl() {\n // For Node 10\n if (!process.report || typeof process.report.getReport !== 'function') {\n try {\n const lddPath = require('child_process').execSync('which ldd').toString().trim()\n return readFileSync(lddPath, 'utf8').includes('musl')\n } catch (e) {\n return true\n }\n } else {\n const { glibcVersionRuntime } = process.report.getReport().header\n return !glibcVersionRuntime\n }\n}\n\nswitch (platform) {\n case 'android':\n switch (arch) {\n case 'arm64':\n localFileExisted = existsSync(join(__dirname, 'swc.android-arm64.node'))\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'android-arm64.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'android-arm64')\n }\n } catch (e) {\n loadError = e\n }\n break\n case 'arm':\n localFileExisted = existsSync(join(__dirname, 'swc.android-arm-eabi.node'))\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'android-arm-eabi.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'android-arm-eabi')\n }\n } catch (e) {\n loadError = e\n }\n break\n default:\n throw new Error(`Unsupported architecture on Android ${arch}`)\n }\n break\n case 'win32':\n switch (arch) {\n case 'x64':\n localFileExisted = existsSync(\n join(__dirname, 'swc.win32-x64-msvc.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'win32-x64-msvc.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'win32-x64-msvc')\n }\n } catch (e) {\n loadError = e\n }\n break\n case 'ia32':\n localFileExisted = existsSync(\n join(__dirname, 'swc.win32-ia32-msvc.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'win32-ia32-msvc.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'win32-ia32-msvc')\n }\n } catch (e) {\n loadError = e\n }\n break\n case 'arm64':\n localFileExisted = existsSync(\n join(__dirname, 'swc.win32-arm64-msvc.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'win32-arm64-msvc.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'win32-arm64-msvc')\n }\n } catch (e) {\n loadError = e\n }\n break\n default:\n throw new Error(`Unsupported architecture on Windows: ${arch}`)\n }\n break\n case 'darwin':\n localFileExisted = existsSync(join(__dirname, 'swc.darwin-universal.node'))\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'darwin-universal.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'darwin-universal')\n }\n break\n } catch {}\n switch (arch) {\n case 'x64':\n localFileExisted = existsSync(join(__dirname, 'swc.darwin-x64.node'))\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'darwin-x64.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'darwin-x64')\n }\n } catch (e) {\n loadError = e\n }\n break\n case 'arm64':\n localFileExisted = existsSync(\n join(__dirname, 'swc.darwin-arm64.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'darwin-arm64.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'darwin-arm64')\n }\n } catch (e) {\n loadError = e\n }\n break\n default:\n throw new Error(`Unsupported architecture on macOS: ${arch}`)\n }\n break\n case 'freebsd':\n if (arch !== 'x64') {\n throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)\n }\n localFileExisted = existsSync(join(__dirname, 'swc.freebsd-x64.node'))\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'freebsd-x64.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'freebsd-x64')\n }\n } catch (e) {\n loadError = e\n }\n break\n case 'linux':\n switch (arch) {\n case 'x64':\n if (isMusl()) {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-x64-musl.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-x64-musl.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-x64-musl')\n }\n } catch (e) {\n loadError = e\n }\n } else {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-x64-gnu.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-x64-gnu.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-x64-gnu')\n }\n } catch (e) {\n loadError = e\n }\n }\n break\n case 'arm64':\n if (isMusl()) {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-arm64-musl.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-arm64-musl.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-arm64-musl')\n }\n } catch (e) {\n loadError = e\n }\n } else {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-arm64-gnu.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-arm64-gnu.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-arm64-gnu')\n }\n } catch (e) {\n loadError = e\n }\n }\n break\n case 'arm':\n if (isMusl()) {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-arm-musleabihf.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-arm-musleabihf.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-arm-musleabihf')\n }\n } catch (e) {\n loadError = e\n }\n } else {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-arm-gnueabihf.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-arm-gnueabihf.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-arm-gnueabihf')\n }\n } catch (e) {\n loadError = e\n }\n }\n break\n case 'riscv64':\n if (isMusl()) {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-riscv64-musl.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-riscv64-musl.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-riscv64-musl')\n }\n } catch (e) {\n loadError = e\n }\n } else {\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-riscv64-gnu.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-riscv64-gnu.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-riscv64-gnu')\n }\n } catch (e) {\n loadError = e\n }\n }\n break\n case 's390x':\n localFileExisted = existsSync(\n join(__dirname, 'swc.linux-s390x-gnu.node')\n )\n try {\n if (localFileExisted) {\n nativeBinding = require('./swc.'.slice(0) + 'linux-s390x-gnu.node')\n } else {\n nativeBinding = require('@soda-gql/swc-'.slice(0) + 'linux-s390x-gnu')\n }\n } catch (e) {\n loadError = e\n }\n break\n default:\n throw new Error(`Unsupported architecture on Linux: ${arch}`)\n }\n break\n default:\n throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)\n}\n\nif (!nativeBinding) {\n if (loadError) {\n throw loadError\n }\n throw new Error(`Failed to load native binding`)\n}\n\nconst { transform, SwcTrans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AAG,kBAAkB;cAEjE,GAAG;AACV,kBAAY;;AAEd;IACF,QACE,OAAM,IAAI,MAAM,sCAAsC,OAAO;;AAEjE;EACF,QACE,OAAM,IAAI,MAAM,mBAAmB,SAAS,kBAAkB,OAAO;;AAGzE,KAAI,CAAC,eAAe;AAClB,MAAI,UACF,OAAM;AAER,QAAM,IAAI,MAAM,gCAAgC;;CAGlD,MAAM,EAAE,WAAW,mBAAmB;AAEtC,QAAO,QAAQ,YAAY;AAC3B,QAAO,QAAQ,iBAAiB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region packages/swc/src/native/index.d.ts
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Transform a single source file.
|
|
9
|
+
*
|
|
10
|
+
* # Arguments
|
|
11
|
+
* * `input_json` - JSON-serialized TransformInput containing source code, file path, artifact, and config
|
|
12
|
+
*
|
|
13
|
+
* # Returns
|
|
14
|
+
* JSON-serialized TransformResult containing the transformed code
|
|
15
|
+
*/
|
|
16
|
+
declare function transform(inputJson: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Stateful transformer that caches artifact and config for multiple file transformations.
|
|
19
|
+
*
|
|
20
|
+
* The artifact is parsed once in the constructor and reused for all subsequent
|
|
21
|
+
* transform calls, avoiding repeated JSON parsing overhead.
|
|
22
|
+
*/
|
|
23
|
+
declare class SwcTransformer {
|
|
24
|
+
/**
|
|
25
|
+
* Create a new transformer instance.
|
|
26
|
+
*
|
|
27
|
+
* # Arguments
|
|
28
|
+
* * `artifact_json` - JSON-serialized BuilderArtifact
|
|
29
|
+
* * `config_json` - JSON-serialized TransformConfig
|
|
30
|
+
*/
|
|
31
|
+
constructor(artifactJson: string, configJson: string);
|
|
32
|
+
/**
|
|
33
|
+
* Transform a single source file.
|
|
34
|
+
*
|
|
35
|
+
* # Arguments
|
|
36
|
+
* * `source_code` - The source code to transform
|
|
37
|
+
* * `source_path` - The file path of the source
|
|
38
|
+
*
|
|
39
|
+
* # Returns
|
|
40
|
+
* JSON-serialized TransformResult
|
|
41
|
+
*/
|
|
42
|
+
transform(sourceCode: string, sourcePath: string): string;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { SwcTransformer, transform };
|
|
46
|
+
//# sourceMappingURL=native.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.cts","names":["transform","SwcTransformer"],"sources":["../src/native/index.d.ts"],"sourcesContent":["/* tslint:disable */\n/* eslint-disable */\n\n/* auto-generated by NAPI-RS */\n\n/**\n * Transform a single source file.\n *\n * # Arguments\n * * `input_json` - JSON-serialized TransformInput containing source code, file path, artifact, and config\n *\n * # Returns\n * JSON-serialized TransformResult containing the transformed code\n */\nexport declare function transform(inputJson: string): string\n/**\n * Stateful transformer that caches artifact and config for multiple file transformations.\n *\n * The artifact is parsed once in the constructor and reused for all subsequent\n * transform calls, avoiding repeated JSON parsing overhead.\n */\nexport declare class SwcTransformer {\n /**\n * Create a new transformer instance.\n *\n * # Arguments\n * * `artifact_json` - JSON-serialized BuilderArtifact\n * * `config_json` - JSON-serialized TransformConfig\n */\n constructor(artifactJson: string, configJson: string)\n /**\n * Transform a single source file.\n *\n * # Arguments\n * * `source_code` - The source code to transform\n * * `source_path` - The file path of the source\n *\n * # Returns\n * JSON-serialized TransformResult\n */\n transform(sourceCode: string, sourcePath: string): string\n}\n"],"mappings":";;AAcA;;;;;;;;;;;;;iBAAwBA,SAAAA;;;;;;;cAOHC,cAAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region packages/swc/src/native/index.d.ts
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Transform a single source file.
|
|
9
|
+
*
|
|
10
|
+
* # Arguments
|
|
11
|
+
* * `input_json` - JSON-serialized TransformInput containing source code, file path, artifact, and config
|
|
12
|
+
*
|
|
13
|
+
* # Returns
|
|
14
|
+
* JSON-serialized TransformResult containing the transformed code
|
|
15
|
+
*/
|
|
16
|
+
declare function transform(inputJson: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Stateful transformer that caches artifact and config for multiple file transformations.
|
|
19
|
+
*
|
|
20
|
+
* The artifact is parsed once in the constructor and reused for all subsequent
|
|
21
|
+
* transform calls, avoiding repeated JSON parsing overhead.
|
|
22
|
+
*/
|
|
23
|
+
declare class SwcTransformer {
|
|
24
|
+
/**
|
|
25
|
+
* Create a new transformer instance.
|
|
26
|
+
*
|
|
27
|
+
* # Arguments
|
|
28
|
+
* * `artifact_json` - JSON-serialized BuilderArtifact
|
|
29
|
+
* * `config_json` - JSON-serialized TransformConfig
|
|
30
|
+
*/
|
|
31
|
+
constructor(artifactJson: string, configJson: string);
|
|
32
|
+
/**
|
|
33
|
+
* Transform a single source file.
|
|
34
|
+
*
|
|
35
|
+
* # Arguments
|
|
36
|
+
* * `source_code` - The source code to transform
|
|
37
|
+
* * `source_path` - The file path of the source
|
|
38
|
+
*
|
|
39
|
+
* # Returns
|
|
40
|
+
* JSON-serialized TransformResult
|
|
41
|
+
*/
|
|
42
|
+
transform(sourceCode: string, sourcePath: string): string;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { SwcTransformer, transform };
|
|
46
|
+
//# sourceMappingURL=native.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.mts","names":["transform","SwcTransformer"],"sources":["../src/native/index.d.ts"],"sourcesContent":["/* tslint:disable */\n/* eslint-disable */\n\n/* auto-generated by NAPI-RS */\n\n/**\n * Transform a single source file.\n *\n * # Arguments\n * * `input_json` - JSON-serialized TransformInput containing source code, file path, artifact, and config\n *\n * # Returns\n * JSON-serialized TransformResult containing the transformed code\n */\nexport declare function transform(inputJson: string): string\n/**\n * Stateful transformer that caches artifact and config for multiple file transformations.\n *\n * The artifact is parsed once in the constructor and reused for all subsequent\n * transform calls, avoiding repeated JSON parsing overhead.\n */\nexport declare class SwcTransformer {\n /**\n * Create a new transformer instance.\n *\n * # Arguments\n * * `artifact_json` - JSON-serialized BuilderArtifact\n * * `config_json` - JSON-serialized TransformConfig\n */\n constructor(artifactJson: string, configJson: string)\n /**\n * Transform a single source file.\n *\n * # Arguments\n * * `source_code` - The source code to transform\n * * `source_path` - The file path of the source\n *\n * # Returns\n * JSON-serialized TransformResult\n */\n transform(sourceCode: string, sourcePath: string): string\n}\n"],"mappings":";;AAcA;;;;;;;;;;;;;iBAAwBA,SAAAA;;;;;;;cAOHC,cAAAA"}
|
package/dist/native.mjs
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
__defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
26
|
+
if (symbols) {
|
|
27
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
28
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
29
|
+
}
|
|
30
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
31
|
+
};
|
|
32
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
33
|
+
value: mod,
|
|
34
|
+
enumerable: true
|
|
35
|
+
}) : target, mod));
|
|
36
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region packages/swc/src/native/index.js
|
|
40
|
+
var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
41
|
+
const { existsSync, readFileSync } = __require("fs");
|
|
42
|
+
const { join } = __require("path");
|
|
43
|
+
const { platform, arch } = process;
|
|
44
|
+
let nativeBinding = null;
|
|
45
|
+
let localFileExisted = false;
|
|
46
|
+
let loadError = null;
|
|
47
|
+
function isMusl() {
|
|
48
|
+
if (!process.report || typeof process.report.getReport !== "function") try {
|
|
49
|
+
return readFileSync(__require("child_process").execSync("which ldd").toString().trim(), "utf8").includes("musl");
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
55
|
+
return !glibcVersionRuntime;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
switch (platform) {
|
|
59
|
+
case "android":
|
|
60
|
+
switch (arch) {
|
|
61
|
+
case "arm64":
|
|
62
|
+
localFileExisted = existsSync(join(__dirname, "swc.android-arm64.node"));
|
|
63
|
+
try {
|
|
64
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "android-arm64.node");
|
|
65
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "android-arm64");
|
|
66
|
+
} catch (e) {
|
|
67
|
+
loadError = e;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case "arm":
|
|
71
|
+
localFileExisted = existsSync(join(__dirname, "swc.android-arm-eabi.node"));
|
|
72
|
+
try {
|
|
73
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "android-arm-eabi.node");
|
|
74
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "android-arm-eabi");
|
|
75
|
+
} catch (e) {
|
|
76
|
+
loadError = e;
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
default: throw new Error(`Unsupported architecture on Android ${arch}`);
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case "win32":
|
|
83
|
+
switch (arch) {
|
|
84
|
+
case "x64":
|
|
85
|
+
localFileExisted = existsSync(join(__dirname, "swc.win32-x64-msvc.node"));
|
|
86
|
+
try {
|
|
87
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "win32-x64-msvc.node");
|
|
88
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "win32-x64-msvc");
|
|
89
|
+
} catch (e) {
|
|
90
|
+
loadError = e;
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case "ia32":
|
|
94
|
+
localFileExisted = existsSync(join(__dirname, "swc.win32-ia32-msvc.node"));
|
|
95
|
+
try {
|
|
96
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "win32-ia32-msvc.node");
|
|
97
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "win32-ia32-msvc");
|
|
98
|
+
} catch (e) {
|
|
99
|
+
loadError = e;
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case "arm64":
|
|
103
|
+
localFileExisted = existsSync(join(__dirname, "swc.win32-arm64-msvc.node"));
|
|
104
|
+
try {
|
|
105
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "win32-arm64-msvc.node");
|
|
106
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "win32-arm64-msvc");
|
|
107
|
+
} catch (e) {
|
|
108
|
+
loadError = e;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
default: throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case "darwin":
|
|
115
|
+
localFileExisted = existsSync(join(__dirname, "swc.darwin-universal.node"));
|
|
116
|
+
try {
|
|
117
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "darwin-universal.node");
|
|
118
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "darwin-universal");
|
|
119
|
+
break;
|
|
120
|
+
} catch {}
|
|
121
|
+
switch (arch) {
|
|
122
|
+
case "x64":
|
|
123
|
+
localFileExisted = existsSync(join(__dirname, "swc.darwin-x64.node"));
|
|
124
|
+
try {
|
|
125
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "darwin-x64.node");
|
|
126
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "darwin-x64");
|
|
127
|
+
} catch (e) {
|
|
128
|
+
loadError = e;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case "arm64":
|
|
132
|
+
localFileExisted = existsSync(join(__dirname, "swc.darwin-arm64.node"));
|
|
133
|
+
try {
|
|
134
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "darwin-arm64.node");
|
|
135
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "darwin-arm64");
|
|
136
|
+
} catch (e) {
|
|
137
|
+
loadError = e;
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
default: throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case "freebsd":
|
|
144
|
+
if (arch !== "x64") throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
|
|
145
|
+
localFileExisted = existsSync(join(__dirname, "swc.freebsd-x64.node"));
|
|
146
|
+
try {
|
|
147
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "freebsd-x64.node");
|
|
148
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "freebsd-x64");
|
|
149
|
+
} catch (e) {
|
|
150
|
+
loadError = e;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case "linux":
|
|
154
|
+
switch (arch) {
|
|
155
|
+
case "x64":
|
|
156
|
+
if (isMusl()) {
|
|
157
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-x64-musl.node"));
|
|
158
|
+
try {
|
|
159
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-x64-musl.node");
|
|
160
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-x64-musl");
|
|
161
|
+
} catch (e) {
|
|
162
|
+
loadError = e;
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-x64-gnu.node"));
|
|
166
|
+
try {
|
|
167
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-x64-gnu.node");
|
|
168
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-x64-gnu");
|
|
169
|
+
} catch (e) {
|
|
170
|
+
loadError = e;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case "arm64":
|
|
175
|
+
if (isMusl()) {
|
|
176
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm64-musl.node"));
|
|
177
|
+
try {
|
|
178
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-arm64-musl.node");
|
|
179
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-arm64-musl");
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadError = e;
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm64-gnu.node"));
|
|
185
|
+
try {
|
|
186
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-arm64-gnu.node");
|
|
187
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-arm64-gnu");
|
|
188
|
+
} catch (e) {
|
|
189
|
+
loadError = e;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case "arm":
|
|
194
|
+
if (isMusl()) {
|
|
195
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm-musleabihf.node"));
|
|
196
|
+
try {
|
|
197
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-arm-musleabihf.node");
|
|
198
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-arm-musleabihf");
|
|
199
|
+
} catch (e) {
|
|
200
|
+
loadError = e;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-arm-gnueabihf.node"));
|
|
204
|
+
try {
|
|
205
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-arm-gnueabihf.node");
|
|
206
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-arm-gnueabihf");
|
|
207
|
+
} catch (e) {
|
|
208
|
+
loadError = e;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
case "riscv64":
|
|
213
|
+
if (isMusl()) {
|
|
214
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-riscv64-musl.node"));
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-riscv64-musl.node");
|
|
217
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-riscv64-musl");
|
|
218
|
+
} catch (e) {
|
|
219
|
+
loadError = e;
|
|
220
|
+
}
|
|
221
|
+
} else {
|
|
222
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-riscv64-gnu.node"));
|
|
223
|
+
try {
|
|
224
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-riscv64-gnu.node");
|
|
225
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-riscv64-gnu");
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadError = e;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
case "s390x":
|
|
232
|
+
localFileExisted = existsSync(join(__dirname, "swc.linux-s390x-gnu.node"));
|
|
233
|
+
try {
|
|
234
|
+
if (localFileExisted) nativeBinding = __require("./swc.".slice(0) + "linux-s390x-gnu.node");
|
|
235
|
+
else nativeBinding = __require("@soda-gql/swc-".slice(0) + "linux-s390x-gnu");
|
|
236
|
+
} catch (e) {
|
|
237
|
+
loadError = e;
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
default: throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
default: throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
244
|
+
}
|
|
245
|
+
if (!nativeBinding) {
|
|
246
|
+
if (loadError) throw loadError;
|
|
247
|
+
throw new Error(`Failed to load native binding`);
|
|
248
|
+
}
|
|
249
|
+
const { transform, SwcTransformer } = nativeBinding;
|
|
250
|
+
module.exports.transform = transform;
|
|
251
|
+
module.exports.SwcTransformer = SwcTransformer;
|
|
252
|
+
}));
|
|
253
|
+
|
|
254
|
+
//#endregion
|
|
255
|
+
export { };
|
|
256
|
+
//# sourceMappingURL=native.mjs.map
|