@rolldown/browser 1.0.0-beta.40 → 1.0.0-beta.42

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 (29) hide show
  1. package/dist/cli.mjs +17 -9
  2. package/dist/config.d.mts +2 -2
  3. package/dist/config.mjs +4 -4
  4. package/dist/experimental-index.browser.mjs +22 -25
  5. package/dist/experimental-index.d.mts +17 -9
  6. package/dist/experimental-index.mjs +25 -28
  7. package/dist/experimental-runtime-types.d.ts +6 -0
  8. package/dist/filter-index.d.mts +2 -2
  9. package/dist/filter-index.mjs +1 -1
  10. package/dist/index.browser.mjs +1 -1
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +3 -3
  13. package/dist/parallel-plugin-worker.mjs +5 -6
  14. package/dist/parallel-plugin.d.mts +2 -2
  15. package/dist/parse-ast-index.d.mts +1 -1
  16. package/dist/parse-ast-index.mjs +1 -1
  17. package/dist/rolldown-binding.wasi-browser.js +2 -1
  18. package/dist/rolldown-binding.wasi.cjs +2 -1
  19. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  20. package/dist/shared/{binding-BVXbXhPv.d.mts → binding-CtbNz6TD.d.mts} +29 -22
  21. package/dist/shared/{define-config-D9LkukIg.d.mts → define-config-xBdWOg15.d.mts} +27 -6
  22. package/dist/shared/{dist-CHTC3-kR.mjs → dist-CU0dSkK2.mjs} +2 -3
  23. package/dist/shared/{load-config-CU4Yss-9.mjs → load-config-B4-CoeU7.mjs} +4 -7
  24. package/dist/shared/{logger-CiCY7ucm.mjs → logger-B83ocDok.mjs} +6 -9
  25. package/dist/shared/{parse-ast-index-DuyJNdzo.mjs → parse-ast-index-Gktxd-oi.mjs} +1 -1
  26. package/dist/shared/{prompt-D2FxOcB5.mjs → prompt-B4e-jZUR.mjs} +28 -30
  27. package/dist/shared/{src-BfUPNTHw.mjs → src-DbG0hppv.mjs} +115 -125
  28. package/dist/{src-ChN10Pih.js → src-D_rsgcbb.js} +150 -163
  29. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { augmentCodeLocation, error, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-DuyJNdzo.mjs";
2
- import { and, arraify, code, exclude, id, include, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-CHTC3-kR.mjs";
1
+ import { augmentCodeLocation, error, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-Gktxd-oi.mjs";
2
+ import { and, arraify, code, exclude, id, include, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-CU0dSkK2.mjs";
3
3
  import { Worker, isMainThread } from "node:worker_threads";
4
4
  import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingChunkModuleOrderBy, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, BindingWatcher, ParallelJsPluginRegistry, initTraceSubscriber, shutdownAsyncRuntime, startAsyncRuntime } from "../rolldown-binding.wasi.cjs";
5
5
  import path from "node:path";
@@ -243,7 +243,7 @@ if (isMainThread) {
243
243
 
244
244
  //#endregion
245
245
  //#region package.json
246
- var version = "1.0.0-beta.40";
246
+ var version = "1.0.0-beta.42";
247
247
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
248
248
 
249
249
  //#endregion
@@ -590,20 +590,20 @@ function getSortedPlugins(hookName, plugins) {
590
590
  }
591
591
 
592
592
  //#endregion
593
- //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
594
- var require_ansis = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs": ((exports, module) => {
595
- let e$1, t$2, r, { defineProperty: n$1, setPrototypeOf: l, create: o, keys: s } = Object, i = "", { round: c, max: a$1 } = Math, p = (e$2) => {
596
- let t$3 = /([a-f\d]{3,6})/i.exec(e$2)?.[1], r$1 = t$3?.length, n$2 = parseInt(6 ^ r$1 ? 3 ^ r$1 ? "0" : t$3[0] + t$3[0] + t$3[1] + t$3[1] + t$3[2] + t$3[2] : t$3, 16);
593
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.cjs
594
+ var require_ansis = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.cjs": ((exports, module) => {
595
+ let e$1, t$2, r, { defineProperty: l, setPrototypeOf: n$1, create: o, keys: s } = Object, i = "", { round: c, max: a$1 } = Math, p = (e$2) => {
596
+ let t$3 = /([a-f\d]{3,6})/i.exec(e$2)?.[1], r$1 = t$3?.length, l$1 = parseInt(6 ^ r$1 ? 3 ^ r$1 ? "0" : t$3[0] + t$3[0] + t$3[1] + t$3[1] + t$3[2] + t$3[2] : t$3, 16);
597
597
  return [
598
- n$2 >> 16 & 255,
599
- n$2 >> 8 & 255,
600
- 255 & n$2
598
+ l$1 >> 16 & 255,
599
+ l$1 >> 8 & 255,
600
+ 255 & l$1
601
601
  ];
602
602
  }, u = (e$2, t$3, r$1) => e$2 ^ t$3 || t$3 ^ r$1 ? 16 + 36 * c(e$2 / 51) + 6 * c(t$3 / 51) + c(r$1 / 51) : 8 > e$2 ? 16 : e$2 > 248 ? 231 : c(24 * (e$2 - 8) / 247) + 232, d = (e$2) => {
603
- let t$3, r$1, n$2, l$1, o$1;
604
- return 8 > e$2 ? 30 + e$2 : 16 > e$2 ? e$2 - 8 + 90 : (232 > e$2 ? (o$1 = (e$2 -= 16) % 36, t$3 = (e$2 / 36 | 0) / 5, r$1 = (o$1 / 6 | 0) / 5, n$2 = o$1 % 6 / 5) : t$3 = r$1 = n$2 = (10 * (e$2 - 232) + 8) / 255, l$1 = 2 * a$1(t$3, r$1, n$2), l$1 ? 30 + (c(n$2) << 2 | c(r$1) << 1 | c(t$3)) + (2 ^ l$1 ? 0 : 60) : 30);
605
- }, g = (() => {
606
- let r$1 = (e$2) => o$1.some(((t$3) => e$2.test(t$3))), n$2 = globalThis, l$1 = n$2.process ?? {}, o$1 = l$1.argv ?? [], i$1 = l$1.env ?? {}, c$1 = -1;
603
+ let t$3, r$1, l$1, n$2, o$1;
604
+ return 8 > e$2 ? 30 + e$2 : 16 > e$2 ? e$2 - 8 + 90 : (232 > e$2 ? (o$1 = (e$2 -= 16) % 36, t$3 = (e$2 / 36 | 0) / 5, r$1 = (o$1 / 6 | 0) / 5, l$1 = o$1 % 6 / 5) : t$3 = r$1 = l$1 = (10 * (e$2 - 232) + 8) / 255, n$2 = 2 * a$1(t$3, r$1, l$1), n$2 ? 30 + (c(l$1) << 2 | c(r$1) << 1 | c(t$3)) + (2 ^ n$2 ? 0 : 60) : 30);
605
+ }, f = (() => {
606
+ let r$1 = (e$2) => o$1.some(((t$3) => e$2.test(t$3))), l$1 = globalThis, n$2 = l$1.process ?? {}, o$1 = n$2.argv ?? [], i$1 = n$2.env ?? {}, c$1 = -1;
607
607
  try {
608
608
  e$1 = "," + s(i$1).join(",");
609
609
  } catch (e$2) {
@@ -616,92 +616,92 @@ var require_ansis = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ansis
616
616
  2: 2,
617
617
  3: 3
618
618
  }[i$1[a$2]] ?? -1, u$1 = a$2 in i$1 && p$1 || r$1(/^--color=?(true|always)?$/);
619
- return u$1 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$3, l$2) => (t$2 = r$2.TERM, {
619
+ return u$1 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, l$2, n$3) => (t$2 = r$2.TERM, {
620
620
  "24bit": 3,
621
621
  truecolor: 3,
622
622
  ansi256: 2,
623
623
  ansi: 1
624
- }[r$2.COLORTERM] || (r$2.CI ? /,GITHUB/.test(e$1) ? 3 : 1 : n$3 && "dumb" !== t$2 ? l$2 ? 3 : /-256/.test(t$2) ? 2 : 1 : 0)))(i$1, !!i$1.PM2_HOME || i$1.NEXT_RUNTIME?.includes("edge") || !!l$1.stdout?.isTTY, "win32" === l$1.platform)), !p$1 || i$1.NO_COLOR || r$1(/^--(no-color|color=(false|never))$/) ? 0 : n$2.window?.chrome || u$1 && !c$1 ? 3 : c$1;
625
- })(), f = {
624
+ }[r$2.COLORTERM] || (r$2.CI ? /,GITHUB/.test(e$1) ? 3 : 1 : l$2 && "dumb" !== t$2 ? n$3 ? 3 : /-256/.test(t$2) ? 2 : 1 : 0)))(i$1, !!i$1.PM2_HOME || i$1.NEXT_RUNTIME?.includes("edge") || !!n$2.stdout?.isTTY, "win32" === n$2.platform)), !p$1 || i$1.NO_COLOR || r$1(/^--(no-color|color=(false|never))$/) ? 0 : l$1.window?.chrome || u$1 && !c$1 ? 3 : c$1;
625
+ })(), g = {
626
626
  open: i,
627
627
  close: i
628
- }, h = 39, b = 49, O = {}, m = ({ p: e$2 }, { open: t$3, close: n$2 }) => {
628
+ }, h = 39, b = 49, O = {}, m = ({ p: e$2 }, { open: t$3, close: l$1 }) => {
629
629
  let o$1 = (e$3, ...r$1) => {
630
630
  if (!e$3) {
631
- if (t$3 && t$3 === n$2) return t$3;
631
+ if (t$3 && t$3 === l$1) return t$3;
632
632
  if ((e$3 ?? i) === i) return i;
633
633
  }
634
- let l$1, s$2 = e$3.raw ? String.raw({ raw: e$3 }, ...r$1) : i + e$3, c$2 = o$1.p, a$2 = c$2.o, p$1 = c$2.c;
634
+ let n$2, s$2 = e$3.raw ? String.raw({ raw: e$3 }, ...r$1) : i + e$3, c$2 = o$1.p, a$2 = c$2.o, p$1 = c$2.c;
635
635
  if (s$2.includes("\x1B")) for (; c$2; c$2 = c$2.p) {
636
- let { open: e$4, close: t$4 } = c$2, r$2 = t$4.length, n$3 = i, o$2 = 0;
637
- if (r$2) for (; ~(l$1 = s$2.indexOf(t$4, o$2)); o$2 = l$1 + r$2) n$3 += s$2.slice(o$2, l$1) + e$4;
638
- s$2 = n$3 + s$2.slice(o$2);
636
+ let { open: e$4, close: t$4 } = c$2, r$2 = t$4.length, l$2 = i, o$2 = 0;
637
+ if (r$2) for (; ~(n$2 = s$2.indexOf(t$4, o$2)); o$2 = n$2 + r$2) l$2 += s$2.slice(o$2, n$2) + e$4;
638
+ s$2 = l$2 + s$2.slice(o$2);
639
639
  }
640
640
  return a$2 + (s$2.includes("\n") ? s$2.replace(/(\r?\n)/g, p$1 + "$1" + a$2) : s$2) + p$1;
641
- }, s$1 = t$3, c$1 = n$2;
642
- return e$2 && (s$1 = e$2.o + t$3, c$1 = n$2 + e$2.c), l(o$1, r), o$1.p = {
641
+ }, s$1 = t$3, c$1 = l$1;
642
+ return e$2 && (s$1 = e$2.o + t$3, c$1 = l$1 + e$2.c), n$1(o$1, r), o$1.p = {
643
643
  open: t$3,
644
- close: n$2,
644
+ close: l$1,
645
645
  o: s$1,
646
646
  c: c$1,
647
647
  p: e$2
648
648
  }, o$1.open = s$1, o$1.close = c$1, o$1;
649
649
  };
650
- const w = function(e$2 = g) {
651
- let t$3 = {
652
- Ansis: w,
653
- level: e$2,
654
- isSupported: () => s$1,
650
+ const w = new function e$2(t$3 = f) {
651
+ let s$1 = {
652
+ Ansis: e$2,
653
+ level: t$3,
654
+ isSupported: () => a$2,
655
655
  strip: (e$3) => e$3.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
656
656
  extend(e$3) {
657
657
  for (let t$4 in e$3) {
658
- let r$1 = e$3[t$4], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
659
- O[t$4] = "f" === l$1 ? { get() {
660
- return (...e$4) => m(this, r$1(...e$4));
661
- } } : { get() {
662
- let e$4 = m(this, o$1);
663
- return n$1(this, t$4, { value: e$4 }), e$4;
664
- } };
658
+ let r$1 = e$3[t$4], l$1 = (typeof r$1)[0];
659
+ "s" === l$1 ? (c$1(t$4, T(...p(r$1))), c$1(_(t$4), v(...p(r$1)))) : c$1(t$4, r$1, "f" === l$1);
665
660
  }
666
- return r = o({}, O), l(t$3, r), t$3;
661
+ return r = o({}, O), n$1(s$1, r), s$1;
667
662
  }
668
- }, s$1 = e$2 > 0, c$1 = (e$3, t$4) => s$1 ? {
663
+ }, c$1 = (e$3, t$4, r$1) => {
664
+ O[e$3] = { get() {
665
+ let n$2 = r$1 ? (...e$4) => m(this, t$4(...e$4)) : m(this, t$4);
666
+ return l(this, e$3, { value: n$2 }), n$2;
667
+ } };
668
+ }, a$2 = t$3 > 0, w$1 = (e$3, t$4) => a$2 ? {
669
669
  open: `[${e$3}m`,
670
670
  close: `[${t$4}m`
671
- } : f, a$2 = (e$3) => (t$4) => e$3(...p(t$4)), y$1 = (e$3, t$4) => (r$1, n$2, l$1) => c$1(`${e$3}8;2;${r$1};${n$2};${l$1}`, t$4), R = (e$3, t$4) => (r$1, n$2, l$1) => c$1(((e$4, t$5, r$2) => d(u(e$4, t$5, r$2)))(r$1, n$2, l$1) + e$3, t$4), $ = (e$3) => (t$4, r$1, n$2) => e$3(u(t$4, r$1, n$2)), x = y$1(3, h), T = y$1(4, b), v = (e$3) => c$1("38;5;" + e$3, h), C = (e$3) => c$1("48;5;" + e$3, b);
672
- 2 === e$2 ? (x = $(v), T = $(C)) : 1 === e$2 && (x = R(0, h), T = R(10, b), v = (e$3) => c$1(d(e$3), h), C = (e$3) => c$1(d(e$3) + 10, b));
673
- let E, M = {
674
- fg: v,
675
- bg: C,
676
- rgb: x,
677
- bgRgb: T,
678
- hex: a$2(x),
679
- bgHex: a$2(T),
680
- visible: f,
681
- reset: c$1(0, 0),
682
- bold: c$1(1, 22),
683
- dim: c$1(2, 22),
684
- italic: c$1(3, 23),
685
- underline: c$1(4, 24),
686
- inverse: c$1(7, 27),
687
- hidden: c$1(8, 28),
688
- strikethrough: c$1(9, 29)
689
- }, I = "Bright";
671
+ } : g, y = (e$3) => (t$4) => e$3(...p(t$4)), R = (e$3, t$4) => (r$1, l$1, n$2) => w$1(`${e$3}8;2;${r$1};${l$1};${n$2}`, t$4), $ = (e$3, t$4) => (r$1, l$1, n$2) => w$1(((e$4, t$5, r$2) => d(u(e$4, t$5, r$2)))(r$1, l$1, n$2) + e$3, t$4), x = (e$3) => (t$4, r$1, l$1) => e$3(u(t$4, r$1, l$1)), T = R(3, h), v = R(4, b), C = (e$3) => w$1("38;5;" + e$3, h), E = (e$3) => w$1("48;5;" + e$3, b);
672
+ 2 === t$3 ? (T = x(C), v = x(E)) : 1 === t$3 && (T = $(0, h), v = $(10, b), C = (e$3) => w$1(d(e$3), h), E = (e$3) => w$1(d(e$3) + 10, b));
673
+ let M, I = {
674
+ fg: C,
675
+ bg: E,
676
+ rgb: T,
677
+ bgRgb: v,
678
+ hex: y(T),
679
+ bgHex: y(v),
680
+ visible: g,
681
+ reset: w$1(0, 0),
682
+ bold: w$1(1, 22),
683
+ dim: w$1(2, 22),
684
+ italic: w$1(3, 23),
685
+ underline: w$1(4, 24),
686
+ inverse: w$1(7, 27),
687
+ hidden: w$1(8, 28),
688
+ strikethrough: w$1(9, 29)
689
+ }, _ = (e$3) => "bg" + e$3[0].toUpperCase() + e$3.slice(1), k = "Bright";
690
690
  return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e$3, t$4) => {
691
- E = "bg" + e$3[0].toUpperCase() + e$3.slice(1), 8 > t$4 ? (M[e$3 + I] = c$1(90 + t$4, h), M[E + I] = c$1(100 + t$4, b)) : t$4 = 60, M[e$3] = c$1(30 + t$4, h), M[E] = c$1(40 + t$4, b);
692
- })), t$3.extend(M);
693
- }, y = new w();
694
- module.exports = y, y.default = y;
691
+ M = _(e$3), 8 > t$4 ? (I[e$3 + k] = w$1(90 + t$4, h), I[M + k] = w$1(100 + t$4, b)) : t$4 = 60, I[e$3] = w$1(30 + t$4, h), I[M] = w$1(40 + t$4, b);
692
+ })), s$1.extend(I);
693
+ }();
694
+ module.exports = w, w.default = w;
695
695
  }) });
696
696
 
697
697
  //#endregion
698
- //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.mjs
698
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
699
699
  var import_ansis = /* @__PURE__ */ __toESM(require_ansis(), 1);
700
700
  var ansis_default = import_ansis.default;
701
701
  const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
702
702
 
703
703
  //#endregion
704
- //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.9.2/node_modules/valibot/dist/index.js
704
+ //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.9.3/node_modules/valibot/dist/index.js
705
705
  var store;
706
706
  /* @__NO_SIDE_EFFECTS__ */
707
707
  function getGlobalConfig(config2) {
@@ -1638,6 +1638,18 @@ function omit(schema, keys) {
1638
1638
  };
1639
1639
  }
1640
1640
  /* @__NO_SIDE_EFFECTS__ */
1641
+ function partial(schema, keys) {
1642
+ const entries2 = {};
1643
+ for (const key in schema.entries) entries2[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
1644
+ return {
1645
+ ...schema,
1646
+ entries: entries2,
1647
+ get "~standard"() {
1648
+ return /* @__PURE__ */ _getStandardProps(this);
1649
+ }
1650
+ };
1651
+ }
1652
+ /* @__NO_SIDE_EFFECTS__ */
1641
1653
  function pipe(...pipe2) {
1642
1654
  return {
1643
1655
  ...pipe2[0],
@@ -2092,6 +2104,11 @@ const AdvancedChunksSchema = strictObject({
2092
2104
  maxModuleSize: optional(number())
2093
2105
  })))
2094
2106
  });
2107
+ const GeneratedCodePresetSchema = union([literal("es5"), literal("es2015")]);
2108
+ const GeneratedCodeOptionsSchema = strictObject({
2109
+ symbols: pipe(optional(boolean()), description("Whether to use Symbol.toStringTag for namespace objects")),
2110
+ preset: GeneratedCodePresetSchema
2111
+ });
2095
2112
  const OutputOptionsSchema = strictObject({
2096
2113
  dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
2097
2114
  file: pipe(optional(string()), description("Single output file")),
@@ -2139,6 +2156,7 @@ const OutputOptionsSchema = strictObject({
2139
2156
  ])), description("Minify the bundled file")),
2140
2157
  name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
2141
2158
  globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2159
+ generatedCode: pipe(optional(partial(GeneratedCodeOptionsSchema)), description("Generated code options")),
2142
2160
  externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2143
2161
  inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2144
2162
  manualChunks: optional(pipe(function_(), args(tuple([string(), object({})])), returns(union([string(), nullish(string())])))),
@@ -2190,6 +2208,7 @@ const OutputCliOptionsSchema = omit(strictObject({
2190
2208
  const CliOptionsSchema = strictObject({
2191
2209
  config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
2192
2210
  help: pipe(optional(boolean()), description("Show help")),
2211
+ environment: pipe(optional(union([string(), array(string())])), description("Pass additional settings to the config file via process.ENV.")),
2193
2212
  version: pipe(optional(boolean()), description("Show version number")),
2194
2213
  watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
2195
2214
  ...InputCliOptionsSchema.entries,
@@ -2257,12 +2276,19 @@ function bindingifySourcemap$1(map) {
2257
2276
 
2258
2277
  //#endregion
2259
2278
  //#region src/utils/error.ts
2260
- function normalizeErrors(rawErrors) {
2261
- const errors = rawErrors.map((e$2) => e$2 instanceof Error ? e$2 : Object.assign(/* @__PURE__ */ new Error(), {
2262
- kind: e$2.kind,
2263
- message: e$2.message,
2279
+ function unwrapBindingResult(container) {
2280
+ if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
2281
+ return container;
2282
+ }
2283
+ function normalizeBindingError(e$2) {
2284
+ return e$2.type === "JsError" ? e$2.field0 : Object.assign(/* @__PURE__ */ new Error(), {
2285
+ kind: e$2.field0.kind,
2286
+ message: e$2.field0.message,
2264
2287
  stack: void 0
2265
- }));
2288
+ });
2289
+ }
2290
+ function aggregateBindingErrorsIntoJsError(rawErrors) {
2291
+ const errors = rawErrors.map(normalizeBindingError);
2266
2292
  let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
2267
2293
  for (let i$1 = 0; i$1 < errors.length; i$1++) {
2268
2294
  summary += "\n";
@@ -2701,7 +2727,7 @@ function bindingifyBuildEnd(args$1) {
2701
2727
  const { handler, meta } = normalizeHook(hook);
2702
2728
  return {
2703
2729
  plugin: async (ctx, err) => {
2704
- await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), err ? normalizeErrors(err) : void 0);
2730
+ await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
2705
2731
  },
2706
2732
  meta: bindingifyPluginHookMeta(meta)
2707
2733
  };
@@ -2759,7 +2785,8 @@ function bindingifyResolveDynamicImport(args$1) {
2759
2785
  if (typeof ret === "string") return { id: ret };
2760
2786
  const result = {
2761
2787
  id: ret.id,
2762
- external: ret.external
2788
+ external: ret.external,
2789
+ packageJsonPath: ret.packageJsonPath
2763
2790
  };
2764
2791
  if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
2765
2792
  args$1.pluginContextData.updateModuleOption(ret.id, {
@@ -3001,14 +3028,9 @@ function transformToRollupOutputAsset(bindingAsset, changed) {
3001
3028
  });
3002
3029
  }
3003
3030
  function transformToRollupOutput(output, changed) {
3004
- handleOutputErrors(output);
3005
3031
  const { chunks, assets } = output;
3006
3032
  return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
3007
3033
  }
3008
- function handleOutputErrors(output) {
3009
- const rawErrors = output.errors;
3010
- if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
3011
- }
3012
3034
  function transformToOutputBundle(context, output, changed) {
3013
3035
  const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
3014
3036
  return new Proxy(bundle, {
@@ -3114,7 +3136,7 @@ function bindingifyRenderError(args$1) {
3114
3136
  const { handler, meta } = normalizeHook(hook);
3115
3137
  return {
3116
3138
  plugin: async (ctx, err) => {
3117
- handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), normalizeErrors(err));
3139
+ handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), aggregateBindingErrorsIntoJsError(err));
3118
3140
  },
3119
3141
  meta: bindingifyPluginHookMeta(meta)
3120
3142
  };
@@ -3130,7 +3152,7 @@ function bindingifyGenerateBundle(args$1) {
3130
3152
  deleted: /* @__PURE__ */ new Set()
3131
3153
  };
3132
3154
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3133
- const output = transformToOutputBundle(context, bundle, changed);
3155
+ const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
3134
3156
  await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
3135
3157
  return collectChangedBundle(changed, output);
3136
3158
  },
@@ -3148,7 +3170,7 @@ function bindingifyWriteBundle(args$1) {
3148
3170
  deleted: /* @__PURE__ */ new Set()
3149
3171
  };
3150
3172
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3151
- const output = transformToOutputBundle(context, bundle, changed);
3173
+ const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
3152
3174
  await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
3153
3175
  return collectChangedBundle(changed, output);
3154
3176
  },
@@ -3335,7 +3357,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
3335
3357
  const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args$1);
3336
3358
  const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args$1);
3337
3359
  let hookUsage = extractHookUsage(plugin).inner();
3338
- const result = {
3360
+ return wrapHandlers({
3339
3361
  name: plugin.name,
3340
3362
  buildStart,
3341
3363
  buildStartMeta,
@@ -3382,8 +3404,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
3382
3404
  closeWatcher,
3383
3405
  closeWatcherMeta,
3384
3406
  hookUsage
3385
- };
3386
- return wrapHandlers(result);
3407
+ });
3387
3408
  }
3388
3409
  function wrapHandlers(plugin) {
3389
3410
  for (const hookName of [
@@ -3965,7 +3986,7 @@ var ChunkingContextImpl = class {
3965
3986
  //#endregion
3966
3987
  //#region src/utils/bindingify-output-options.ts
3967
3988
  function bindingifyOutputOptions(outputOptions) {
3968
- const { dir, format, exports, hashCharacters, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks, topLevelVar } = outputOptions;
3989
+ const { dir, format, exports, hashCharacters, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, generatedCode, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks, topLevelVar } = outputOptions;
3969
3990
  const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3970
3991
  return {
3971
3992
  dir,
@@ -3984,6 +4005,7 @@ function bindingifyOutputOptions(outputOptions) {
3984
4005
  outro: bindingifyAddon(outro),
3985
4006
  extend: outputOptions.extend,
3986
4007
  globals,
4008
+ generatedCode,
3987
4009
  esModule,
3988
4010
  name,
3989
4011
  assetFileNames: bindingifyAssetFilenames(assetFileNames),
@@ -4141,12 +4163,10 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4141
4163
  let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
4142
4164
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4143
4165
  try {
4144
- const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
4145
- const bindingOutputOptions = bindingifyOutputOptions(outputOptions);
4146
4166
  return {
4147
4167
  bundlerOptions: {
4148
- inputOptions: bindingInputOptions,
4149
- outputOptions: bindingOutputOptions,
4168
+ inputOptions: bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode),
4169
+ outputOptions: bindingifyOutputOptions(outputOptions),
4150
4170
  parallelPluginsRegistry: parallelPluginInitResult?.registry
4151
4171
  },
4152
4172
  inputOptions,
@@ -4159,18 +4179,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4159
4179
  }
4160
4180
  }
4161
4181
 
4162
- //#endregion
4163
- //#region src/utils/transform-hmr-patch-output.ts
4164
- function transformHmrPatchOutput(output) {
4165
- handleHmrPatchOutputErrors(output);
4166
- const { patch } = output;
4167
- return patch ?? void 0;
4168
- }
4169
- function handleHmrPatchOutputErrors(output) {
4170
- const rawErrors = output.errors;
4171
- if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
4172
- }
4173
-
4174
4182
  //#endregion
4175
4183
  //#region src/api/rolldown/rolldown-build.ts
4176
4184
  Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
@@ -4206,20 +4214,17 @@ var RolldownBuild = class RolldownBuild {
4206
4214
  }
4207
4215
  async scan() {
4208
4216
  const { impl } = await this.#getBundlerWithStopWorker({});
4209
- const output = await impl.scan();
4210
- return handleOutputErrors(output);
4217
+ unwrapBindingResult(await impl.scan());
4211
4218
  }
4212
4219
  async generate(outputOptions = {}) {
4213
4220
  validateOption("output", outputOptions);
4214
4221
  const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4215
- const output = await impl.generate();
4216
- return transformToRollupOutput(output);
4222
+ return transformToRollupOutput(unwrapBindingResult(await impl.generate()));
4217
4223
  }
4218
4224
  async write(outputOptions = {}) {
4219
4225
  validateOption("output", outputOptions);
4220
4226
  const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4221
- const output = await impl.write();
4222
- return transformToRollupOutput(output);
4227
+ return transformToRollupOutput(unwrapBindingResult(await impl.write()));
4223
4228
  }
4224
4229
  async close() {
4225
4230
  if (this.#bundlerImpl) {
@@ -4232,18 +4237,6 @@ var RolldownBuild = class RolldownBuild {
4232
4237
  async [Symbol.asyncDispose]() {
4233
4238
  await this.close();
4234
4239
  }
4235
- async generateHmrPatch(changedFiles) {
4236
- const ret = await this.#bundlerImpl.impl.generateHmrPatch(changedFiles);
4237
- switch (ret.type) {
4238
- case "Ok": return ret.field0;
4239
- case "Error": throw normalizeErrors(ret.field0);
4240
- default: throw new Error("Unknown error");
4241
- }
4242
- }
4243
- async hmrInvalidate(file, firstInvalidatedBy) {
4244
- const output = await this.#bundlerImpl.impl.hmrInvalidate(file, firstInvalidatedBy);
4245
- return transformHmrPatchOutput(output);
4246
- }
4247
4240
  get watchFiles() {
4248
4241
  return this.#bundlerImpl?.impl.getWatchFiles() ?? Promise.resolve([]);
4249
4242
  }
@@ -4253,8 +4246,7 @@ var RolldownBuild = class RolldownBuild {
4253
4246
  //#region src/api/rolldown/index.ts
4254
4247
  const rolldown = async (input) => {
4255
4248
  validateOption("input", input);
4256
- const inputOptions = await PluginDriver.callOptionsHook(input);
4257
- return new RolldownBuild(inputOptions);
4249
+ return new RolldownBuild(await PluginDriver.callOptionsHook(input));
4258
4250
  };
4259
4251
 
4260
4252
  //#endregion
@@ -4322,7 +4314,7 @@ var WatcherEmitter = class {
4322
4314
  const data = event.bundleErrorData();
4323
4315
  await listener({
4324
4316
  code: "ERROR",
4325
- error: normalizeErrors(data.error),
4317
+ error: aggregateBindingErrorsIntoJsError(data.error),
4326
4318
  result: data.result
4327
4319
  });
4328
4320
  break;
@@ -4378,12 +4370,10 @@ var Watcher = class {
4378
4370
  async function createWatcher(emitter, input) {
4379
4371
  const options = arraify(input);
4380
4372
  const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
4381
- const inputOptions = await PluginDriver.callOptionsHook(option, true);
4382
- return createBundlerOptions(inputOptions, output, true);
4373
+ return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
4383
4374
  })).flat());
4384
4375
  const notifyOptions = getValidNotifyOption(bundlerOptions);
4385
- const bindingWatcher = new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
4386
- new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers)).start();
4376
+ new Watcher(emitter, new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions), bundlerOptions.map((option) => option.stopWorkers)).start();
4387
4377
  }
4388
4378
  function getValidNotifyOption(bundlerOptions) {
4389
4379
  let result;