rolldown 1.0.0-beta.9-commit.0ec9e7d → 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.
Files changed (68) hide show
  1. package/README.md +11 -0
  2. package/bin/cli.mjs +1 -0
  3. package/dist/cli-setup.mjs +17 -0
  4. package/dist/cli.mjs +1085 -1281
  5. package/dist/config.d.mts +2 -4
  6. package/dist/config.mjs +8 -5
  7. package/dist/experimental-index.d.mts +161 -76
  8. package/dist/experimental-index.mjs +227 -61
  9. package/dist/experimental-runtime-types.d.ts +98 -0
  10. package/dist/filter-index.d.mts +196 -4
  11. package/dist/filter-index.mjs +328 -4
  12. package/dist/get-log-filter.d.mts +7 -0
  13. package/dist/get-log-filter.mjs +48 -0
  14. package/dist/index.d.mts +4 -4
  15. package/dist/index.mjs +56 -5
  16. package/dist/parallel-plugin-worker.mjs +27 -33
  17. package/dist/parallel-plugin.d.mts +7 -8
  18. package/dist/parse-ast-index.d.mts +4 -5
  19. package/dist/parse-ast-index.mjs +2 -2
  20. package/dist/plugins-index.d.mts +30 -0
  21. package/dist/plugins-index.mjs +40 -0
  22. package/dist/shared/binding-B92Lq__Q.d.mts +1687 -0
  23. package/dist/shared/binding-C-UNREnT.mjs +585 -0
  24. package/dist/shared/bindingify-input-options-Cb-01HR1.mjs +2233 -0
  25. package/dist/shared/constructors-D_KFsTQ-.d.mts +28 -0
  26. package/dist/shared/constructors-aZ82R2dj.mjs +61 -0
  27. package/dist/shared/define-config-BVG4QvnP.mjs +7 -0
  28. package/dist/shared/define-config-DO4TBkJV.d.mts +3457 -0
  29. package/dist/shared/{load-config-Dll-92l5.mjs → load-config-D6cey0o1.mjs} +23 -33
  30. package/dist/shared/logging-wIy4zY9I.d.mts +50 -0
  31. package/dist/shared/logs-NH298mHo.mjs +183 -0
  32. package/dist/shared/{misc-DGAe2XOW.mjs → misc-CCZIsXVO.mjs} +1 -7
  33. package/dist/shared/normalize-string-or-regex-Dq50a7l9.mjs +61 -0
  34. package/dist/shared/parse-ast-index-B6LAhWD8.mjs +99 -0
  35. package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-tlfjalEt.mjs} +301 -308
  36. package/dist/shared/rolldown-CIC_OHw3.mjs +42 -0
  37. package/dist/shared/rolldown-build-KB1YaNe-.mjs +2369 -0
  38. package/dist/shared/watch-B2WRkpw2.mjs +379 -0
  39. package/package.json +86 -98
  40. package/dist/cli.cjs +0 -1748
  41. package/dist/config.cjs +0 -12
  42. package/dist/config.d.cts +0 -12
  43. package/dist/experimental-index.cjs +0 -132
  44. package/dist/experimental-index.d.cts +0 -96
  45. package/dist/filter-index.cjs +0 -105
  46. package/dist/filter-index.d.cts +0 -5
  47. package/dist/index.cjs +0 -9
  48. package/dist/index.d.cts +0 -4
  49. package/dist/parallel-plugin-worker.cjs +0 -33
  50. package/dist/parallel-plugin-worker.d.cts +0 -1
  51. package/dist/parallel-plugin.cjs +0 -8
  52. package/dist/parallel-plugin.d.cts +0 -15
  53. package/dist/parse-ast-index.cjs +0 -4
  54. package/dist/parse-ast-index.d.cts +0 -9
  55. package/dist/shared/binding.d-Dz3qQrbl.d.mts +0 -1682
  56. package/dist/shared/binding.d-QXzDcVmm.d.cts +0 -1682
  57. package/dist/shared/chunk--iN_1bjD.mjs +0 -33
  58. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  59. package/dist/shared/define-config.d-CUcDq_vm.d.cts +0 -1080
  60. package/dist/shared/define-config.d-qV1PzX_C.d.mts +0 -1080
  61. package/dist/shared/load-config-Bx9W9x2a.cjs +0 -125
  62. package/dist/shared/misc-BKp5iIef.cjs +0 -67
  63. package/dist/shared/parse-ast-index-0m6JgGc9.mjs +0 -655
  64. package/dist/shared/parse-ast-index-Cn_efzjO.cjs +0 -697
  65. package/dist/shared/prompt-uGrwvyp0.mjs +0 -854
  66. package/dist/shared/src-B4EklR3U.mjs +0 -4704
  67. package/dist/shared/src-BzFe16tX.cjs +0 -4654
  68. /package/dist/{cli.d.cts → cli-setup.d.mts} +0 -0
@@ -1,697 +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(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
- const LINE_TRUNCATE_LENGTH = 120;
390
- const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
391
- const ELLIPSIS = "...";
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
-
418
- //#endregion
419
- //#region src/log/locate-character/index.js
420
- /** @typedef {import('./types').Location} Location */
421
- /**
422
- * @param {import('./types').Range} range
423
- * @param {number} index
424
- */
425
- function rangeContains(range, index) {
426
- return range.start <= index && index < range.end;
427
- }
428
- /**
429
- * @param {string} source
430
- * @param {import('./types').Options} [options]
431
- */
432
- function getLocator(source, options = {}) {
433
- const { offsetLine = 0, offsetColumn = 0 } = options;
434
- let start = 0;
435
- const ranges = source.split("\n").map((line, i$1) => {
436
- const end = start + line.length + 1;
437
- /** @type {import('./types').Range} */
438
- const range = {
439
- start,
440
- end,
441
- line: i$1
442
- };
443
- start = end;
444
- return range;
445
- });
446
- let i = 0;
447
- /**
448
- * @param {string | number} search
449
- * @param {number} [index]
450
- * @returns {Location | undefined}
451
- */
452
- function locator(search, index) {
453
- if (typeof search === "string") search = source.indexOf(search, index ?? 0);
454
- if (search === -1) return void 0;
455
- let range = ranges[i];
456
- const d = search >= range.end ? 1 : -1;
457
- while (range) {
458
- if (rangeContains(range, search)) return {
459
- line: offsetLine + range.line,
460
- column: offsetColumn + search - range.start,
461
- character: search
462
- };
463
- i += d;
464
- range = ranges[i];
465
- }
466
- }
467
- return locator;
468
- }
469
- /**
470
- * @param {string} source
471
- * @param {string | number} search
472
- * @param {import('./types').Options} [options]
473
- * @returns {Location | undefined}
474
- */
475
- function locate(source, search, options) {
476
- return getLocator(source, options)(search, options && options.startIndex);
477
- }
478
-
479
- //#endregion
480
- //#region src/log/logs.ts
481
- 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";
482
- function logParseError(message) {
483
- return {
484
- code: PARSE_ERROR,
485
- message
486
- };
487
- }
488
- function logInvalidLogPosition(pluginName) {
489
- return {
490
- code: INVALID_LOG_POSITION,
491
- 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.`
492
- };
493
- }
494
- function logInputHookInOutputPlugin(pluginName, hookName) {
495
- return {
496
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
497
- 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.`
498
- };
499
- }
500
- function logCycleLoading(pluginName, moduleId) {
501
- return {
502
- code: CYCLE_LOADING,
503
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
504
- };
505
- }
506
- function logMultiplyNotifyOption() {
507
- return {
508
- code: MULTIPLY_NOTIFY_OPTION,
509
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`
510
- };
511
- }
512
- function logPluginError(error$1, plugin, { hook, id } = {}) {
513
- try {
514
- const code = error$1.code;
515
- if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
516
- error$1.code = PLUGIN_ERROR;
517
- error$1.plugin = plugin;
518
- if (hook) error$1.hook = hook;
519
- if (id) error$1.id = id;
520
- } catch (_) {} finally {
521
- return error$1;
522
- }
523
- }
524
- function error(base) {
525
- if (!(base instanceof Error)) {
526
- base = Object.assign(new Error(base.message), base);
527
- Object.defineProperty(base, "name", {
528
- value: "RollupError",
529
- writable: true
530
- });
531
- }
532
- throw base;
533
- }
534
- function augmentCodeLocation(properties, pos, source, id) {
535
- if (typeof pos === "object") {
536
- const { line, column } = pos;
537
- properties.loc = {
538
- column,
539
- file: id,
540
- line
541
- };
542
- } else {
543
- properties.pos = pos;
544
- const location = locate(source, pos, { offsetLine: 1 });
545
- if (!location) return;
546
- const { line, column } = location;
547
- properties.loc = {
548
- column,
549
- file: id,
550
- line
551
- };
552
- }
553
- if (properties.frame === void 0) {
554
- const { line, column } = properties.loc;
555
- properties.frame = getCodeFrame(source, line, column);
556
- }
557
- }
558
-
559
- //#endregion
560
- //#region ../../node_modules/.pnpm/oxc-parser@0.72.0/node_modules/oxc-parser/wrap.mjs
561
- function wrap$1(result) {
562
- let program, module$1, comments, errors;
563
- return {
564
- get program() {
565
- if (!program) program = jsonParseAst(result.program);
566
- return program;
567
- },
568
- get module() {
569
- if (!module$1) module$1 = result.module;
570
- return module$1;
571
- },
572
- get comments() {
573
- if (!comments) comments = result.comments;
574
- return comments;
575
- },
576
- get errors() {
577
- if (!errors) errors = result.errors;
578
- return errors;
579
- }
580
- };
581
- }
582
- function jsonParseAst(programJson) {
583
- const { node: program, fixes } = JSON.parse(programJson);
584
- for (const fixPath of fixes) applyFix(program, fixPath);
585
- return program;
586
- }
587
- function applyFix(program, fixPath) {
588
- let node = program;
589
- for (const key of fixPath) node = node[key];
590
- if (node.bigint) node.value = BigInt(node.bigint);
591
- else try {
592
- node.value = RegExp(node.regex.pattern, node.regex.flags);
593
- } catch (_err) {}
594
- }
595
-
596
- //#endregion
597
- //#region src/parse-ast-index.ts
598
- var import_binding = require_chunk.__toESM(require_binding());
599
- function wrap(result, sourceText) {
600
- result = wrap$1(result);
601
- if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
602
- return result.program;
603
- }
604
- function normalizeParseError(sourceText, errors) {
605
- let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
606
- for (let i = 0; i < errors.length; i++) {
607
- if (i >= 5) {
608
- message += "\n...";
609
- break;
610
- }
611
- const e = errors[i];
612
- message += e.message + "\n" + e.labels.map((label) => {
613
- const location = locate(sourceText, label.start, { offsetLine: 1 });
614
- if (!location) return;
615
- return getCodeFrame(sourceText, location.line, location.column);
616
- }).filter(Boolean).join("\n");
617
- }
618
- return error(logParseError(message));
619
- }
620
- const defaultParserOptions = {
621
- lang: "js",
622
- preserveParens: false
623
- };
624
- function parseAst(sourceText, options, filename) {
625
- return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
626
- ...defaultParserOptions,
627
- ...options
628
- }), sourceText);
629
- }
630
- async function parseAstAsync(sourceText, options, filename) {
631
- return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
632
- ...defaultParserOptions,
633
- ...options
634
- }), sourceText);
635
- }
636
-
637
- //#endregion
638
- Object.defineProperty(exports, 'augmentCodeLocation', {
639
- enumerable: true,
640
- get: function () {
641
- return augmentCodeLocation;
642
- }
643
- });
644
- Object.defineProperty(exports, 'error', {
645
- enumerable: true,
646
- get: function () {
647
- return error;
648
- }
649
- });
650
- Object.defineProperty(exports, 'logCycleLoading', {
651
- enumerable: true,
652
- get: function () {
653
- return logCycleLoading;
654
- }
655
- });
656
- Object.defineProperty(exports, 'logInputHookInOutputPlugin', {
657
- enumerable: true,
658
- get: function () {
659
- return logInputHookInOutputPlugin;
660
- }
661
- });
662
- Object.defineProperty(exports, 'logInvalidLogPosition', {
663
- enumerable: true,
664
- get: function () {
665
- return logInvalidLogPosition;
666
- }
667
- });
668
- Object.defineProperty(exports, 'logMultiplyNotifyOption', {
669
- enumerable: true,
670
- get: function () {
671
- return logMultiplyNotifyOption;
672
- }
673
- });
674
- Object.defineProperty(exports, 'logPluginError', {
675
- enumerable: true,
676
- get: function () {
677
- return logPluginError;
678
- }
679
- });
680
- Object.defineProperty(exports, 'parseAst', {
681
- enumerable: true,
682
- get: function () {
683
- return parseAst;
684
- }
685
- });
686
- Object.defineProperty(exports, 'parseAstAsync', {
687
- enumerable: true,
688
- get: function () {
689
- return parseAstAsync;
690
- }
691
- });
692
- Object.defineProperty(exports, 'require_binding', {
693
- enumerable: true,
694
- get: function () {
695
- return require_binding;
696
- }
697
- });