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