rolldown 1.0.0-beta.16 → 1.0.0-beta.18

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 +6 -6
  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 -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-D__94uwg.d.cts} +13 -462
  27. package/dist/shared/{binding-C_9au5Eg.d.mts → binding-DwMf_OTa.d.mts} +13 -462
  28. package/dist/shared/{define-config-DMWHsgSt.d.mts → define-config-CXjwrGWr.d.cts} +70 -10
  29. package/dist/shared/{define-config-CAyC9-af.d.cts → define-config-pMM2R7Js.d.mts} +70 -10
  30. package/dist/shared/{load-config-BniS-jT_.cjs → load-config-BeHXwv7L.cjs} +1 -1
  31. package/dist/shared/{load-config-BT5Ts430.mjs → load-config-D2fi4c8T.mjs} +14 -19
  32. package/dist/shared/{misc-DGAe2XOW.mjs → misc-BN0nse6C.mjs} +1 -4
  33. package/dist/shared/parse-ast-index-BbUPYP6B.cjs +738 -0
  34. package/dist/shared/parse-ast-index-QIuIuIzO.mjs +616 -0
  35. package/dist/shared/prompt-C5jz26Zn.mjs +852 -0
  36. package/dist/shared/{src-1lPDqeuR.cjs → src-BHe-J6xJ.cjs} +44 -48
  37. package/dist/shared/{src-Cv4_zurW.mjs → src-Bob3e8Hh.mjs} +1136 -1394
  38. package/package.json +21 -21
  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,701 +0,0 @@
1
- const require_chunk = require('./chunk-DDkG_k5U.cjs');
2
-
3
- //#region src/webcontainer-fallback.js
4
- var require_webcontainer_fallback = require_chunk.__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 = require_chunk.__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
- const LINE_TRUNCATE_LENGTH = 120;
394
- const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
395
- const ELLIPSIS = "...";
396
- function getCodeFrame(source, line, column) {
397
- let lines = source.split("\n");
398
- if (line > lines.length) return "";
399
- const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
400
- const frameStart = Math.max(0, line - 3);
401
- let frameEnd = Math.min(line + 2, lines.length);
402
- lines = lines.slice(frameStart, frameEnd);
403
- while (!/\S/.test(lines[lines.length - 1])) {
404
- lines.pop();
405
- frameEnd -= 1;
406
- }
407
- const digits = String(frameEnd).length;
408
- return lines.map((sourceLine, index) => {
409
- const isErrorLine = frameStart + index + 1 === line;
410
- let lineNumber = String(index + frameStart + 1);
411
- while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
412
- let displayedLine = tabsToSpaces(sourceLine);
413
- if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
414
- if (isErrorLine) {
415
- const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
416
- return `${lineNumber}: ${displayedLine}\n${indicator}`;
417
- }
418
- return `${lineNumber}: ${displayedLine}`;
419
- }).join("\n");
420
- }
421
-
422
- //#endregion
423
- //#region src/log/locate-character/index.js
424
- /** @typedef {import('./types').Location} Location */
425
- /**
426
- * @param {import('./types').Range} range
427
- * @param {number} index
428
- */
429
- function rangeContains(range, index) {
430
- return range.start <= index && index < range.end;
431
- }
432
- /**
433
- * @param {string} source
434
- * @param {import('./types').Options} [options]
435
- */
436
- function getLocator(source, options = {}) {
437
- const { offsetLine = 0, offsetColumn = 0 } = options;
438
- let start = 0;
439
- const ranges = source.split("\n").map((line, i$1) => {
440
- const end = start + line.length + 1;
441
- /** @type {import('./types').Range} */
442
- const range = {
443
- start,
444
- end,
445
- line: i$1
446
- };
447
- start = end;
448
- return range;
449
- });
450
- let i = 0;
451
- /**
452
- * @param {string | number} search
453
- * @param {number} [index]
454
- * @returns {Location | undefined}
455
- */
456
- function locator(search, index) {
457
- if (typeof search === "string") search = source.indexOf(search, index ?? 0);
458
- if (search === -1) return void 0;
459
- let range = ranges[i];
460
- const d = search >= range.end ? 1 : -1;
461
- while (range) {
462
- if (rangeContains(range, search)) return {
463
- line: offsetLine + range.line,
464
- column: offsetColumn + search - range.start,
465
- character: search
466
- };
467
- i += d;
468
- range = ranges[i];
469
- }
470
- }
471
- return locator;
472
- }
473
- /**
474
- * @param {string} source
475
- * @param {string | number} search
476
- * @param {import('./types').Options} [options]
477
- * @returns {Location | undefined}
478
- */
479
- function locate(source, search, options) {
480
- return getLocator(source, options)(search, options && options.startIndex);
481
- }
482
-
483
- //#endregion
484
- //#region src/log/logs.ts
485
- const 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";
486
- function logParseError(message) {
487
- return {
488
- code: PARSE_ERROR,
489
- message
490
- };
491
- }
492
- function logInvalidLogPosition(pluginName) {
493
- return {
494
- code: INVALID_LOG_POSITION,
495
- 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.`
496
- };
497
- }
498
- function logInputHookInOutputPlugin(pluginName, hookName) {
499
- return {
500
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
501
- 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.`
502
- };
503
- }
504
- function logCycleLoading(pluginName, moduleId) {
505
- return {
506
- code: CYCLE_LOADING,
507
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
508
- };
509
- }
510
- function logMultiplyNotifyOption() {
511
- return {
512
- code: MULTIPLY_NOTIFY_OPTION,
513
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`
514
- };
515
- }
516
- function logPluginError(error$1, plugin, { hook, id } = {}) {
517
- try {
518
- const code = error$1.code;
519
- if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
520
- error$1.code = PLUGIN_ERROR;
521
- error$1.plugin = plugin;
522
- if (hook) error$1.hook = hook;
523
- if (id) error$1.id = id;
524
- } catch (_) {} finally {
525
- return error$1;
526
- }
527
- }
528
- function error(base) {
529
- if (!(base instanceof Error)) {
530
- base = Object.assign(new Error(base.message), base);
531
- Object.defineProperty(base, "name", {
532
- value: "RollupError",
533
- writable: true
534
- });
535
- }
536
- throw base;
537
- }
538
- function augmentCodeLocation(properties, pos, source, id) {
539
- if (typeof pos === "object") {
540
- const { line, column } = pos;
541
- properties.loc = {
542
- column,
543
- file: id,
544
- line
545
- };
546
- } else {
547
- properties.pos = pos;
548
- const location = locate(source, pos, { offsetLine: 1 });
549
- if (!location) return;
550
- const { line, column } = location;
551
- properties.loc = {
552
- column,
553
- file: id,
554
- line
555
- };
556
- }
557
- if (properties.frame === void 0) {
558
- const { line, column } = properties.loc;
559
- properties.frame = getCodeFrame(source, line, column);
560
- }
561
- }
562
-
563
- //#endregion
564
- //#region ../../node_modules/.pnpm/oxc-parser@0.73.0/node_modules/oxc-parser/wrap.mjs
565
- function wrap$1(result) {
566
- let program, module$1, comments, errors;
567
- return {
568
- get program() {
569
- if (!program) program = jsonParseAst(result.program);
570
- return program;
571
- },
572
- get module() {
573
- if (!module$1) module$1 = result.module;
574
- return module$1;
575
- },
576
- get comments() {
577
- if (!comments) comments = result.comments;
578
- return comments;
579
- },
580
- get errors() {
581
- if (!errors) errors = result.errors;
582
- return errors;
583
- }
584
- };
585
- }
586
- function jsonParseAst(programJson) {
587
- const { node: program, fixes } = JSON.parse(programJson);
588
- for (const fixPath of fixes) applyFix(program, fixPath);
589
- return program;
590
- }
591
- function applyFix(program, fixPath) {
592
- let node = program;
593
- for (const key of fixPath) node = node[key];
594
- if (node.bigint) node.value = BigInt(node.bigint);
595
- else try {
596
- node.value = RegExp(node.regex.pattern, node.regex.flags);
597
- } catch (_err) {}
598
- }
599
-
600
- //#endregion
601
- //#region src/parse-ast-index.ts
602
- var import_binding = require_chunk.__toESM(require_binding());
603
- function wrap(result, sourceText) {
604
- result = wrap$1(result);
605
- if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
606
- return result.program;
607
- }
608
- function normalizeParseError(sourceText, errors) {
609
- let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
610
- for (let i = 0; i < errors.length; i++) {
611
- if (i >= 5) {
612
- message += "\n...";
613
- break;
614
- }
615
- const e = errors[i];
616
- message += e.message + "\n" + e.labels.map((label) => {
617
- const location = locate(sourceText, label.start, { offsetLine: 1 });
618
- if (!location) return;
619
- return getCodeFrame(sourceText, location.line, location.column);
620
- }).filter(Boolean).join("\n");
621
- }
622
- return error(logParseError(message));
623
- }
624
- const defaultParserOptions = {
625
- lang: "js",
626
- preserveParens: false
627
- };
628
- function parseAst(sourceText, options, filename) {
629
- return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
630
- ...defaultParserOptions,
631
- ...options
632
- }), sourceText);
633
- }
634
- async function parseAstAsync(sourceText, options, filename) {
635
- return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
636
- ...defaultParserOptions,
637
- ...options
638
- }), sourceText);
639
- }
640
-
641
- //#endregion
642
- Object.defineProperty(exports, 'augmentCodeLocation', {
643
- enumerable: true,
644
- get: function () {
645
- return augmentCodeLocation;
646
- }
647
- });
648
- Object.defineProperty(exports, 'error', {
649
- enumerable: true,
650
- get: function () {
651
- return error;
652
- }
653
- });
654
- Object.defineProperty(exports, 'logCycleLoading', {
655
- enumerable: true,
656
- get: function () {
657
- return logCycleLoading;
658
- }
659
- });
660
- Object.defineProperty(exports, 'logInputHookInOutputPlugin', {
661
- enumerable: true,
662
- get: function () {
663
- return logInputHookInOutputPlugin;
664
- }
665
- });
666
- Object.defineProperty(exports, 'logInvalidLogPosition', {
667
- enumerable: true,
668
- get: function () {
669
- return logInvalidLogPosition;
670
- }
671
- });
672
- Object.defineProperty(exports, 'logMultiplyNotifyOption', {
673
- enumerable: true,
674
- get: function () {
675
- return logMultiplyNotifyOption;
676
- }
677
- });
678
- Object.defineProperty(exports, 'logPluginError', {
679
- enumerable: true,
680
- get: function () {
681
- return logPluginError;
682
- }
683
- });
684
- Object.defineProperty(exports, 'parseAst', {
685
- enumerable: true,
686
- get: function () {
687
- return parseAst;
688
- }
689
- });
690
- Object.defineProperty(exports, 'parseAstAsync', {
691
- enumerable: true,
692
- get: function () {
693
- return parseAstAsync;
694
- }
695
- });
696
- Object.defineProperty(exports, 'require_binding', {
697
- enumerable: true,
698
- get: function () {
699
- return require_binding;
700
- }
701
- });