rolldown 1.0.0-beta.15 → 1.0.0-beta.17

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.
Files changed (44) hide show
  1. package/dist/cli.cjs +8 -8
  2. package/dist/cli.mjs +1042 -1081
  3. package/dist/config.cjs +3 -3
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +4 -5
  7. package/dist/experimental-index.cjs +7 -31
  8. package/dist/experimental-index.d.cts +2 -2
  9. package/dist/experimental-index.d.mts +2 -2
  10. package/dist/experimental-index.mjs +4 -22
  11. package/dist/experimental-runtime-types.d.ts +52 -0
  12. package/dist/filter-index.d.cts +2 -2
  13. package/dist/filter-index.d.mts +2 -2
  14. package/dist/filter-index.mjs +1 -2
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.d.cts +2 -2
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.mjs +3 -4
  19. package/dist/parallel-plugin-worker.cjs +3 -4
  20. package/dist/parallel-plugin-worker.mjs +27 -34
  21. package/dist/parallel-plugin.d.cts +2 -2
  22. package/dist/parallel-plugin.d.mts +2 -2
  23. package/dist/parse-ast-index.cjs +1 -1
  24. package/dist/parse-ast-index.d.cts +1 -1
  25. package/dist/parse-ast-index.d.mts +1 -1
  26. package/dist/parse-ast-index.mjs +1 -2
  27. package/dist/shared/{binding-CZdobbZA.d.cts → binding-CWvDTpOw.d.mts} +23 -15
  28. package/dist/shared/{binding-Dze8QVpf.d.mts → binding-um3VI33z.d.cts} +23 -15
  29. package/dist/shared/{define-config-De_1kjGz.d.mts → define-config-Cm86JHb7.d.mts} +73 -12
  30. package/dist/shared/{define-config-BE-fkZNW.d.cts → define-config-POPyhxOq.d.cts} +73 -12
  31. package/dist/shared/{load-config-Bq6nGoUg.cjs → load-config-B4zzmrcW.cjs} +1 -1
  32. package/dist/shared/{load-config-BOcke1T-.mjs → load-config-BlOqMlge.mjs} +14 -19
  33. package/dist/shared/{misc-DGAe2XOW.mjs → misc-BN0nse6C.mjs} +1 -4
  34. package/dist/shared/parse-ast-index-BpqxVgDm.mjs +616 -0
  35. package/dist/shared/parse-ast-index-XFcW-g8N.cjs +738 -0
  36. package/dist/shared/prompt-C5jz26Zn.mjs +852 -0
  37. package/dist/shared/{prompt-8EeOGx1_.cjs → prompt-QNI93ne7.cjs} +2 -2
  38. package/dist/shared/{src-aJubL6dq.cjs → src-C98Q0NLX.cjs} +63 -55
  39. package/dist/shared/{src-DBOqhEP1.mjs → src-CuIbdNSi.mjs} +1146 -1391
  40. package/package.json +22 -22
  41. package/dist/shared/chunk--iN_1bjD.mjs +0 -33
  42. package/dist/shared/parse-ast-index-BAuPesgO.mjs +0 -658
  43. package/dist/shared/parse-ast-index-C53MhHqY.cjs +0 -700
  44. package/dist/shared/prompt-Dc0i9ubg.mjs +0 -854
@@ -1,658 +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.Severity = nativeBinding.Severity;
332
- module.exports.ParseResult = nativeBinding.ParseResult;
333
- module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
334
- module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
335
- module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
336
- module.exports.getBufferOffset = nativeBinding.getBufferOffset;
337
- module.exports.ImportNameKind = nativeBinding.ImportNameKind;
338
- module.exports.parseAsync = nativeBinding.parseAsync;
339
- module.exports.parseAsyncRaw = nativeBinding.parseAsyncRaw;
340
- module.exports.parseSync = nativeBinding.parseSync;
341
- module.exports.parseSyncRaw = nativeBinding.parseSyncRaw;
342
- module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
343
- module.exports.ResolverFactory = nativeBinding.ResolverFactory;
344
- module.exports.EnforceExtension = nativeBinding.EnforceExtension;
345
- module.exports.ModuleType = nativeBinding.ModuleType;
346
- module.exports.sync = nativeBinding.sync;
347
- module.exports.HelperMode = nativeBinding.HelperMode;
348
- module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
349
- module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
350
- module.exports.transform = nativeBinding.transform;
351
- module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
352
- module.exports.BindingBundleErrorEventData = nativeBinding.BindingBundleErrorEventData;
353
- module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
354
- module.exports.BindingError = nativeBinding.BindingError;
355
- module.exports.BindingHmrOutput = nativeBinding.BindingHmrOutput;
356
- module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
357
- module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
358
- module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
359
- module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
360
- module.exports.BindingOutputs = nativeBinding.BindingOutputs;
361
- module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
362
- module.exports.BindingRenderedChunk = nativeBinding.BindingRenderedChunk;
363
- module.exports.BindingRenderedChunkMeta = nativeBinding.BindingRenderedChunkMeta;
364
- module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
365
- module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
366
- module.exports.BindingWatcher = nativeBinding.BindingWatcher;
367
- module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
368
- module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
369
- module.exports.Bundler = nativeBinding.Bundler;
370
- module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
371
- module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
372
- module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
373
- module.exports.BindingJsx = nativeBinding.BindingJsx;
374
- module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
375
- module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
376
- module.exports.FilterTokenKind = nativeBinding.FilterTokenKind;
377
- module.exports.registerPlugins = nativeBinding.registerPlugins;
378
- module.exports.shutdownAsyncRuntime = nativeBinding.shutdownAsyncRuntime;
379
- module.exports.startAsyncRuntime = nativeBinding.startAsyncRuntime;
380
- } });
381
-
382
- //#endregion
383
- //#region src/utils/code-frame.ts
384
- function spaces(index) {
385
- let result = "";
386
- while (index--) result += " ";
387
- return result;
388
- }
389
- function tabsToSpaces(value) {
390
- return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
391
- }
392
- function getCodeFrame(source, line, column) {
393
- let lines = source.split("\n");
394
- if (line > lines.length) return "";
395
- const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
396
- const frameStart = Math.max(0, line - 3);
397
- let frameEnd = Math.min(line + 2, lines.length);
398
- lines = lines.slice(frameStart, frameEnd);
399
- while (!/\S/.test(lines[lines.length - 1])) {
400
- lines.pop();
401
- frameEnd -= 1;
402
- }
403
- const digits = String(frameEnd).length;
404
- return lines.map((sourceLine, index) => {
405
- const isErrorLine = frameStart + index + 1 === line;
406
- let lineNumber = String(index + frameStart + 1);
407
- while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
408
- let displayedLine = tabsToSpaces(sourceLine);
409
- if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
410
- if (isErrorLine) {
411
- const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
412
- return `${lineNumber}: ${displayedLine}\n${indicator}`;
413
- }
414
- return `${lineNumber}: ${displayedLine}`;
415
- }).join("\n");
416
- }
417
- var LINE_TRUNCATE_LENGTH, MIN_CHARACTERS_SHOWN_AFTER_LOCATION, ELLIPSIS;
418
- var init_code_frame = __esm({ "src/utils/code-frame.ts"() {
419
- LINE_TRUNCATE_LENGTH = 120;
420
- MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
421
- ELLIPSIS = "...";
422
- } });
423
-
424
- //#endregion
425
- //#region src/log/locate-character/index.js
426
- /** @typedef {import('./types').Location} Location */
427
- /**
428
- * @param {import('./types').Range} range
429
- * @param {number} index
430
- */
431
- function rangeContains(range, index) {
432
- return range.start <= index && index < range.end;
433
- }
434
- /**
435
- * @param {string} source
436
- * @param {import('./types').Options} [options]
437
- */
438
- function getLocator(source, options = {}) {
439
- const { offsetLine = 0, offsetColumn = 0 } = options;
440
- let start = 0;
441
- const ranges = source.split("\n").map((line, i$1) => {
442
- const end = start + line.length + 1;
443
- /** @type {import('./types').Range} */
444
- const range = {
445
- start,
446
- end,
447
- line: i$1
448
- };
449
- start = end;
450
- return range;
451
- });
452
- let i = 0;
453
- /**
454
- * @param {string | number} search
455
- * @param {number} [index]
456
- * @returns {Location | undefined}
457
- */
458
- function locator(search, index) {
459
- if (typeof search === "string") search = source.indexOf(search, index ?? 0);
460
- if (search === -1) return void 0;
461
- let range = ranges[i];
462
- const d = search >= range.end ? 1 : -1;
463
- while (range) {
464
- if (rangeContains(range, search)) return {
465
- line: offsetLine + range.line,
466
- column: offsetColumn + search - range.start,
467
- character: search
468
- };
469
- i += d;
470
- range = ranges[i];
471
- }
472
- }
473
- return locator;
474
- }
475
- /**
476
- * @param {string} source
477
- * @param {string | number} search
478
- * @param {import('./types').Options} [options]
479
- * @returns {Location | undefined}
480
- */
481
- function locate(source, search, options) {
482
- return getLocator(source, options)(search, options && options.startIndex);
483
- }
484
- var init_locate_character = __esm({ "src/log/locate-character/index.js"() {} });
485
-
486
- //#endregion
487
- //#region src/log/logs.ts
488
- function logParseError(message) {
489
- return {
490
- code: PARSE_ERROR,
491
- message
492
- };
493
- }
494
- function logInvalidLogPosition(pluginName) {
495
- return {
496
- code: INVALID_LOG_POSITION,
497
- 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.`
498
- };
499
- }
500
- function logInputHookInOutputPlugin(pluginName, hookName) {
501
- return {
502
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
503
- 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.`
504
- };
505
- }
506
- function logCycleLoading(pluginName, moduleId) {
507
- return {
508
- code: CYCLE_LOADING,
509
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
510
- };
511
- }
512
- function logMultiplyNotifyOption() {
513
- return {
514
- code: MULTIPLY_NOTIFY_OPTION,
515
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`
516
- };
517
- }
518
- function logPluginError(error$1, plugin, { hook, id } = {}) {
519
- try {
520
- const code = error$1.code;
521
- if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
522
- error$1.code = PLUGIN_ERROR;
523
- error$1.plugin = plugin;
524
- if (hook) error$1.hook = hook;
525
- if (id) error$1.id = id;
526
- } catch (_) {} finally {
527
- return error$1;
528
- }
529
- }
530
- function error(base) {
531
- if (!(base instanceof Error)) {
532
- base = Object.assign(new Error(base.message), base);
533
- Object.defineProperty(base, "name", {
534
- value: "RollupError",
535
- writable: true
536
- });
537
- }
538
- throw base;
539
- }
540
- function augmentCodeLocation(properties, pos, source, id) {
541
- if (typeof pos === "object") {
542
- const { line, column } = pos;
543
- properties.loc = {
544
- column,
545
- file: id,
546
- line
547
- };
548
- } else {
549
- properties.pos = pos;
550
- const location = locate(source, pos, { offsetLine: 1 });
551
- if (!location) return;
552
- const { line, column } = location;
553
- properties.loc = {
554
- column,
555
- file: id,
556
- line
557
- };
558
- }
559
- if (properties.frame === void 0) {
560
- const { line, column } = properties.loc;
561
- properties.frame = getCodeFrame(source, line, column);
562
- }
563
- }
564
- var INVALID_LOG_POSITION, PLUGIN_ERROR, INPUT_HOOK_IN_OUTPUT_PLUGIN, CYCLE_LOADING, MULTIPLY_NOTIFY_OPTION, PARSE_ERROR;
565
- var init_logs = __esm({ "src/log/logs.ts"() {
566
- init_code_frame();
567
- init_locate_character();
568
- 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";
569
- } });
570
-
571
- //#endregion
572
- //#region ../../node_modules/.pnpm/oxc-parser@0.72.3/node_modules/oxc-parser/wrap.mjs
573
- function wrap$1(result) {
574
- let program, module$1, comments, errors;
575
- return {
576
- get program() {
577
- if (!program) program = jsonParseAst(result.program);
578
- return program;
579
- },
580
- get module() {
581
- if (!module$1) module$1 = result.module;
582
- return module$1;
583
- },
584
- get comments() {
585
- if (!comments) comments = result.comments;
586
- return comments;
587
- },
588
- get errors() {
589
- if (!errors) errors = result.errors;
590
- return errors;
591
- }
592
- };
593
- }
594
- function jsonParseAst(programJson) {
595
- const { node: program, fixes } = JSON.parse(programJson);
596
- for (const fixPath of fixes) applyFix(program, fixPath);
597
- return program;
598
- }
599
- function applyFix(program, fixPath) {
600
- let node = program;
601
- for (const key of fixPath) node = node[key];
602
- if (node.bigint) node.value = BigInt(node.bigint);
603
- else try {
604
- node.value = RegExp(node.regex.pattern, node.regex.flags);
605
- } catch (_err) {}
606
- }
607
- var init_wrap = __esm({ "../../node_modules/.pnpm/oxc-parser@0.72.3/node_modules/oxc-parser/wrap.mjs"() {} });
608
-
609
- //#endregion
610
- //#region src/parse-ast-index.ts
611
- function wrap(result, sourceText) {
612
- result = wrap$1(result);
613
- if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
614
- return result.program;
615
- }
616
- function normalizeParseError(sourceText, errors) {
617
- let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
618
- for (let i = 0; i < errors.length; i++) {
619
- if (i >= 5) {
620
- message += "\n...";
621
- break;
622
- }
623
- const e = errors[i];
624
- message += e.message + "\n" + e.labels.map((label) => {
625
- const location = locate(sourceText, label.start, { offsetLine: 1 });
626
- if (!location) return;
627
- return getCodeFrame(sourceText, location.line, location.column);
628
- }).filter(Boolean).join("\n");
629
- }
630
- return error(logParseError(message));
631
- }
632
- function parseAst(sourceText, options, filename) {
633
- return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
634
- ...defaultParserOptions,
635
- ...options
636
- }), sourceText);
637
- }
638
- async function parseAstAsync(sourceText, options, filename) {
639
- return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
640
- ...defaultParserOptions,
641
- ...options
642
- }), sourceText);
643
- }
644
- var import_binding, defaultParserOptions;
645
- var init_parse_ast_index = __esm({ "src/parse-ast-index.ts"() {
646
- import_binding = __toESM(require_binding());
647
- init_locate_character();
648
- init_logs();
649
- init_code_frame();
650
- init_wrap();
651
- defaultParserOptions = {
652
- lang: "js",
653
- preserveParens: false
654
- };
655
- } });
656
-
657
- //#endregion
658
- export { augmentCodeLocation, error, init_logs, init_parse_ast_index, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, parseAstAsync, require_binding };