rolldown 1.0.0-beta.9-commit.ca4e9dd → 1.0.0-rc.1
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 +11 -0
- package/bin/cli.mjs +1 -0
- package/dist/cli-setup.mjs +17 -0
- package/dist/cli.mjs +1085 -1281
- package/dist/config.d.mts +2 -4
- package/dist/config.mjs +8 -5
- package/dist/experimental-index.d.mts +161 -76
- package/dist/experimental-index.mjs +227 -61
- package/dist/experimental-runtime-types.d.ts +98 -0
- package/dist/filter-index.d.mts +196 -4
- package/dist/filter-index.mjs +328 -4
- package/dist/get-log-filter.d.mts +7 -0
- package/dist/get-log-filter.mjs +48 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +56 -5
- package/dist/parallel-plugin-worker.mjs +27 -33
- package/dist/parallel-plugin.d.mts +7 -8
- package/dist/parse-ast-index.d.mts +4 -5
- package/dist/parse-ast-index.mjs +2 -2
- package/dist/plugins-index.d.mts +30 -0
- package/dist/plugins-index.mjs +40 -0
- package/dist/shared/binding-B92Lq__Q.d.mts +1687 -0
- package/dist/shared/binding-C-UNREnT.mjs +585 -0
- package/dist/shared/bindingify-input-options-Cb-01HR1.mjs +2233 -0
- package/dist/shared/constructors-D_KFsTQ-.d.mts +28 -0
- package/dist/shared/constructors-aZ82R2dj.mjs +61 -0
- package/dist/shared/define-config-BVG4QvnP.mjs +7 -0
- package/dist/shared/define-config-DO4TBkJV.d.mts +3457 -0
- package/dist/shared/{load-config-Hg0usN_9.mjs → load-config-D6cey0o1.mjs} +23 -33
- package/dist/shared/logging-wIy4zY9I.d.mts +50 -0
- package/dist/shared/logs-NH298mHo.mjs +183 -0
- package/dist/shared/{misc-DGAe2XOW.mjs → misc-CCZIsXVO.mjs} +1 -7
- package/dist/shared/normalize-string-or-regex-Dq50a7l9.mjs +61 -0
- package/dist/shared/parse-ast-index-B6LAhWD8.mjs +99 -0
- package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-tlfjalEt.mjs} +301 -308
- package/dist/shared/rolldown-CIC_OHw3.mjs +42 -0
- package/dist/shared/rolldown-build-KB1YaNe-.mjs +2369 -0
- package/dist/shared/watch-B2WRkpw2.mjs +379 -0
- package/package.json +86 -98
- package/dist/cli.cjs +0 -1748
- package/dist/config.cjs +0 -12
- package/dist/config.d.cts +0 -12
- package/dist/experimental-index.cjs +0 -132
- package/dist/experimental-index.d.cts +0 -96
- package/dist/filter-index.cjs +0 -105
- package/dist/filter-index.d.cts +0 -5
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +0 -4
- package/dist/parallel-plugin-worker.cjs +0 -33
- package/dist/parallel-plugin-worker.d.cts +0 -1
- package/dist/parallel-plugin.cjs +0 -8
- package/dist/parallel-plugin.d.cts +0 -15
- package/dist/parse-ast-index.cjs +0 -4
- package/dist/parse-ast-index.d.cts +0 -9
- package/dist/shared/binding.d-Dz3qQrbl.d.mts +0 -1682
- package/dist/shared/binding.d-QXzDcVmm.d.cts +0 -1682
- package/dist/shared/chunk--iN_1bjD.mjs +0 -33
- package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
- package/dist/shared/define-config.d-CUcDq_vm.d.cts +0 -1080
- package/dist/shared/define-config.d-qV1PzX_C.d.mts +0 -1080
- package/dist/shared/load-config-Cy3vMDpE.cjs +0 -125
- package/dist/shared/misc-BKp5iIef.cjs +0 -67
- package/dist/shared/parse-ast-index-0m6JgGc9.mjs +0 -655
- package/dist/shared/parse-ast-index-Cn_efzjO.cjs +0 -697
- package/dist/shared/prompt-uGrwvyp0.mjs +0 -854
- package/dist/shared/src-CqsZy-Xs.cjs +0 -4654
- package/dist/shared/src-sZov5fTK.mjs +0 -4704
- /package/dist/{cli.d.cts → cli-setup.d.mts} +0 -0
|
@@ -1,655 +0,0 @@
|
|
|
1
|
-
import { __commonJS, __esm, __require, __toESM } from "./chunk--iN_1bjD.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/webcontainer-fallback.js
|
|
4
|
-
var require_webcontainer_fallback = __commonJS({ "src/webcontainer-fallback.js"(exports, module) {
|
|
5
|
-
const fs = __require("node:fs");
|
|
6
|
-
const childProcess = __require("node:child_process");
|
|
7
|
-
const rolldownPkg = JSON.parse(fs.readFileSync(__require.resolve("rolldown/package.json"), "utf-8"));
|
|
8
|
-
const version = rolldownPkg.version;
|
|
9
|
-
const baseDir = `/tmp/rolldown-${version}`;
|
|
10
|
-
const bindingEntry = `${baseDir}/node_modules/@rolldown/binding-wasm32-wasi/rolldown-binding.wasi.cjs`;
|
|
11
|
-
if (!fs.existsSync(bindingEntry)) {
|
|
12
|
-
const bindingPkg = `@rolldown/binding-wasm32-wasi@${version}`;
|
|
13
|
-
fs.rmSync(baseDir, {
|
|
14
|
-
recursive: true,
|
|
15
|
-
force: true
|
|
16
|
-
});
|
|
17
|
-
fs.mkdirSync(baseDir, { recursive: true });
|
|
18
|
-
console.log(`[rolldown] Downloading ${bindingPkg} on WebContainer...`);
|
|
19
|
-
childProcess.execFileSync("pnpm", ["i", bindingPkg], {
|
|
20
|
-
cwd: baseDir,
|
|
21
|
-
stdio: "inherit"
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
module.exports = __require(bindingEntry);
|
|
25
|
-
} });
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/binding.js
|
|
29
|
-
var require_binding = __commonJS({ "src/binding.js"(exports, module) {
|
|
30
|
-
const { createRequire } = __require("node:module");
|
|
31
|
-
const { readFileSync } = __require("node:fs");
|
|
32
|
-
let nativeBinding = null;
|
|
33
|
-
const loadErrors = [];
|
|
34
|
-
const isMusl = () => {
|
|
35
|
-
let musl = false;
|
|
36
|
-
if (process.platform === "linux") {
|
|
37
|
-
musl = isMuslFromFilesystem();
|
|
38
|
-
if (musl === null) musl = isMuslFromReport();
|
|
39
|
-
if (musl === null) musl = isMuslFromChildProcess();
|
|
40
|
-
}
|
|
41
|
-
return musl;
|
|
42
|
-
};
|
|
43
|
-
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
44
|
-
const isMuslFromFilesystem = () => {
|
|
45
|
-
try {
|
|
46
|
-
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
|
|
47
|
-
} catch {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const isMuslFromReport = () => {
|
|
52
|
-
let report = null;
|
|
53
|
-
if (typeof process.report?.getReport === "function") {
|
|
54
|
-
process.report.excludeNetwork = true;
|
|
55
|
-
report = process.report.getReport();
|
|
56
|
-
}
|
|
57
|
-
if (!report) return null;
|
|
58
|
-
if (report.header && report.header.glibcVersionRuntime) return false;
|
|
59
|
-
if (Array.isArray(report.sharedObjects)) {
|
|
60
|
-
if (report.sharedObjects.some(isFileMusl)) return true;
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
};
|
|
64
|
-
const isMuslFromChildProcess = () => {
|
|
65
|
-
try {
|
|
66
|
-
return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
|
|
67
|
-
} catch (e) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
function requireNative() {
|
|
72
|
-
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
|
|
73
|
-
nativeBinding = __require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
74
|
-
} catch (err) {
|
|
75
|
-
loadErrors.push(err);
|
|
76
|
-
}
|
|
77
|
-
else if (process.platform === "android") if (process.arch === "arm64") {
|
|
78
|
-
try {
|
|
79
|
-
return __require("../rolldown-binding.android-arm64.node");
|
|
80
|
-
} catch (e) {
|
|
81
|
-
loadErrors.push(e);
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
return __require("@rolldown/binding-android-arm64");
|
|
85
|
-
} catch (e) {
|
|
86
|
-
loadErrors.push(e);
|
|
87
|
-
}
|
|
88
|
-
} else if (process.arch === "arm") {
|
|
89
|
-
try {
|
|
90
|
-
return __require("../rolldown-binding.android-arm-eabi.node");
|
|
91
|
-
} catch (e) {
|
|
92
|
-
loadErrors.push(e);
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
return __require("@rolldown/binding-android-arm-eabi");
|
|
96
|
-
} catch (e) {
|
|
97
|
-
loadErrors.push(e);
|
|
98
|
-
}
|
|
99
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
|
|
100
|
-
else if (process.platform === "win32") if (process.arch === "x64") {
|
|
101
|
-
try {
|
|
102
|
-
return __require("../rolldown-binding.win32-x64-msvc.node");
|
|
103
|
-
} catch (e) {
|
|
104
|
-
loadErrors.push(e);
|
|
105
|
-
}
|
|
106
|
-
try {
|
|
107
|
-
return __require("@rolldown/binding-win32-x64-msvc");
|
|
108
|
-
} catch (e) {
|
|
109
|
-
loadErrors.push(e);
|
|
110
|
-
}
|
|
111
|
-
} else if (process.arch === "ia32") {
|
|
112
|
-
try {
|
|
113
|
-
return __require("../rolldown-binding.win32-ia32-msvc.node");
|
|
114
|
-
} catch (e) {
|
|
115
|
-
loadErrors.push(e);
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
return __require("@rolldown/binding-win32-ia32-msvc");
|
|
119
|
-
} catch (e) {
|
|
120
|
-
loadErrors.push(e);
|
|
121
|
-
}
|
|
122
|
-
} else if (process.arch === "arm64") {
|
|
123
|
-
try {
|
|
124
|
-
return __require("../rolldown-binding.win32-arm64-msvc.node");
|
|
125
|
-
} catch (e) {
|
|
126
|
-
loadErrors.push(e);
|
|
127
|
-
}
|
|
128
|
-
try {
|
|
129
|
-
return __require("@rolldown/binding-win32-arm64-msvc");
|
|
130
|
-
} catch (e) {
|
|
131
|
-
loadErrors.push(e);
|
|
132
|
-
}
|
|
133
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
|
|
134
|
-
else if (process.platform === "darwin") {
|
|
135
|
-
try {
|
|
136
|
-
return __require("../rolldown-binding.darwin-universal.node");
|
|
137
|
-
} catch (e) {
|
|
138
|
-
loadErrors.push(e);
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
return __require("@rolldown/binding-darwin-universal");
|
|
142
|
-
} catch (e) {
|
|
143
|
-
loadErrors.push(e);
|
|
144
|
-
}
|
|
145
|
-
if (process.arch === "x64") {
|
|
146
|
-
try {
|
|
147
|
-
return __require("../rolldown-binding.darwin-x64.node");
|
|
148
|
-
} catch (e) {
|
|
149
|
-
loadErrors.push(e);
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
return __require("@rolldown/binding-darwin-x64");
|
|
153
|
-
} catch (e) {
|
|
154
|
-
loadErrors.push(e);
|
|
155
|
-
}
|
|
156
|
-
} else if (process.arch === "arm64") {
|
|
157
|
-
try {
|
|
158
|
-
return __require("../rolldown-binding.darwin-arm64.node");
|
|
159
|
-
} catch (e) {
|
|
160
|
-
loadErrors.push(e);
|
|
161
|
-
}
|
|
162
|
-
try {
|
|
163
|
-
return __require("@rolldown/binding-darwin-arm64");
|
|
164
|
-
} catch (e) {
|
|
165
|
-
loadErrors.push(e);
|
|
166
|
-
}
|
|
167
|
-
} else loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
|
|
168
|
-
} else if (process.platform === "freebsd") if (process.arch === "x64") {
|
|
169
|
-
try {
|
|
170
|
-
return __require("../rolldown-binding.freebsd-x64.node");
|
|
171
|
-
} catch (e) {
|
|
172
|
-
loadErrors.push(e);
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
return __require("@rolldown/binding-freebsd-x64");
|
|
176
|
-
} catch (e) {
|
|
177
|
-
loadErrors.push(e);
|
|
178
|
-
}
|
|
179
|
-
} else if (process.arch === "arm64") {
|
|
180
|
-
try {
|
|
181
|
-
return __require("../rolldown-binding.freebsd-arm64.node");
|
|
182
|
-
} catch (e) {
|
|
183
|
-
loadErrors.push(e);
|
|
184
|
-
}
|
|
185
|
-
try {
|
|
186
|
-
return __require("@rolldown/binding-freebsd-arm64");
|
|
187
|
-
} catch (e) {
|
|
188
|
-
loadErrors.push(e);
|
|
189
|
-
}
|
|
190
|
-
} else loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
|
|
191
|
-
else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
|
|
192
|
-
try {
|
|
193
|
-
return __require("../rolldown-binding.linux-x64-musl.node");
|
|
194
|
-
} catch (e) {
|
|
195
|
-
loadErrors.push(e);
|
|
196
|
-
}
|
|
197
|
-
try {
|
|
198
|
-
return __require("@rolldown/binding-linux-x64-musl");
|
|
199
|
-
} catch (e) {
|
|
200
|
-
loadErrors.push(e);
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
try {
|
|
204
|
-
return __require("../rolldown-binding.linux-x64-gnu.node");
|
|
205
|
-
} catch (e) {
|
|
206
|
-
loadErrors.push(e);
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
return __require("@rolldown/binding-linux-x64-gnu");
|
|
210
|
-
} catch (e) {
|
|
211
|
-
loadErrors.push(e);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else if (process.arch === "arm64") if (isMusl()) {
|
|
215
|
-
try {
|
|
216
|
-
return __require("../rolldown-binding.linux-arm64-musl.node");
|
|
217
|
-
} catch (e) {
|
|
218
|
-
loadErrors.push(e);
|
|
219
|
-
}
|
|
220
|
-
try {
|
|
221
|
-
return __require("@rolldown/binding-linux-arm64-musl");
|
|
222
|
-
} catch (e) {
|
|
223
|
-
loadErrors.push(e);
|
|
224
|
-
}
|
|
225
|
-
} else {
|
|
226
|
-
try {
|
|
227
|
-
return __require("../rolldown-binding.linux-arm64-gnu.node");
|
|
228
|
-
} catch (e) {
|
|
229
|
-
loadErrors.push(e);
|
|
230
|
-
}
|
|
231
|
-
try {
|
|
232
|
-
return __require("@rolldown/binding-linux-arm64-gnu");
|
|
233
|
-
} catch (e) {
|
|
234
|
-
loadErrors.push(e);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
else if (process.arch === "arm") if (isMusl()) {
|
|
238
|
-
try {
|
|
239
|
-
return __require("../rolldown-binding.linux-arm-musleabihf.node");
|
|
240
|
-
} catch (e) {
|
|
241
|
-
loadErrors.push(e);
|
|
242
|
-
}
|
|
243
|
-
try {
|
|
244
|
-
return __require("@rolldown/binding-linux-arm-musleabihf");
|
|
245
|
-
} catch (e) {
|
|
246
|
-
loadErrors.push(e);
|
|
247
|
-
}
|
|
248
|
-
} else {
|
|
249
|
-
try {
|
|
250
|
-
return __require("../rolldown-binding.linux-arm-gnueabihf.node");
|
|
251
|
-
} catch (e) {
|
|
252
|
-
loadErrors.push(e);
|
|
253
|
-
}
|
|
254
|
-
try {
|
|
255
|
-
return __require("@rolldown/binding-linux-arm-gnueabihf");
|
|
256
|
-
} catch (e) {
|
|
257
|
-
loadErrors.push(e);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
else if (process.arch === "riscv64") if (isMusl()) {
|
|
261
|
-
try {
|
|
262
|
-
return __require("../rolldown-binding.linux-riscv64-musl.node");
|
|
263
|
-
} catch (e) {
|
|
264
|
-
loadErrors.push(e);
|
|
265
|
-
}
|
|
266
|
-
try {
|
|
267
|
-
return __require("@rolldown/binding-linux-riscv64-musl");
|
|
268
|
-
} catch (e) {
|
|
269
|
-
loadErrors.push(e);
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
try {
|
|
273
|
-
return __require("../rolldown-binding.linux-riscv64-gnu.node");
|
|
274
|
-
} catch (e) {
|
|
275
|
-
loadErrors.push(e);
|
|
276
|
-
}
|
|
277
|
-
try {
|
|
278
|
-
return __require("@rolldown/binding-linux-riscv64-gnu");
|
|
279
|
-
} catch (e) {
|
|
280
|
-
loadErrors.push(e);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else if (process.arch === "ppc64") {
|
|
284
|
-
try {
|
|
285
|
-
return __require("../rolldown-binding.linux-ppc64-gnu.node");
|
|
286
|
-
} catch (e) {
|
|
287
|
-
loadErrors.push(e);
|
|
288
|
-
}
|
|
289
|
-
try {
|
|
290
|
-
return __require("@rolldown/binding-linux-ppc64-gnu");
|
|
291
|
-
} catch (e) {
|
|
292
|
-
loadErrors.push(e);
|
|
293
|
-
}
|
|
294
|
-
} else if (process.arch === "s390x") {
|
|
295
|
-
try {
|
|
296
|
-
return __require("../rolldown-binding.linux-s390x-gnu.node");
|
|
297
|
-
} catch (e) {
|
|
298
|
-
loadErrors.push(e);
|
|
299
|
-
}
|
|
300
|
-
try {
|
|
301
|
-
return __require("@rolldown/binding-linux-s390x-gnu");
|
|
302
|
-
} catch (e) {
|
|
303
|
-
loadErrors.push(e);
|
|
304
|
-
}
|
|
305
|
-
} else loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
|
|
306
|
-
else loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
|
|
307
|
-
}
|
|
308
|
-
nativeBinding = requireNative();
|
|
309
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
310
|
-
try {
|
|
311
|
-
nativeBinding = __require("../rolldown-binding.wasi.cjs");
|
|
312
|
-
} catch (err) {
|
|
313
|
-
if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
|
|
314
|
-
}
|
|
315
|
-
if (!nativeBinding) try {
|
|
316
|
-
nativeBinding = __require("@rolldown/binding-wasm32-wasi");
|
|
317
|
-
} catch (err) {
|
|
318
|
-
if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) try {
|
|
322
|
-
nativeBinding = require_webcontainer_fallback();
|
|
323
|
-
} catch (err) {
|
|
324
|
-
loadErrors.push(err);
|
|
325
|
-
}
|
|
326
|
-
if (!nativeBinding) {
|
|
327
|
-
if (loadErrors.length > 0) throw new Error("Failed to load native binding", { cause: loadErrors });
|
|
328
|
-
throw new Error(`Failed to load native binding`);
|
|
329
|
-
}
|
|
330
|
-
module.exports = nativeBinding;
|
|
331
|
-
module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
|
|
332
|
-
module.exports.BindingBundleErrorEventData = nativeBinding.BindingBundleErrorEventData;
|
|
333
|
-
module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
|
|
334
|
-
module.exports.BindingError = nativeBinding.BindingError;
|
|
335
|
-
module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
|
|
336
|
-
module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
|
|
337
|
-
module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
|
|
338
|
-
module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
|
|
339
|
-
module.exports.BindingOutputs = nativeBinding.BindingOutputs;
|
|
340
|
-
module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
|
|
341
|
-
module.exports.BindingRenderedChunk = nativeBinding.BindingRenderedChunk;
|
|
342
|
-
module.exports.BindingRenderedChunkMeta = nativeBinding.BindingRenderedChunkMeta;
|
|
343
|
-
module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
|
|
344
|
-
module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
|
|
345
|
-
module.exports.BindingWatcher = nativeBinding.BindingWatcher;
|
|
346
|
-
module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
|
|
347
|
-
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
|
|
348
|
-
module.exports.Bundler = nativeBinding.Bundler;
|
|
349
|
-
module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
|
|
350
|
-
module.exports.ParseResult = nativeBinding.ParseResult;
|
|
351
|
-
module.exports.ResolverFactory = nativeBinding.ResolverFactory;
|
|
352
|
-
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
|
|
353
|
-
module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
|
|
354
|
-
module.exports.BindingJsx = nativeBinding.BindingJsx;
|
|
355
|
-
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
|
|
356
|
-
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
|
|
357
|
-
module.exports.EnforceExtension = nativeBinding.EnforceExtension;
|
|
358
|
-
module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
|
|
359
|
-
module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
|
|
360
|
-
module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
|
|
361
|
-
module.exports.FilterTokenKind = nativeBinding.FilterTokenKind;
|
|
362
|
-
module.exports.getBufferOffset = nativeBinding.getBufferOffset;
|
|
363
|
-
module.exports.HelperMode = nativeBinding.HelperMode;
|
|
364
|
-
module.exports.ImportNameKind = nativeBinding.ImportNameKind;
|
|
365
|
-
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
|
|
366
|
-
module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
|
|
367
|
-
module.exports.parseAsync = nativeBinding.parseAsync;
|
|
368
|
-
module.exports.parseSync = nativeBinding.parseSync;
|
|
369
|
-
module.exports.parseSyncRaw = nativeBinding.parseSyncRaw;
|
|
370
|
-
module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
|
|
371
|
-
module.exports.registerPlugins = nativeBinding.registerPlugins;
|
|
372
|
-
module.exports.Severity = nativeBinding.Severity;
|
|
373
|
-
module.exports.shutdownAsyncRuntime = nativeBinding.shutdownAsyncRuntime;
|
|
374
|
-
module.exports.startAsyncRuntime = nativeBinding.startAsyncRuntime;
|
|
375
|
-
module.exports.sync = nativeBinding.sync;
|
|
376
|
-
module.exports.transform = nativeBinding.transform;
|
|
377
|
-
} });
|
|
378
|
-
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region src/utils/code-frame.ts
|
|
381
|
-
function spaces(index) {
|
|
382
|
-
let result = "";
|
|
383
|
-
while (index--) result += " ";
|
|
384
|
-
return result;
|
|
385
|
-
}
|
|
386
|
-
function tabsToSpaces(value) {
|
|
387
|
-
return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
|
|
388
|
-
}
|
|
389
|
-
function getCodeFrame(source, line, column) {
|
|
390
|
-
let lines = source.split("\n");
|
|
391
|
-
if (line > lines.length) return "";
|
|
392
|
-
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
|
|
393
|
-
const frameStart = Math.max(0, line - 3);
|
|
394
|
-
let frameEnd = Math.min(line + 2, lines.length);
|
|
395
|
-
lines = lines.slice(frameStart, frameEnd);
|
|
396
|
-
while (!/\S/.test(lines[lines.length - 1])) {
|
|
397
|
-
lines.pop();
|
|
398
|
-
frameEnd -= 1;
|
|
399
|
-
}
|
|
400
|
-
const digits = String(frameEnd).length;
|
|
401
|
-
return lines.map((sourceLine, index) => {
|
|
402
|
-
const isErrorLine = frameStart + index + 1 === line;
|
|
403
|
-
let lineNumber = String(index + frameStart + 1);
|
|
404
|
-
while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
|
|
405
|
-
let displayedLine = tabsToSpaces(sourceLine);
|
|
406
|
-
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
|
|
407
|
-
if (isErrorLine) {
|
|
408
|
-
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
|
|
409
|
-
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
410
|
-
}
|
|
411
|
-
return `${lineNumber}: ${displayedLine}`;
|
|
412
|
-
}).join("\n");
|
|
413
|
-
}
|
|
414
|
-
var LINE_TRUNCATE_LENGTH, MIN_CHARACTERS_SHOWN_AFTER_LOCATION, ELLIPSIS;
|
|
415
|
-
var init_code_frame = __esm({ "src/utils/code-frame.ts"() {
|
|
416
|
-
LINE_TRUNCATE_LENGTH = 120;
|
|
417
|
-
MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
418
|
-
ELLIPSIS = "...";
|
|
419
|
-
} });
|
|
420
|
-
|
|
421
|
-
//#endregion
|
|
422
|
-
//#region src/log/locate-character/index.js
|
|
423
|
-
/** @typedef {import('./types').Location} Location */
|
|
424
|
-
/**
|
|
425
|
-
* @param {import('./types').Range} range
|
|
426
|
-
* @param {number} index
|
|
427
|
-
*/
|
|
428
|
-
function rangeContains(range, index) {
|
|
429
|
-
return range.start <= index && index < range.end;
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* @param {string} source
|
|
433
|
-
* @param {import('./types').Options} [options]
|
|
434
|
-
*/
|
|
435
|
-
function getLocator(source, options = {}) {
|
|
436
|
-
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
437
|
-
let start = 0;
|
|
438
|
-
const ranges = source.split("\n").map((line, i$1) => {
|
|
439
|
-
const end = start + line.length + 1;
|
|
440
|
-
/** @type {import('./types').Range} */
|
|
441
|
-
const range = {
|
|
442
|
-
start,
|
|
443
|
-
end,
|
|
444
|
-
line: i$1
|
|
445
|
-
};
|
|
446
|
-
start = end;
|
|
447
|
-
return range;
|
|
448
|
-
});
|
|
449
|
-
let i = 0;
|
|
450
|
-
/**
|
|
451
|
-
* @param {string | number} search
|
|
452
|
-
* @param {number} [index]
|
|
453
|
-
* @returns {Location | undefined}
|
|
454
|
-
*/
|
|
455
|
-
function locator(search, index) {
|
|
456
|
-
if (typeof search === "string") search = source.indexOf(search, index ?? 0);
|
|
457
|
-
if (search === -1) return void 0;
|
|
458
|
-
let range = ranges[i];
|
|
459
|
-
const d = search >= range.end ? 1 : -1;
|
|
460
|
-
while (range) {
|
|
461
|
-
if (rangeContains(range, search)) return {
|
|
462
|
-
line: offsetLine + range.line,
|
|
463
|
-
column: offsetColumn + search - range.start,
|
|
464
|
-
character: search
|
|
465
|
-
};
|
|
466
|
-
i += d;
|
|
467
|
-
range = ranges[i];
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return locator;
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* @param {string} source
|
|
474
|
-
* @param {string | number} search
|
|
475
|
-
* @param {import('./types').Options} [options]
|
|
476
|
-
* @returns {Location | undefined}
|
|
477
|
-
*/
|
|
478
|
-
function locate(source, search, options) {
|
|
479
|
-
return getLocator(source, options)(search, options && options.startIndex);
|
|
480
|
-
}
|
|
481
|
-
var init_locate_character = __esm({ "src/log/locate-character/index.js"() {} });
|
|
482
|
-
|
|
483
|
-
//#endregion
|
|
484
|
-
//#region src/log/logs.ts
|
|
485
|
-
function logParseError(message) {
|
|
486
|
-
return {
|
|
487
|
-
code: PARSE_ERROR,
|
|
488
|
-
message
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
function logInvalidLogPosition(pluginName) {
|
|
492
|
-
return {
|
|
493
|
-
code: INVALID_LOG_POSITION,
|
|
494
|
-
message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
function logInputHookInOutputPlugin(pluginName, hookName) {
|
|
498
|
-
return {
|
|
499
|
-
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
500
|
-
message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
function logCycleLoading(pluginName, moduleId) {
|
|
504
|
-
return {
|
|
505
|
-
code: CYCLE_LOADING,
|
|
506
|
-
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
function logMultiplyNotifyOption() {
|
|
510
|
-
return {
|
|
511
|
-
code: MULTIPLY_NOTIFY_OPTION,
|
|
512
|
-
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
function logPluginError(error$1, plugin, { hook, id } = {}) {
|
|
516
|
-
try {
|
|
517
|
-
const code = error$1.code;
|
|
518
|
-
if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
|
|
519
|
-
error$1.code = PLUGIN_ERROR;
|
|
520
|
-
error$1.plugin = plugin;
|
|
521
|
-
if (hook) error$1.hook = hook;
|
|
522
|
-
if (id) error$1.id = id;
|
|
523
|
-
} catch (_) {} finally {
|
|
524
|
-
return error$1;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
function error(base) {
|
|
528
|
-
if (!(base instanceof Error)) {
|
|
529
|
-
base = Object.assign(new Error(base.message), base);
|
|
530
|
-
Object.defineProperty(base, "name", {
|
|
531
|
-
value: "RollupError",
|
|
532
|
-
writable: true
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
throw base;
|
|
536
|
-
}
|
|
537
|
-
function augmentCodeLocation(properties, pos, source, id) {
|
|
538
|
-
if (typeof pos === "object") {
|
|
539
|
-
const { line, column } = pos;
|
|
540
|
-
properties.loc = {
|
|
541
|
-
column,
|
|
542
|
-
file: id,
|
|
543
|
-
line
|
|
544
|
-
};
|
|
545
|
-
} else {
|
|
546
|
-
properties.pos = pos;
|
|
547
|
-
const location = locate(source, pos, { offsetLine: 1 });
|
|
548
|
-
if (!location) return;
|
|
549
|
-
const { line, column } = location;
|
|
550
|
-
properties.loc = {
|
|
551
|
-
column,
|
|
552
|
-
file: id,
|
|
553
|
-
line
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
if (properties.frame === void 0) {
|
|
557
|
-
const { line, column } = properties.loc;
|
|
558
|
-
properties.frame = getCodeFrame(source, line, column);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
var INVALID_LOG_POSITION, PLUGIN_ERROR, INPUT_HOOK_IN_OUTPUT_PLUGIN, CYCLE_LOADING, MULTIPLY_NOTIFY_OPTION, PARSE_ERROR;
|
|
562
|
-
var init_logs = __esm({ "src/log/logs.ts"() {
|
|
563
|
-
init_code_frame();
|
|
564
|
-
init_locate_character();
|
|
565
|
-
INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR";
|
|
566
|
-
} });
|
|
567
|
-
|
|
568
|
-
//#endregion
|
|
569
|
-
//#region ../../node_modules/.pnpm/oxc-parser@0.72.0/node_modules/oxc-parser/wrap.mjs
|
|
570
|
-
function wrap$1(result) {
|
|
571
|
-
let program, module$1, comments, errors;
|
|
572
|
-
return {
|
|
573
|
-
get program() {
|
|
574
|
-
if (!program) program = jsonParseAst(result.program);
|
|
575
|
-
return program;
|
|
576
|
-
},
|
|
577
|
-
get module() {
|
|
578
|
-
if (!module$1) module$1 = result.module;
|
|
579
|
-
return module$1;
|
|
580
|
-
},
|
|
581
|
-
get comments() {
|
|
582
|
-
if (!comments) comments = result.comments;
|
|
583
|
-
return comments;
|
|
584
|
-
},
|
|
585
|
-
get errors() {
|
|
586
|
-
if (!errors) errors = result.errors;
|
|
587
|
-
return errors;
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
function jsonParseAst(programJson) {
|
|
592
|
-
const { node: program, fixes } = JSON.parse(programJson);
|
|
593
|
-
for (const fixPath of fixes) applyFix(program, fixPath);
|
|
594
|
-
return program;
|
|
595
|
-
}
|
|
596
|
-
function applyFix(program, fixPath) {
|
|
597
|
-
let node = program;
|
|
598
|
-
for (const key of fixPath) node = node[key];
|
|
599
|
-
if (node.bigint) node.value = BigInt(node.bigint);
|
|
600
|
-
else try {
|
|
601
|
-
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
602
|
-
} catch (_err) {}
|
|
603
|
-
}
|
|
604
|
-
var init_wrap = __esm({ "../../node_modules/.pnpm/oxc-parser@0.72.0/node_modules/oxc-parser/wrap.mjs"() {} });
|
|
605
|
-
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region src/parse-ast-index.ts
|
|
608
|
-
function wrap(result, sourceText) {
|
|
609
|
-
result = wrap$1(result);
|
|
610
|
-
if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
|
|
611
|
-
return result.program;
|
|
612
|
-
}
|
|
613
|
-
function normalizeParseError(sourceText, errors) {
|
|
614
|
-
let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
615
|
-
for (let i = 0; i < errors.length; i++) {
|
|
616
|
-
if (i >= 5) {
|
|
617
|
-
message += "\n...";
|
|
618
|
-
break;
|
|
619
|
-
}
|
|
620
|
-
const e = errors[i];
|
|
621
|
-
message += e.message + "\n" + e.labels.map((label) => {
|
|
622
|
-
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
623
|
-
if (!location) return;
|
|
624
|
-
return getCodeFrame(sourceText, location.line, location.column);
|
|
625
|
-
}).filter(Boolean).join("\n");
|
|
626
|
-
}
|
|
627
|
-
return error(logParseError(message));
|
|
628
|
-
}
|
|
629
|
-
function parseAst(sourceText, options, filename) {
|
|
630
|
-
return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
|
|
631
|
-
...defaultParserOptions,
|
|
632
|
-
...options
|
|
633
|
-
}), sourceText);
|
|
634
|
-
}
|
|
635
|
-
async function parseAstAsync(sourceText, options, filename) {
|
|
636
|
-
return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
|
|
637
|
-
...defaultParserOptions,
|
|
638
|
-
...options
|
|
639
|
-
}), sourceText);
|
|
640
|
-
}
|
|
641
|
-
var import_binding, defaultParserOptions;
|
|
642
|
-
var init_parse_ast_index = __esm({ "src/parse-ast-index.ts"() {
|
|
643
|
-
import_binding = __toESM(require_binding());
|
|
644
|
-
init_locate_character();
|
|
645
|
-
init_logs();
|
|
646
|
-
init_code_frame();
|
|
647
|
-
init_wrap();
|
|
648
|
-
defaultParserOptions = {
|
|
649
|
-
lang: "js",
|
|
650
|
-
preserveParens: false
|
|
651
|
-
};
|
|
652
|
-
} });
|
|
653
|
-
|
|
654
|
-
//#endregion
|
|
655
|
-
export { augmentCodeLocation, error, init_logs, init_parse_ast_index, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, parseAstAsync, require_binding };
|