@rolldown/browser 1.0.0-beta.22 → 1.0.0-beta.23

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 (39) hide show
  1. package/dist/cli.cjs +3 -3
  2. package/dist/cli.mjs +3 -3
  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 +3 -3
  7. package/dist/experimental-index.browser.mjs +2 -2
  8. package/dist/experimental-index.cjs +2 -3
  9. package/dist/experimental-index.d.cts +3 -6
  10. package/dist/experimental-index.d.mts +3 -6
  11. package/dist/experimental-index.mjs +3 -3
  12. package/dist/filter-index.cjs +1 -1
  13. package/dist/filter-index.d.cts +2 -2
  14. package/dist/filter-index.d.mts +2 -2
  15. package/dist/filter-index.mjs +1 -1
  16. package/dist/index.browser.mjs +1 -1
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.d.cts +3 -3
  19. package/dist/index.d.mts +3 -3
  20. package/dist/index.mjs +2 -2
  21. package/dist/parallel-plugin-worker.cjs +3 -3
  22. package/dist/parallel-plugin-worker.mjs +3 -3
  23. package/dist/parallel-plugin.d.cts +2 -2
  24. package/dist/parallel-plugin.d.mts +2 -2
  25. package/dist/parse-ast-index.d.cts +1 -1
  26. package/dist/parse-ast-index.d.mts +1 -1
  27. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  28. package/dist/shared/{binding-B8kHDLfO.d.mts → binding-CMKStSph.d.cts} +4 -14
  29. package/dist/shared/{binding-CbR_BHh9.d.cts → binding-DB58iXP8.d.mts} +4 -14
  30. package/dist/shared/{define-config-DZVEpUTF.d.cts → define-config-BRkYSF9E.d.cts} +11 -21
  31. package/dist/shared/{define-config-DsN80oVh.d.mts → define-config-CqVfqfZQ.d.mts} +11 -21
  32. package/dist/shared/{dist-BMVjvV-v.cjs → dist-BVAp8sOm.cjs} +0 -9
  33. package/dist/shared/{dist-BoWaIc-K.mjs → dist-DvBwroyk.mjs} +1 -4
  34. package/dist/shared/{load-config-_2H4hlKT.mjs → load-config-BWbXOTbl.mjs} +1 -1
  35. package/dist/shared/{load-config-BgXwAVNp.cjs → load-config-Bh2dNRk9.cjs} +1 -1
  36. package/dist/shared/{src-C_vfq91X.mjs → src-BA5CL--T.mjs} +454 -775
  37. package/dist/shared/{src-DT8g8X-x.cjs → src-Co_Bf7DL.cjs} +354 -681
  38. package/dist/{src-DJeuVN_z.js → src-C1KTaRyZ.js} +483 -807
  39. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { and, arraify, code, exclude, id, include, isNullish, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-BoWaIc-K.mjs";
1
+ import { and, arraify, code, exclude, id, include, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-DvBwroyk.mjs";
2
2
  import { augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-BzdtcWzA.mjs";
3
3
  import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, shutdownAsyncRuntime, startAsyncRuntime } from "../rolldown-binding.wasi.cjs";
4
4
  import path from "node:path";
@@ -33,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
 
34
34
  //#endregion
35
35
  //#region package.json
36
- var version = "1.0.0-beta.22";
36
+ var version = "1.0.0-beta.23";
37
37
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
38
38
 
39
39
  //#endregion
@@ -76,8 +76,8 @@ function reporterPlugin(config) {
76
76
  function manifestPlugin(config) {
77
77
  return new BuiltinPlugin("builtin:manifest", config);
78
78
  }
79
- function wasmHelperPlugin() {
80
- return new BuiltinPlugin("builtin:wasm-helper");
79
+ function wasmHelperPlugin(config) {
80
+ return new BuiltinPlugin("builtin:wasm-helper", config);
81
81
  }
82
82
  function wasmFallbackPlugin() {
83
83
  const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
@@ -1873,18 +1873,18 @@ function toJsonSchema(schema, config) {
1873
1873
  //#endregion
1874
1874
  //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
1875
1875
  var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs"(exports, module) {
1876
- let e, t$1, r, { defineProperty: n, setPrototypeOf: l, create: o, keys: s } = Object, i$1 = "", { round: c, max: a$1 } = Math, p = (e$1) => {
1877
- let t$2 = /([a-f\d]{3,6})/i.exec(e$1)?.[1], r$1 = t$2?.length, n$1 = parseInt(6 ^ r$1 ? 3 ^ r$1 ? "0" : t$2[0] + t$2[0] + t$2[1] + t$2[1] + t$2[2] + t$2[2] : t$2, 16);
1876
+ let e, t, r, { defineProperty: n, setPrototypeOf: l, create: o, keys: s } = Object, i$1 = "", { round: c, max: a$1 } = Math, p = (e$1) => {
1877
+ let t$1 = /([a-f\d]{3,6})/i.exec(e$1)?.[1], r$1 = t$1?.length, n$1 = parseInt(6 ^ r$1 ? 3 ^ r$1 ? "0" : t$1[0] + t$1[0] + t$1[1] + t$1[1] + t$1[2] + t$1[2] : t$1, 16);
1878
1878
  return [
1879
1879
  n$1 >> 16 & 255,
1880
1880
  n$1 >> 8 & 255,
1881
1881
  255 & n$1
1882
1882
  ];
1883
- }, u$2 = (e$1, t$2, r$1) => e$1 ^ t$2 || t$2 ^ r$1 ? 16 + 36 * c(e$1 / 51) + 6 * c(t$2 / 51) + c(r$1 / 51) : 8 > e$1 ? 16 : e$1 > 248 ? 231 : c(24 * (e$1 - 8) / 247) + 232, d$1 = (e$1) => {
1884
- let t$2, r$1, n$1, l$1, o$1;
1885
- return 8 > e$1 ? 30 + e$1 : 16 > e$1 ? e$1 - 8 + 90 : (232 > e$1 ? (o$1 = (e$1 -= 16) % 36, t$2 = (e$1 / 36 | 0) / 5, r$1 = (o$1 / 6 | 0) / 5, n$1 = o$1 % 6 / 5) : t$2 = r$1 = n$1 = (10 * (e$1 - 232) + 8) / 255, l$1 = 2 * a$1(t$2, r$1, n$1), l$1 ? 30 + (c(n$1) << 2 | c(r$1) << 1 | c(t$2)) + (2 ^ l$1 ? 0 : 60) : 30);
1883
+ }, u$2 = (e$1, t$1, r$1) => e$1 ^ t$1 || t$1 ^ r$1 ? 16 + 36 * c(e$1 / 51) + 6 * c(t$1 / 51) + c(r$1 / 51) : 8 > e$1 ? 16 : e$1 > 248 ? 231 : c(24 * (e$1 - 8) / 247) + 232, d$1 = (e$1) => {
1884
+ let t$1, r$1, n$1, l$1, o$1;
1885
+ return 8 > e$1 ? 30 + e$1 : 16 > e$1 ? e$1 - 8 + 90 : (232 > e$1 ? (o$1 = (e$1 -= 16) % 36, t$1 = (e$1 / 36 | 0) / 5, r$1 = (o$1 / 6 | 0) / 5, n$1 = o$1 % 6 / 5) : t$1 = r$1 = n$1 = (10 * (e$1 - 232) + 8) / 255, l$1 = 2 * a$1(t$1, r$1, n$1), l$1 ? 30 + (c(n$1) << 2 | c(r$1) << 1 | c(t$1)) + (2 ^ l$1 ? 0 : 60) : 30);
1886
1886
  }, g = (() => {
1887
- let r$1 = (e$1) => o$1.some((t$2) => e$1.test(t$2)), n$1 = globalThis, l$1 = n$1.process ?? {}, o$1 = l$1.argv ?? [], i$2 = l$1.env ?? {}, c$1 = -1;
1887
+ let r$1 = (e$1) => o$1.some((t$1) => e$1.test(t$1)), n$1 = globalThis, l$1 = n$1.process ?? {}, o$1 = l$1.argv ?? [], i$2 = l$1.env ?? {}, c$1 = -1;
1888
1888
  try {
1889
1889
  e = "," + s(i$2).join(",");
1890
1890
  } catch (e$1) {
@@ -1897,31 +1897,31 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
1897
1897
  2: 2,
1898
1898
  3: 3
1899
1899
  }[i$2[a$2]] ?? -1, u$3 = a$2 in i$2 && p$1 || r$1(/^--color=?(true|always)?$/);
1900
- return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t$1 = r$2.TERM, {
1900
+ return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t = r$2.TERM, {
1901
1901
  "24bit": 3,
1902
1902
  truecolor: 3,
1903
1903
  ansi256: 2,
1904
1904
  ansi: 1
1905
- }[r$2.COLORTERM] || (r$2.CI ? /,GITHUB/.test(e) ? 3 : 1 : n$2 && "dumb" !== t$1 ? l$2 ? 3 : /-256/.test(t$1) ? 2 : 1 : 0)))(i$2, !!i$2.PM2_HOME || i$2.NEXT_RUNTIME?.includes("edge") || !!l$1.stdout?.isTTY, "win32" === l$1.platform)), !p$1 || i$2.NO_COLOR || r$1(/^--(no-color|color=(false|never))$/) ? 0 : n$1.window?.chrome || u$3 && !c$1 ? 3 : c$1;
1905
+ }[r$2.COLORTERM] || (r$2.CI ? /,GITHUB/.test(e) ? 3 : 1 : n$2 && "dumb" !== t ? l$2 ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i$2, !!i$2.PM2_HOME || i$2.NEXT_RUNTIME?.includes("edge") || !!l$1.stdout?.isTTY, "win32" === l$1.platform)), !p$1 || i$2.NO_COLOR || r$1(/^--(no-color|color=(false|never))$/) ? 0 : n$1.window?.chrome || u$3 && !c$1 ? 3 : c$1;
1906
1906
  })(), f = {
1907
1907
  open: i$1,
1908
1908
  close: i$1
1909
- }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$2, close: n$1 }) => {
1909
+ }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$1, close: n$1 }) => {
1910
1910
  let o$1 = (e$2, ...r$1) => {
1911
1911
  if (!e$2) {
1912
- if (t$2 && t$2 === n$1) return t$2;
1912
+ if (t$1 && t$1 === n$1) return t$1;
1913
1913
  if ((e$2 ?? i$1) === i$1) return i$1;
1914
1914
  }
1915
1915
  let l$1, s$2 = e$2.raw ? String.raw({ raw: e$2 }, ...r$1) : i$1 + e$2, c$2 = o$1.p, a$2 = c$2.o, p$1 = c$2.c;
1916
1916
  if (s$2.includes("\x1B")) for (; c$2; c$2 = c$2.p) {
1917
- let { open: e$3, close: t$3 } = c$2, r$2 = t$3.length, n$2 = i$1, o$2 = 0;
1918
- if (r$2) for (; ~(l$1 = s$2.indexOf(t$3, o$2)); o$2 = l$1 + r$2) n$2 += s$2.slice(o$2, l$1) + e$3;
1917
+ let { open: e$3, close: t$2 } = c$2, r$2 = t$2.length, n$2 = i$1, o$2 = 0;
1918
+ if (r$2) for (; ~(l$1 = s$2.indexOf(t$2, o$2)); o$2 = l$1 + r$2) n$2 += s$2.slice(o$2, l$1) + e$3;
1919
1919
  s$2 = n$2 + s$2.slice(o$2);
1920
1920
  }
1921
1921
  return a$2 + (s$2.includes("\n") ? s$2.replace(/(\r?\n)/g, p$1 + "$1" + a$2) : s$2) + p$1;
1922
- }, s$1 = t$2, c$1 = n$1;
1923
- return e$1 && (s$1 = e$1.o + t$2, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
1924
- open: t$2,
1922
+ }, s$1 = t$1, c$1 = n$1;
1923
+ return e$1 && (s$1 = e$1.o + t$1, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
1924
+ open: t$1,
1925
1925
  close: n$1,
1926
1926
  o: s$1,
1927
1927
  c: c$1,
@@ -1929,27 +1929,27 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
1929
1929
  }, o$1.open = s$1, o$1.close = c$1, o$1;
1930
1930
  };
1931
1931
  const w = function(e$1 = g) {
1932
- let t$2 = {
1932
+ let t$1 = {
1933
1933
  Ansis: w,
1934
1934
  level: e$1,
1935
1935
  isSupported: () => s$1,
1936
1936
  strip: (e$2) => e$2.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i$1),
1937
1937
  extend(e$2) {
1938
- for (let t$3 in e$2) {
1939
- let r$1 = e$2[t$3], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
1940
- O[t$3] = "f" === l$1 ? { get() {
1938
+ for (let t$2 in e$2) {
1939
+ let r$1 = e$2[t$2], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
1940
+ O[t$2] = "f" === l$1 ? { get() {
1941
1941
  return (...e$3) => m(this, r$1(...e$3));
1942
1942
  } } : { get() {
1943
1943
  let e$3 = m(this, o$1);
1944
- return n(this, t$3, { value: e$3 }), e$3;
1944
+ return n(this, t$2, { value: e$3 }), e$3;
1945
1945
  } };
1946
1946
  }
1947
- return r = o({}, O), l(t$2, r), t$2;
1947
+ return r = o({}, O), l(t$1, r), t$1;
1948
1948
  }
1949
- }, s$1 = e$1 > 0, c$1 = (e$2, t$3) => s$1 ? {
1949
+ }, s$1 = e$1 > 0, c$1 = (e$2, t$2) => s$1 ? {
1950
1950
  open: `[${e$2}m`,
1951
- close: `[${t$3}m`
1952
- } : f, a$2 = (e$2) => (t$3) => e$2(...p(t$3)), y$1 = (e$2, t$3) => (r$1, n$1, l$1) => c$1(`${e$2}8;2;${r$1};${n$1};${l$1}`, t$3), R = (e$2, t$3) => (r$1, n$1, l$1) => c$1(((e$3, t$4, r$2) => d$1(u$2(e$3, t$4, r$2)))(r$1, n$1, l$1) + e$2, t$3), $ = (e$2) => (t$3, r$1, n$1) => e$2(u$2(t$3, r$1, n$1)), x = y$1(3, h), T = y$1(4, b), v = (e$2) => c$1("38;5;" + e$2, h), C = (e$2) => c$1("48;5;" + e$2, b);
1951
+ close: `[${t$2}m`
1952
+ } : f, a$2 = (e$2) => (t$2) => e$2(...p(t$2)), y$1 = (e$2, t$2) => (r$1, n$1, l$1) => c$1(`${e$2}8;2;${r$1};${n$1};${l$1}`, t$2), R = (e$2, t$2) => (r$1, n$1, l$1) => c$1(((e$3, t$3, r$2) => d$1(u$2(e$3, t$3, r$2)))(r$1, n$1, l$1) + e$2, t$2), $ = (e$2) => (t$2, r$1, n$1) => e$2(u$2(t$2, r$1, n$1)), x = y$1(3, h), T = y$1(4, b), v = (e$2) => c$1("38;5;" + e$2, h), C = (e$2) => c$1("48;5;" + e$2, b);
1953
1953
  2 === e$1 ? (x = $(v), T = $(C)) : 1 === e$1 && (x = R(0, h), T = R(10, b), v = (e$2) => c$1(d$1(e$2), h), C = (e$2) => c$1(d$1(e$2) + 10, b));
1954
1954
  let E, M = {
1955
1955
  fg: v,
@@ -1968,9 +1968,9 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
1968
1968
  hidden: c$1(8, 28),
1969
1969
  strikethrough: c$1(9, 29)
1970
1970
  }, I = "Bright";
1971
- return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$3) => {
1972
- E = "bg" + e$2[0].toUpperCase() + e$2.slice(1), 8 > t$3 ? (M[e$2 + I] = c$1(90 + t$3, h), M[E + I] = c$1(100 + t$3, b)) : t$3 = 60, M[e$2] = c$1(30 + t$3, h), M[E] = c$1(40 + t$3, b);
1973
- }), t$2.extend(M);
1971
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$2) => {
1972
+ E = "bg" + e$2[0].toUpperCase() + e$2.slice(1), 8 > t$2 ? (M[e$2 + I] = c$1(90 + t$2, h), M[E + I] = c$1(100 + t$2, b)) : t$2 = 60, M[e$2] = c$1(30 + t$2, h), M[E] = c$1(40 + t$2, b);
1973
+ }), t$1.extend(M);
1974
1974
  }, y = new w();
1975
1975
  module.exports = y, y.default = y;
1976
1976
  } });
@@ -2390,41 +2390,9 @@ function getJsonSchema() {
2390
2390
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2391
2391
  }
2392
2392
 
2393
- //#endregion
2394
- //#region src/constants/plugin-context.ts
2395
- /**
2396
- * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2397
- * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2398
- * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2399
- * internally.
2400
- */
2401
- const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2402
-
2403
- //#endregion
2404
- //#region src/options/normalized-input-options.ts
2405
- var NormalizedInputOptionsImpl = class {
2406
- inner;
2407
- constructor(inner, onLog) {
2408
- this.onLog = onLog;
2409
- this.inner = inner;
2410
- }
2411
- get shimMissingExports() {
2412
- return this.inner.shimMissingExports;
2413
- }
2414
- get input() {
2415
- return this.inner.input;
2416
- }
2417
- get cwd() {
2418
- return this.inner.cwd ?? void 0;
2419
- }
2420
- get platform() {
2421
- return this.inner.platform;
2422
- }
2423
- };
2424
-
2425
2393
  //#endregion
2426
2394
  //#region src/types/sourcemap.ts
2427
- function bindingifySourcemap(map) {
2395
+ function bindingifySourcemap$1(map) {
2428
2396
  if (map == null) return;
2429
2397
  return { inner: typeof map === "string" ? map : {
2430
2398
  file: map.file ?? void 0,
@@ -2540,8 +2508,8 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2540
2508
  //#endregion
2541
2509
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
2542
2510
  function u$1(o$1, n$1, a$2) {
2543
- let t$2 = (r$1) => o$1(r$1, ...n$1);
2544
- return a$2 === void 0 ? t$2 : Object.assign(t$2, {
2511
+ let t$1 = (r$1) => o$1(r$1, ...n$1);
2512
+ return a$2 === void 0 ? t$1 : Object.assign(t$1, {
2545
2513
  lazy: a$2,
2546
2514
  lazyArgs: n$1
2547
2515
  });
@@ -2561,18 +2529,12 @@ function u(r$1, n$1, o$1) {
2561
2529
  function d(...r$1) {
2562
2530
  return u(i, r$1);
2563
2531
  }
2564
- var i = (r$1, t$2) => {
2532
+ var i = (r$1, t$1) => {
2565
2533
  let a$2 = [[], []];
2566
- for (let [o$1, e$1] of r$1.entries()) t$2(e$1, o$1, r$1) ? a$2[0].push(e$1) : a$2[1].push(e$1);
2534
+ for (let [o$1, e$1] of r$1.entries()) t$1(e$1, o$1, r$1) ? a$2[0].push(e$1) : a$2[1].push(e$1);
2567
2535
  return a$2;
2568
2536
  };
2569
2537
 
2570
- //#endregion
2571
- //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
2572
- function t(...n$1) {
2573
- return u(Object.keys, n$1);
2574
- }
2575
-
2576
2538
  //#endregion
2577
2539
  //#region src/plugin/bindingify-hook-filter.ts
2578
2540
  function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
@@ -2877,7 +2839,7 @@ function bindingifyBuildStart(args$1) {
2877
2839
  const { handler, meta } = normalizeHook(hook);
2878
2840
  return {
2879
2841
  plugin: async (ctx, opts) => {
2880
- await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedInputOptionsImpl(opts, args$1.onLog));
2842
+ await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), args$1.pluginContextData.getInputOptions(opts));
2881
2843
  },
2882
2844
  meta: bindingifyPluginHookMeta(meta)
2883
2845
  };
@@ -2900,12 +2862,10 @@ function bindingifyResolveId(args$1) {
2900
2862
  return {
2901
2863
  plugin: async (ctx, specifier, importer, extraOptions) => {
2902
2864
  const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
2903
- const newExtraOptions = {
2865
+ const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), specifier, importer ?? void 0, {
2904
2866
  ...extraOptions,
2905
- custom: contextResolveOptions?.custom,
2906
- [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
2907
- };
2908
- const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), specifier, importer ?? void 0, newExtraOptions);
2867
+ custom: contextResolveOptions?.custom
2868
+ });
2909
2869
  if (ret == null) return;
2910
2870
  if (ret === false) return {
2911
2871
  id: specifier,
@@ -2976,7 +2936,7 @@ function bindingifyTransform(args$1) {
2976
2936
  });
2977
2937
  return {
2978
2938
  code: ret.code,
2979
- map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2939
+ map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2980
2940
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
2981
2941
  moduleType: ret.moduleType
2982
2942
  };
@@ -3002,7 +2962,7 @@ function bindingifyLoad(args$1) {
3002
2962
  let map = preProcessSourceMap(ret, id$1);
3003
2963
  return {
3004
2964
  code: ret.code,
3005
- map: bindingifySourcemap(map),
2965
+ map: bindingifySourcemap$1(map),
3006
2966
  moduleType: ret.moduleType,
3007
2967
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
3008
2968
  };
@@ -3033,25 +2993,6 @@ function bindingifyModuleParsed(args$1) {
3033
2993
  };
3034
2994
  }
3035
2995
 
3036
- //#endregion
3037
- //#region src/types/chunking-context.ts
3038
- var ChunkingContext = class {
3039
- constructor(context) {
3040
- this.context = context;
3041
- }
3042
- getModuleInfo(moduleId) {
3043
- const bindingInfo = this.context.getModuleInfo(moduleId);
3044
- if (bindingInfo) {
3045
- const info = transformModuleInfo(bindingInfo, {
3046
- moduleSideEffects: null,
3047
- meta: {}
3048
- });
3049
- return info;
3050
- }
3051
- return null;
3052
- }
3053
- };
3054
-
3055
2996
  //#endregion
3056
2997
  //#region src/utils/transform-rendered-module.ts
3057
2998
  function transformToRenderedModule(bindingRenderedModule) {
@@ -3118,338 +3059,125 @@ function transformChunkModules(modules) {
3118
3059
  }
3119
3060
 
3120
3061
  //#endregion
3121
- //#region src/utils/bindingify-output-options.ts
3122
- function bindingifyOutputOptions(outputOptions) {
3123
- const { dir, format, exports, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks } = outputOptions;
3124
- const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3125
- return {
3126
- dir,
3127
- file: file == null ? void 0 : file,
3128
- format: bindingifyFormat(format),
3129
- exports,
3130
- hashCharacters,
3131
- sourcemap: bindingifySourcemap$1(sourcemap),
3132
- sourcemapDebugIds,
3133
- sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3134
- sourcemapPathTransform,
3135
- banner: bindingifyAddon(banner),
3136
- footer: bindingifyAddon(footer),
3137
- intro: bindingifyAddon(intro),
3138
- outro: bindingifyAddon(outro),
3139
- extend: outputOptions.extend,
3140
- globals,
3141
- esModule,
3142
- name,
3143
- assetFileNames: bindingifyAssetFilenames(assetFileNames),
3144
- entryFileNames,
3145
- chunkFileNames,
3146
- cssEntryFileNames,
3147
- cssChunkFileNames,
3148
- plugins: [],
3149
- minify: outputOptions.minify,
3150
- externalLiveBindings: outputOptions.externalLiveBindings,
3151
- inlineDynamicImports: outputOptions.inlineDynamicImports,
3152
- advancedChunks,
3153
- polyfillRequire: outputOptions.polyfillRequire,
3154
- sanitizeFileName,
3155
- preserveModules,
3156
- virtualDirname,
3157
- legalComments,
3158
- preserveModulesRoot
3062
+ //#region src/utils/transform-to-rollup-output.ts
3063
+ function transformToRollupSourceMap(map) {
3064
+ const parsed = JSON.parse(map);
3065
+ const obj = {
3066
+ ...parsed,
3067
+ toString() {
3068
+ return JSON.stringify(obj);
3069
+ },
3070
+ toUrl() {
3071
+ return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
3072
+ }
3159
3073
  };
3074
+ return obj;
3160
3075
  }
3161
- function bindingifyAddon(configAddon) {
3162
- return async (chunk) => {
3163
- if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3164
- return configAddon || "";
3076
+ function transformToRollupOutputChunk(bindingChunk, changed) {
3077
+ const chunk = {
3078
+ type: "chunk",
3079
+ get code() {
3080
+ return bindingChunk.code;
3081
+ },
3082
+ fileName: bindingChunk.fileName,
3083
+ name: bindingChunk.name,
3084
+ get modules() {
3085
+ return transformChunkModules(bindingChunk.modules);
3086
+ },
3087
+ get imports() {
3088
+ return bindingChunk.imports;
3089
+ },
3090
+ get dynamicImports() {
3091
+ return bindingChunk.dynamicImports;
3092
+ },
3093
+ exports: bindingChunk.exports,
3094
+ isEntry: bindingChunk.isEntry,
3095
+ facadeModuleId: bindingChunk.facadeModuleId || null,
3096
+ isDynamicEntry: bindingChunk.isDynamicEntry,
3097
+ get moduleIds() {
3098
+ return bindingChunk.moduleIds;
3099
+ },
3100
+ get map() {
3101
+ return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
3102
+ },
3103
+ sourcemapFileName: bindingChunk.sourcemapFileName || null,
3104
+ preliminaryFileName: bindingChunk.preliminaryFileName
3165
3105
  };
3106
+ const cache = {};
3107
+ return new Proxy(chunk, {
3108
+ get(target, p$1) {
3109
+ if (p$1 in cache) return cache[p$1];
3110
+ const value = target[p$1];
3111
+ cache[p$1] = value;
3112
+ return value;
3113
+ },
3114
+ set(target, p$1, newValue) {
3115
+ cache[p$1] = newValue;
3116
+ changed?.updated.add(bindingChunk.fileName);
3117
+ return true;
3118
+ },
3119
+ has(target, p$1) {
3120
+ if (p$1 in cache) return true;
3121
+ return p$1 in target;
3122
+ }
3123
+ });
3166
3124
  }
3167
- function bindingifyFormat(format) {
3168
- switch (format) {
3169
- case void 0:
3170
- case "es":
3171
- case "esm":
3172
- case "module": return "es";
3173
- case "cjs":
3174
- case "commonjs": return "cjs";
3175
- case "iife": return "iife";
3176
- case "umd": return "umd";
3177
- default: unimplemented(`output.format: ${format}`);
3178
- }
3179
- }
3180
- function bindingifySourcemap$1(sourcemap) {
3181
- switch (sourcemap) {
3182
- case true: return "file";
3183
- case "inline": return "inline";
3184
- case false:
3185
- case void 0: return void 0;
3186
- case "hidden": return "hidden";
3187
- default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3188
- }
3125
+ function transformToRollupOutputAsset(bindingAsset, changed) {
3126
+ const asset = {
3127
+ type: "asset",
3128
+ fileName: bindingAsset.fileName,
3129
+ originalFileName: bindingAsset.originalFileName || null,
3130
+ originalFileNames: bindingAsset.originalFileNames,
3131
+ get source() {
3132
+ return transformAssetSource(bindingAsset.source);
3133
+ },
3134
+ name: bindingAsset.name ?? void 0,
3135
+ names: bindingAsset.names
3136
+ };
3137
+ const cache = {};
3138
+ return new Proxy(asset, {
3139
+ get(target, p$1) {
3140
+ if (p$1 in cache) return cache[p$1];
3141
+ const value = target[p$1];
3142
+ cache[p$1] = value;
3143
+ return value;
3144
+ },
3145
+ set(target, p$1, newValue) {
3146
+ cache[p$1] = newValue;
3147
+ changed?.updated.add(bindingAsset.fileName);
3148
+ return true;
3149
+ }
3150
+ });
3189
3151
  }
3190
- function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3191
- return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3152
+ function transformToRollupOutput(output, changed) {
3153
+ handleOutputErrors(output);
3154
+ const { chunks, assets } = output;
3155
+ return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
3192
3156
  }
3193
- function bindingifyAssetFilenames(assetFileNames) {
3194
- if (typeof assetFileNames === "function") return (asset) => {
3195
- return assetFileNames({
3196
- names: asset.names,
3197
- originalFileNames: asset.originalFileNames,
3198
- source: transformAssetSource(asset.source),
3199
- type: "asset"
3200
- });
3201
- };
3202
- return assetFileNames;
3157
+ function handleOutputErrors(output) {
3158
+ const rawErrors = output.errors;
3159
+ if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
3203
3160
  }
3204
- function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
3205
- if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3206
- else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
3207
- return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
3208
- } }] };
3209
- if (advancedChunks == null) return void 0;
3210
- const { groups,...restAdvancedChunks } = advancedChunks;
3211
- return {
3212
- ...restAdvancedChunks,
3213
- groups: groups?.map((group) => {
3214
- const { name,...restGroup } = group;
3215
- return {
3216
- ...restGroup,
3217
- name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContext(ctx)) : name
3218
- };
3219
- })
3220
- };
3221
- }
3222
-
3223
- //#endregion
3224
- //#region src/options/normalized-output-options.ts
3225
- var NormalizedOutputOptionsImpl = class {
3226
- constructor(inner, outputOptions, normalizedOutputPlugins) {
3227
- this.inner = inner;
3228
- this.outputOptions = outputOptions;
3229
- this.normalizedOutputPlugins = normalizedOutputPlugins;
3230
- }
3231
- get dir() {
3232
- return this.inner.dir ?? void 0;
3233
- }
3234
- get entryFileNames() {
3235
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3236
- }
3237
- get chunkFileNames() {
3238
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3239
- }
3240
- get assetFileNames() {
3241
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3242
- }
3243
- get format() {
3244
- return this.inner.format;
3245
- }
3246
- get exports() {
3247
- return this.inner.exports;
3248
- }
3249
- get sourcemap() {
3250
- return this.inner.sourcemap;
3251
- }
3252
- get cssEntryFileNames() {
3253
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3254
- }
3255
- get cssChunkFileNames() {
3256
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3257
- }
3258
- get shimMissingExports() {
3259
- return this.inner.shimMissingExports;
3260
- }
3261
- get name() {
3262
- return this.inner.name ?? void 0;
3263
- }
3264
- get file() {
3265
- return this.inner.file ?? void 0;
3266
- }
3267
- get inlineDynamicImports() {
3268
- return this.inner.inlineDynamicImports;
3269
- }
3270
- get externalLiveBindings() {
3271
- return this.inner.externalLiveBindings;
3272
- }
3273
- get banner() {
3274
- return normalizeAddon(this.outputOptions.banner);
3275
- }
3276
- get footer() {
3277
- return normalizeAddon(this.outputOptions.footer);
3278
- }
3279
- get intro() {
3280
- return normalizeAddon(this.outputOptions.intro);
3281
- }
3282
- get outro() {
3283
- return normalizeAddon(this.outputOptions.outro);
3284
- }
3285
- get esModule() {
3286
- return this.inner.esModule;
3287
- }
3288
- get extend() {
3289
- return this.inner.extend;
3290
- }
3291
- get globals() {
3292
- return this.inner.globals || this.outputOptions.globals;
3293
- }
3294
- get hashCharacters() {
3295
- return this.inner.hashCharacters;
3296
- }
3297
- get sourcemapDebugIds() {
3298
- return this.inner.sourcemapDebugIds;
3299
- }
3300
- get sourcemapIgnoreList() {
3301
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3302
- }
3303
- get sourcemapPathTransform() {
3304
- return this.outputOptions.sourcemapPathTransform;
3305
- }
3306
- get minify() {
3307
- return this.inner.minify;
3308
- }
3309
- get legalComments() {
3310
- return this.inner.legalComments;
3311
- }
3312
- get polyfillRequire() {
3313
- return this.inner.polyfillRequire;
3314
- }
3315
- get plugins() {
3316
- return this.normalizedOutputPlugins;
3317
- }
3318
- get preserveModules() {
3319
- return this.inner.preserveModules;
3320
- }
3321
- get preserveModulesRoot() {
3322
- return this.inner.preserveModulesRoot;
3323
- }
3324
- get virtualDirname() {
3325
- return this.inner.virtualDirname;
3326
- }
3327
- };
3328
- function normalizeAddon(value) {
3329
- if (typeof value === "function") return value;
3330
- return () => value || "";
3331
- }
3332
-
3333
- //#endregion
3334
- //#region src/utils/transform-to-rollup-output.ts
3335
- function transformToRollupSourceMap(map) {
3336
- const parsed = JSON.parse(map);
3337
- const obj = {
3338
- ...parsed,
3339
- toString() {
3340
- return JSON.stringify(obj);
3341
- },
3342
- toUrl() {
3343
- return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
3344
- }
3345
- };
3346
- return obj;
3347
- }
3348
- function transformToRollupOutputChunk(bindingChunk, changed) {
3349
- const chunk = {
3350
- type: "chunk",
3351
- get code() {
3352
- return bindingChunk.code;
3353
- },
3354
- fileName: bindingChunk.fileName,
3355
- name: bindingChunk.name,
3356
- get modules() {
3357
- return transformChunkModules(bindingChunk.modules);
3358
- },
3359
- get imports() {
3360
- return bindingChunk.imports;
3361
- },
3362
- get dynamicImports() {
3363
- return bindingChunk.dynamicImports;
3364
- },
3365
- exports: bindingChunk.exports,
3366
- isEntry: bindingChunk.isEntry,
3367
- facadeModuleId: bindingChunk.facadeModuleId || null,
3368
- isDynamicEntry: bindingChunk.isDynamicEntry,
3369
- get moduleIds() {
3370
- return bindingChunk.moduleIds;
3371
- },
3372
- get map() {
3373
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
3374
- },
3375
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
3376
- preliminaryFileName: bindingChunk.preliminaryFileName
3377
- };
3378
- const cache = {};
3379
- return new Proxy(chunk, {
3380
- get(target, p$1) {
3381
- if (p$1 in cache) return cache[p$1];
3382
- const value = target[p$1];
3383
- cache[p$1] = value;
3384
- return value;
3385
- },
3386
- set(target, p$1, newValue) {
3387
- cache[p$1] = newValue;
3388
- changed?.updated.add(bindingChunk.fileName);
3389
- return true;
3390
- },
3391
- has(target, p$1) {
3392
- if (p$1 in cache) return true;
3393
- return p$1 in target;
3394
- }
3395
- });
3396
- }
3397
- function transformToRollupOutputAsset(bindingAsset, changed) {
3398
- const asset = {
3399
- type: "asset",
3400
- fileName: bindingAsset.fileName,
3401
- originalFileName: bindingAsset.originalFileName || null,
3402
- originalFileNames: bindingAsset.originalFileNames,
3403
- get source() {
3404
- return transformAssetSource(bindingAsset.source);
3405
- },
3406
- name: bindingAsset.name ?? void 0,
3407
- names: bindingAsset.names
3408
- };
3409
- const cache = {};
3410
- return new Proxy(asset, {
3411
- get(target, p$1) {
3412
- if (p$1 in cache) return cache[p$1];
3413
- const value = target[p$1];
3414
- cache[p$1] = value;
3415
- return value;
3416
- },
3417
- set(target, p$1, newValue) {
3418
- cache[p$1] = newValue;
3419
- changed?.updated.add(bindingAsset.fileName);
3420
- return true;
3421
- }
3422
- });
3423
- }
3424
- function transformToRollupOutput(output, changed) {
3425
- handleOutputErrors(output);
3426
- const { chunks, assets } = output;
3427
- return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
3428
- }
3429
- function handleOutputErrors(output) {
3430
- const rawErrors = output.errors;
3431
- if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
3432
- }
3433
- function transformToOutputBundle(context, output, changed) {
3434
- const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
3435
- return new Proxy(bundle, {
3436
- set(_target, _p, _newValue, _receiver) {
3437
- const originalStackTraceLimit = Error.stackTraceLimit;
3438
- Error.stackTraceLimit = 2;
3439
- const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
3440
- const stack = new Error(message).stack ?? message;
3441
- Error.stackTraceLimit = originalStackTraceLimit;
3442
- context.warn({
3443
- message: stack,
3444
- code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
3445
- });
3446
- return true;
3447
- },
3448
- deleteProperty(target, property) {
3449
- if (typeof property === "string") changed.deleted.add(property);
3450
- return true;
3451
- }
3452
- });
3161
+ function transformToOutputBundle(context, output, changed) {
3162
+ const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
3163
+ return new Proxy(bundle, {
3164
+ set(_target, _p, _newValue, _receiver) {
3165
+ const originalStackTraceLimit = Error.stackTraceLimit;
3166
+ Error.stackTraceLimit = 2;
3167
+ const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
3168
+ const stack = new Error(message).stack ?? message;
3169
+ Error.stackTraceLimit = originalStackTraceLimit;
3170
+ context.warn({
3171
+ message: stack,
3172
+ code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
3173
+ });
3174
+ return true;
3175
+ },
3176
+ deleteProperty(target, property) {
3177
+ if (typeof property === "string") changed.deleted.add(property);
3178
+ return true;
3179
+ }
3180
+ });
3453
3181
  }
3454
3182
  function collectChangedBundle(changed, bundle) {
3455
3183
  const assets = [];
@@ -3475,7 +3203,7 @@ function collectChangedBundle(changed, bundle) {
3475
3203
  facadeModuleId: item.facadeModuleId || void 0,
3476
3204
  isDynamicEntry: item.isDynamicEntry,
3477
3205
  moduleIds: item.moduleIds,
3478
- map: bindingifySourcemap(item.map),
3206
+ map: bindingifySourcemap$1(item.map),
3479
3207
  sourcemapFilename: item.sourcemapFileName || void 0,
3480
3208
  preliminaryFilename: item.preliminaryFileName
3481
3209
  });
@@ -3495,7 +3223,7 @@ function bindingifyRenderStart(args$1) {
3495
3223
  const { handler, meta } = normalizeHook(hook);
3496
3224
  return {
3497
3225
  plugin: async (ctx, opts) => {
3498
- handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), new NormalizedInputOptionsImpl(opts, args$1.onLog));
3226
+ handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), args$1.pluginContextData.getOutputOptions(opts), args$1.pluginContextData.getInputOptions(opts));
3499
3227
  },
3500
3228
  meta: bindingifyPluginHookMeta(meta)
3501
3229
  };
@@ -3507,13 +3235,13 @@ function bindingifyRenderChunk(args$1) {
3507
3235
  return {
3508
3236
  plugin: async (ctx, code$1, chunk, opts, meta$1) => {
3509
3237
  if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
3510
- const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), code$1, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), args$1.pluginContextData.getRenderChunkMeta());
3238
+ const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), code$1, transformRenderedChunk(chunk), args$1.pluginContextData.getOutputOptions(opts), args$1.pluginContextData.getRenderChunkMeta());
3511
3239
  if (ret == null) return;
3512
3240
  if (typeof ret === "string") return { code: ret };
3513
3241
  if (!ret.map) return { code: ret.code };
3514
3242
  return {
3515
3243
  code: ret.code,
3516
- map: bindingifySourcemap(ret.map)
3244
+ map: bindingifySourcemap$1(ret.map)
3517
3245
  };
3518
3246
  },
3519
3247
  meta: bindingifyPluginHookMeta(meta),
@@ -3554,7 +3282,7 @@ function bindingifyGenerateBundle(args$1) {
3554
3282
  };
3555
3283
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3556
3284
  const output = transformToOutputBundle(context, bundle, changed);
3557
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output, isWrite);
3285
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
3558
3286
  return collectChangedBundle(changed, output);
3559
3287
  },
3560
3288
  meta: bindingifyPluginHookMeta(meta)
@@ -3572,7 +3300,7 @@ function bindingifyWriteBundle(args$1) {
3572
3300
  };
3573
3301
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3574
3302
  const output = transformToOutputBundle(context, bundle, changed);
3575
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output);
3303
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
3576
3304
  return collectChangedBundle(changed, output);
3577
3305
  },
3578
3306
  meta: bindingifyPluginHookMeta(meta)
@@ -3847,30 +3575,291 @@ function wrapHandlers(plugin) {
3847
3575
  }
3848
3576
 
3849
3577
  //#endregion
3850
- //#region src/plugin/plugin-context-data.ts
3851
- var PluginContextData = class {
3852
- moduleOptionMap = /* @__PURE__ */ new Map();
3853
- resolveOptionsMap = /* @__PURE__ */ new Map();
3854
- loadModulePromiseMap = /* @__PURE__ */ new Map();
3855
- loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3856
- renderedChunkMeta = null;
3857
- updateModuleOption(id$1, option) {
3858
- const existing = this.moduleOptionMap.get(id$1);
3859
- if (existing) {
3860
- if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3861
- if (option.meta != null) Object.assign(existing.meta, option.meta);
3862
- if (option.invalidate != null) existing.invalidate = option.invalidate;
3863
- } else {
3864
- this.moduleOptionMap.set(id$1, option);
3865
- return option;
3866
- }
3867
- return existing;
3578
+ //#region src/options/normalized-input-options.ts
3579
+ var NormalizedInputOptionsImpl = class {
3580
+ inner;
3581
+ constructor(inner, onLog) {
3582
+ this.onLog = onLog;
3583
+ this.inner = inner;
3868
3584
  }
3869
- getModuleOption(id$1) {
3870
- const option = this.moduleOptionMap.get(id$1);
3871
- if (!option) {
3872
- const raw = {
3873
- moduleSideEffects: null,
3585
+ get shimMissingExports() {
3586
+ return this.inner.shimMissingExports;
3587
+ }
3588
+ get input() {
3589
+ return this.inner.input;
3590
+ }
3591
+ get cwd() {
3592
+ return this.inner.cwd ?? void 0;
3593
+ }
3594
+ get platform() {
3595
+ return this.inner.platform;
3596
+ }
3597
+ };
3598
+
3599
+ //#endregion
3600
+ //#region src/types/chunking-context.ts
3601
+ var ChunkingContextImpl = class {
3602
+ constructor(context) {
3603
+ this.context = context;
3604
+ }
3605
+ getModuleInfo(moduleId) {
3606
+ const bindingInfo = this.context.getModuleInfo(moduleId);
3607
+ if (bindingInfo) {
3608
+ const info = transformModuleInfo(bindingInfo, {
3609
+ moduleSideEffects: null,
3610
+ meta: {}
3611
+ });
3612
+ return info;
3613
+ }
3614
+ return null;
3615
+ }
3616
+ };
3617
+
3618
+ //#endregion
3619
+ //#region src/utils/bindingify-output-options.ts
3620
+ function bindingifyOutputOptions(outputOptions) {
3621
+ const { dir, format, exports, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks } = outputOptions;
3622
+ const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3623
+ return {
3624
+ dir,
3625
+ file: file == null ? void 0 : file,
3626
+ format: bindingifyFormat(format),
3627
+ exports,
3628
+ hashCharacters,
3629
+ sourcemap: bindingifySourcemap(sourcemap),
3630
+ sourcemapDebugIds,
3631
+ sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3632
+ sourcemapPathTransform,
3633
+ banner: bindingifyAddon(banner),
3634
+ footer: bindingifyAddon(footer),
3635
+ intro: bindingifyAddon(intro),
3636
+ outro: bindingifyAddon(outro),
3637
+ extend: outputOptions.extend,
3638
+ globals,
3639
+ esModule,
3640
+ name,
3641
+ assetFileNames: bindingifyAssetFilenames(assetFileNames),
3642
+ entryFileNames,
3643
+ chunkFileNames,
3644
+ cssEntryFileNames,
3645
+ cssChunkFileNames,
3646
+ plugins: [],
3647
+ minify: outputOptions.minify,
3648
+ externalLiveBindings: outputOptions.externalLiveBindings,
3649
+ inlineDynamicImports: outputOptions.inlineDynamicImports,
3650
+ advancedChunks,
3651
+ polyfillRequire: outputOptions.polyfillRequire,
3652
+ sanitizeFileName,
3653
+ preserveModules,
3654
+ virtualDirname,
3655
+ legalComments,
3656
+ preserveModulesRoot
3657
+ };
3658
+ }
3659
+ function bindingifyAddon(configAddon) {
3660
+ return async (chunk) => {
3661
+ if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3662
+ return configAddon || "";
3663
+ };
3664
+ }
3665
+ function bindingifyFormat(format) {
3666
+ switch (format) {
3667
+ case void 0:
3668
+ case "es":
3669
+ case "esm":
3670
+ case "module": return "es";
3671
+ case "cjs":
3672
+ case "commonjs": return "cjs";
3673
+ case "iife": return "iife";
3674
+ case "umd": return "umd";
3675
+ default: unimplemented(`output.format: ${format}`);
3676
+ }
3677
+ }
3678
+ function bindingifySourcemap(sourcemap) {
3679
+ switch (sourcemap) {
3680
+ case true: return "file";
3681
+ case "inline": return "inline";
3682
+ case false:
3683
+ case void 0: return void 0;
3684
+ case "hidden": return "hidden";
3685
+ default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3686
+ }
3687
+ }
3688
+ function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3689
+ return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3690
+ }
3691
+ function bindingifyAssetFilenames(assetFileNames) {
3692
+ if (typeof assetFileNames === "function") return (asset) => {
3693
+ return assetFileNames({
3694
+ names: asset.names,
3695
+ originalFileNames: asset.originalFileNames,
3696
+ source: transformAssetSource(asset.source),
3697
+ type: "asset"
3698
+ });
3699
+ };
3700
+ return assetFileNames;
3701
+ }
3702
+ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
3703
+ if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3704
+ else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
3705
+ return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
3706
+ } }] };
3707
+ if (advancedChunks == null) return void 0;
3708
+ const { groups,...restAdvancedChunks } = advancedChunks;
3709
+ return {
3710
+ ...restAdvancedChunks,
3711
+ groups: groups?.map((group) => {
3712
+ const { name,...restGroup } = group;
3713
+ return {
3714
+ ...restGroup,
3715
+ name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContextImpl(ctx)) : name
3716
+ };
3717
+ })
3718
+ };
3719
+ }
3720
+
3721
+ //#endregion
3722
+ //#region src/options/normalized-output-options.ts
3723
+ var NormalizedOutputOptionsImpl = class {
3724
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
3725
+ this.inner = inner;
3726
+ this.outputOptions = outputOptions;
3727
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3728
+ }
3729
+ get dir() {
3730
+ return this.inner.dir ?? void 0;
3731
+ }
3732
+ get entryFileNames() {
3733
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3734
+ }
3735
+ get chunkFileNames() {
3736
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3737
+ }
3738
+ get assetFileNames() {
3739
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3740
+ }
3741
+ get format() {
3742
+ return this.inner.format;
3743
+ }
3744
+ get exports() {
3745
+ return this.inner.exports;
3746
+ }
3747
+ get sourcemap() {
3748
+ return this.inner.sourcemap;
3749
+ }
3750
+ get cssEntryFileNames() {
3751
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3752
+ }
3753
+ get cssChunkFileNames() {
3754
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3755
+ }
3756
+ get shimMissingExports() {
3757
+ return this.inner.shimMissingExports;
3758
+ }
3759
+ get name() {
3760
+ return this.inner.name ?? void 0;
3761
+ }
3762
+ get file() {
3763
+ return this.inner.file ?? void 0;
3764
+ }
3765
+ get inlineDynamicImports() {
3766
+ return this.inner.inlineDynamicImports;
3767
+ }
3768
+ get externalLiveBindings() {
3769
+ return this.inner.externalLiveBindings;
3770
+ }
3771
+ get banner() {
3772
+ return normalizeAddon(this.outputOptions.banner);
3773
+ }
3774
+ get footer() {
3775
+ return normalizeAddon(this.outputOptions.footer);
3776
+ }
3777
+ get intro() {
3778
+ return normalizeAddon(this.outputOptions.intro);
3779
+ }
3780
+ get outro() {
3781
+ return normalizeAddon(this.outputOptions.outro);
3782
+ }
3783
+ get esModule() {
3784
+ return this.inner.esModule;
3785
+ }
3786
+ get extend() {
3787
+ return this.inner.extend;
3788
+ }
3789
+ get globals() {
3790
+ return this.inner.globals || this.outputOptions.globals;
3791
+ }
3792
+ get hashCharacters() {
3793
+ return this.inner.hashCharacters;
3794
+ }
3795
+ get sourcemapDebugIds() {
3796
+ return this.inner.sourcemapDebugIds;
3797
+ }
3798
+ get sourcemapIgnoreList() {
3799
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3800
+ }
3801
+ get sourcemapPathTransform() {
3802
+ return this.outputOptions.sourcemapPathTransform;
3803
+ }
3804
+ get minify() {
3805
+ return this.inner.minify;
3806
+ }
3807
+ get legalComments() {
3808
+ return this.inner.legalComments;
3809
+ }
3810
+ get polyfillRequire() {
3811
+ return this.inner.polyfillRequire;
3812
+ }
3813
+ get plugins() {
3814
+ return this.normalizedOutputPlugins;
3815
+ }
3816
+ get preserveModules() {
3817
+ return this.inner.preserveModules;
3818
+ }
3819
+ get preserveModulesRoot() {
3820
+ return this.inner.preserveModulesRoot;
3821
+ }
3822
+ get virtualDirname() {
3823
+ return this.inner.virtualDirname;
3824
+ }
3825
+ };
3826
+ function normalizeAddon(value) {
3827
+ if (typeof value === "function") return value;
3828
+ return () => value || "";
3829
+ }
3830
+
3831
+ //#endregion
3832
+ //#region src/plugin/plugin-context-data.ts
3833
+ var PluginContextData = class {
3834
+ moduleOptionMap = /* @__PURE__ */ new Map();
3835
+ resolveOptionsMap = /* @__PURE__ */ new Map();
3836
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
3837
+ loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3838
+ renderedChunkMeta = null;
3839
+ normalizedInputOptions = null;
3840
+ normalizedOutputOptions = null;
3841
+ constructor(onLog, outputOptions, normalizedOutputPlugins) {
3842
+ this.onLog = onLog;
3843
+ this.outputOptions = outputOptions;
3844
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3845
+ }
3846
+ updateModuleOption(id$1, option) {
3847
+ const existing = this.moduleOptionMap.get(id$1);
3848
+ if (existing) {
3849
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3850
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
3851
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
3852
+ } else {
3853
+ this.moduleOptionMap.set(id$1, option);
3854
+ return option;
3855
+ }
3856
+ return existing;
3857
+ }
3858
+ getModuleOption(id$1) {
3859
+ const option = this.moduleOptionMap.get(id$1);
3860
+ if (!option) {
3861
+ const raw = {
3862
+ moduleSideEffects: null,
3874
3863
  meta: {}
3875
3864
  };
3876
3865
  this.moduleOptionMap.set(id$1, raw);
@@ -3924,6 +3913,14 @@ var PluginContextData = class {
3924
3913
  getRenderChunkMeta() {
3925
3914
  return this.renderedChunkMeta;
3926
3915
  }
3916
+ getInputOptions(opts) {
3917
+ this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
3918
+ return this.normalizedInputOptions;
3919
+ }
3920
+ getOutputOptions(opts) {
3921
+ this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
3922
+ return this.normalizedOutputOptions;
3923
+ }
3927
3924
  markModuleLoaded(id$1, _success) {
3928
3925
  const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
3929
3926
  if (resolve) resolve();
@@ -3949,7 +3946,7 @@ function isReadonlyArray(input) {
3949
3946
  //#endregion
3950
3947
  //#region src/utils/bindingify-input-options.ts
3951
3948
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3952
- const pluginContextData = new PluginContextData();
3949
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3953
3950
  const plugins = rawPlugins.map((plugin) => {
3954
3951
  if ("_parallel" in plugin) return void 0;
3955
3952
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
@@ -4157,323 +4154,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4157
4154
  };
4158
4155
  }
4159
4156
 
4160
- //#endregion
4161
- //#region src/utils/plugin/index.ts
4162
- const isPluginHookName = function() {
4163
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4164
- return function isPluginHookName$1(hookName) {
4165
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
4166
- };
4167
- }();
4168
-
4169
- //#endregion
4170
- //#region src/utils/compose-js-plugins.ts
4171
- const unsupportedHookName = [
4172
- "augmentChunkHash",
4173
- "generateBundle",
4174
- "moduleParsed",
4175
- "onLog",
4176
- "options",
4177
- "outputOptions",
4178
- "renderError",
4179
- "renderStart",
4180
- "resolveDynamicImport",
4181
- "writeBundle"
4182
- ];
4183
- const unsupportedHooks = new Set(unsupportedHookName);
4184
- function isUnsupportedHooks(hookName) {
4185
- return unsupportedHooks.has(hookName);
4186
- }
4187
- function createComposedPlugin(plugins) {
4188
- const names = [];
4189
- const batchedHooks = {};
4190
- plugins.forEach((plugin, index) => {
4191
- const pluginName = plugin.name || `Anonymous(index: ${index})`;
4192
- names.push(pluginName);
4193
- t(plugin).forEach((pluginProp) => {
4194
- if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
4195
- if (!isPluginHookName(pluginProp)) return;
4196
- switch (pluginProp) {
4197
- case "buildStart": {
4198
- const handlers = batchedHooks.buildStart ?? [];
4199
- batchedHooks.buildStart = handlers;
4200
- if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
4201
- break;
4202
- }
4203
- case "load": {
4204
- const handlers = batchedHooks.load ?? [];
4205
- batchedHooks.load = handlers;
4206
- if (plugin.load) handlers.push([plugin.load, plugin]);
4207
- break;
4208
- }
4209
- case "transform": {
4210
- const handlers = batchedHooks.transform ?? [];
4211
- batchedHooks.transform = handlers;
4212
- if (plugin.transform) handlers.push([plugin.transform, plugin]);
4213
- break;
4214
- }
4215
- case "resolveId": {
4216
- const handlers = batchedHooks.resolveId ?? [];
4217
- batchedHooks.resolveId = handlers;
4218
- if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
4219
- break;
4220
- }
4221
- case "buildEnd": {
4222
- const handlers = batchedHooks.buildEnd ?? [];
4223
- batchedHooks.buildEnd = handlers;
4224
- if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
4225
- break;
4226
- }
4227
- case "renderChunk": {
4228
- const handlers = batchedHooks.renderChunk ?? [];
4229
- batchedHooks.renderChunk = handlers;
4230
- if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
4231
- break;
4232
- }
4233
- case "banner":
4234
- case "footer":
4235
- case "intro":
4236
- case "outro": {
4237
- const hook = plugin[pluginProp];
4238
- if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
4239
- break;
4240
- }
4241
- case "closeBundle": {
4242
- const handlers = batchedHooks.closeBundle ?? [];
4243
- batchedHooks.closeBundle = handlers;
4244
- if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
4245
- break;
4246
- }
4247
- case "watchChange": {
4248
- const handlers = batchedHooks.watchChange ?? [];
4249
- batchedHooks.watchChange = handlers;
4250
- if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
4251
- break;
4252
- }
4253
- case "closeWatcher": {
4254
- const handlers = batchedHooks.closeWatcher ?? [];
4255
- batchedHooks.closeWatcher = handlers;
4256
- if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
4257
- break;
4258
- }
4259
- default: {}
4260
- }
4261
- });
4262
- });
4263
- const composed = { name: `Composed(${names.join(", ")})` };
4264
- const createFixedPluginResolveFnMap = /* @__PURE__ */ new Map();
4265
- function applyFixedPluginResolveFn(ctx, plugin) {
4266
- const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
4267
- if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
4268
- return ctx;
4269
- }
4270
- if (batchedHooks.resolveId) {
4271
- const batchedHandlers = batchedHooks.resolveId;
4272
- const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
4273
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4274
- const [_handler, plugin] = batchedHandlers[handlerIdx];
4275
- const handlerSymbol = handlerSymbols[handlerIdx];
4276
- const createFixedPluginResolveFn = (ctx, resolve) => {
4277
- return (source, importer, rawContextResolveOptions) => {
4278
- const contextResolveOptions = rawContextResolveOptions ?? {};
4279
- if (contextResolveOptions.skipSelf) {
4280
- contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
4281
- contextResolveOptions.skipSelf = false;
4282
- }
4283
- return resolve(source, importer, contextResolveOptions);
4284
- };
4285
- };
4286
- createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
4287
- }
4288
- composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
4289
- const hookResolveIdOptions = rawHookResolveIdOptions;
4290
- const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
4291
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4292
- const [handler, plugin] = batchedHandlers[handlerIdx];
4293
- const handlerSymbol = handlerSymbols[handlerIdx];
4294
- if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
4295
- const { handler: handlerFn } = normalizeHook(handler);
4296
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
4297
- if (!isNullish(result)) return result;
4298
- }
4299
- };
4300
- }
4301
- t(batchedHooks).forEach((hookName) => {
4302
- switch (hookName) {
4303
- case "resolveId": break;
4304
- case "buildStart": {
4305
- if (batchedHooks.buildStart) {
4306
- const batchedHandlers = batchedHooks.buildStart;
4307
- composed.buildStart = async function(options) {
4308
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4309
- const { handler: handlerFn } = normalizeHook(handler);
4310
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
4311
- }));
4312
- };
4313
- }
4314
- break;
4315
- }
4316
- case "load": {
4317
- if (batchedHooks.load) {
4318
- const batchedHandlers = batchedHooks.load;
4319
- composed.load = async function(id$1) {
4320
- for (const [handler, plugin] of batchedHandlers) {
4321
- const { handler: handlerFn } = normalizeHook(handler);
4322
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
4323
- if (!isNullish(result)) return result;
4324
- }
4325
- };
4326
- }
4327
- break;
4328
- }
4329
- case "transform": {
4330
- if (batchedHooks.transform) {
4331
- const batchedHandlers = batchedHooks.transform;
4332
- composed.transform = async function(initialCode, id$1, moduleType$1) {
4333
- let code$1 = initialCode;
4334
- let moduleSideEffects = void 0;
4335
- function updateOutput(newCode, newModuleSideEffects) {
4336
- code$1 = newCode;
4337
- moduleSideEffects = newModuleSideEffects ?? void 0;
4338
- }
4339
- for (const [handler, plugin] of batchedHandlers) {
4340
- const { handler: handlerFn } = normalizeHook(handler);
4341
- this.getCombinedSourcemap = () => {
4342
- throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
4343
- };
4344
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
4345
- if (!isNullish(result)) {
4346
- if (typeof result === "string") updateOutput(result);
4347
- else if (result.code) updateOutput(result.code, result.moduleSideEffects);
4348
- }
4349
- }
4350
- return {
4351
- code: code$1,
4352
- moduleSideEffects
4353
- };
4354
- };
4355
- }
4356
- break;
4357
- }
4358
- case "buildEnd": {
4359
- if (batchedHooks.buildEnd) {
4360
- const batchedHandlers = batchedHooks.buildEnd;
4361
- composed.buildEnd = async function(err) {
4362
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4363
- const { handler: handlerFn } = normalizeHook(handler);
4364
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
4365
- }));
4366
- };
4367
- }
4368
- break;
4369
- }
4370
- case "renderChunk": {
4371
- if (batchedHooks.renderChunk) {
4372
- const batchedHandlers = batchedHooks.renderChunk;
4373
- composed.renderChunk = async function(code$1, chunk, options, meta) {
4374
- for (const [handler, plugin] of batchedHandlers) {
4375
- const { handler: handlerFn } = normalizeHook(handler);
4376
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
4377
- if (!isNullish(result)) return result;
4378
- }
4379
- };
4380
- }
4381
- break;
4382
- }
4383
- case "banner":
4384
- case "footer":
4385
- case "intro":
4386
- case "outro": {
4387
- const hooks = batchedHooks[hookName];
4388
- if (hooks?.length) composed[hookName] = async function(chunk) {
4389
- const ret = [];
4390
- for (const [hook, plugin] of hooks) {
4391
- const { handler } = normalizeHook(hook);
4392
- ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
4393
- }
4394
- return ret.join("\n");
4395
- };
4396
- break;
4397
- }
4398
- case "closeBundle": {
4399
- if (batchedHooks.closeBundle) {
4400
- const batchedHandlers = batchedHooks.closeBundle;
4401
- composed.closeBundle = async function() {
4402
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4403
- const { handler: handlerFn } = normalizeHook(handler);
4404
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4405
- }));
4406
- };
4407
- }
4408
- break;
4409
- }
4410
- case "watchChange": {
4411
- if (batchedHooks.watchChange) {
4412
- const batchedHandlers = batchedHooks.watchChange;
4413
- composed.watchChange = async function(id$1, event) {
4414
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4415
- const { handler: handlerFn } = normalizeHook(handler);
4416
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
4417
- }));
4418
- };
4419
- }
4420
- break;
4421
- }
4422
- case "closeWatcher": {
4423
- if (batchedHooks.closeWatcher) {
4424
- const batchedHandlers = batchedHooks.closeWatcher;
4425
- composed.closeWatcher = async function() {
4426
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4427
- const { handler: handlerFn } = normalizeHook(handler);
4428
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4429
- }));
4430
- };
4431
- }
4432
- break;
4433
- }
4434
- default: {}
4435
- }
4436
- });
4437
- return composed;
4438
- }
4439
- function isComposablePlugin(plugin) {
4440
- if (plugin instanceof BuiltinPlugin) return false;
4441
- if ("_parallel" in plugin) return false;
4442
- const hasNotComposablePattern = t(plugin).some((hookName) => {
4443
- if (!isPluginHookName(hookName)) return false;
4444
- const OK_TO_COMPOSE = false;
4445
- if (isUnsupportedHooks(hookName)) return true;
4446
- if (plugin[hookName]) {
4447
- const { meta } = normalizeHook(plugin[hookName]);
4448
- if (meta.order === "pre" || meta.order === "post") return true;
4449
- }
4450
- return OK_TO_COMPOSE;
4451
- });
4452
- if (hasNotComposablePattern) return false;
4453
- return true;
4454
- }
4455
- function composeJsPlugins(plugins) {
4456
- const newPlugins = [];
4457
- const toBeComposed = [];
4458
- plugins.forEach((plugin) => {
4459
- if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
4460
- else {
4461
- if (toBeComposed.length > 0) {
4462
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4463
- else newPlugins.push(toBeComposed[0]);
4464
- toBeComposed.length = 0;
4465
- }
4466
- newPlugins.push(plugin);
4467
- }
4468
- });
4469
- if (toBeComposed.length > 0) {
4470
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4471
- else newPlugins.push(toBeComposed[0]);
4472
- toBeComposed.length = 0;
4473
- }
4474
- return newPlugins;
4475
- }
4476
-
4477
4157
  //#endregion
4478
4158
  //#region src/utils/initialize-parallel-plugins.ts
4479
4159
  async function initializeParallelPlugins(plugins) {
@@ -4550,7 +4230,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4550
4230
  ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4551
4231
  ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4552
4232
  ];
4553
- if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
4554
4233
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4555
4234
  try {
4556
4235
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -4820,4 +4499,4 @@ function defineConfig(config) {
4820
4499
  const VERSION = version;
4821
4500
 
4822
4501
  //#endregion
4823
- export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, __commonJS, __toESM, ansis_default, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundlerImpl, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };
4502
+ export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, __commonJS, __toESM, ansis_default, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, createBundlerImpl, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };