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

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 (46) hide show
  1. package/dist/cli.cjs +8 -8
  2. package/dist/cli.mjs +8 -8
  3. package/dist/config.cjs +4 -4
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +4 -4
  7. package/dist/experimental-index.browser.mjs +2 -2
  8. package/dist/experimental-index.cjs +3 -4
  9. package/dist/experimental-index.d.cts +3 -6
  10. package/dist/experimental-index.d.mts +3 -6
  11. package/dist/experimental-index.mjs +4 -4
  12. package/dist/experimental-runtime-types.d.ts +1 -2
  13. package/dist/filter-index.cjs +1 -1
  14. package/dist/filter-index.d.cts +2 -2
  15. package/dist/filter-index.d.mts +2 -2
  16. package/dist/filter-index.mjs +1 -1
  17. package/dist/index.browser.mjs +1 -1
  18. package/dist/index.cjs +3 -3
  19. package/dist/index.d.cts +3 -3
  20. package/dist/index.d.mts +3 -3
  21. package/dist/index.mjs +3 -3
  22. package/dist/parallel-plugin-worker.cjs +4 -4
  23. package/dist/parallel-plugin-worker.mjs +4 -4
  24. package/dist/parallel-plugin.d.cts +2 -2
  25. package/dist/parallel-plugin.d.mts +2 -2
  26. package/dist/parse-ast-index.cjs +1 -1
  27. package/dist/parse-ast-index.d.cts +1 -1
  28. package/dist/parse-ast-index.d.mts +1 -1
  29. package/dist/parse-ast-index.mjs +1 -1
  30. package/dist/rolldown-binding.wasi-browser.js +0 -3
  31. package/dist/rolldown-binding.wasi.cjs +0 -3
  32. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  33. package/dist/shared/{binding-B8kHDLfO.d.mts → binding-DG3bbtXG.d.cts} +4 -22
  34. package/dist/shared/{binding-CbR_BHh9.d.cts → binding-cECB-Ts3.d.mts} +4 -22
  35. package/dist/shared/{define-config-DZVEpUTF.d.cts → define-config-BnlWQIlM.d.cts} +20 -22
  36. package/dist/shared/{define-config-DsN80oVh.d.mts → define-config-Dipre2WB.d.mts} +20 -22
  37. package/dist/shared/{dist-BMVjvV-v.cjs → dist-BVAp8sOm.cjs} +0 -9
  38. package/dist/shared/{dist-BoWaIc-K.mjs → dist-DvBwroyk.mjs} +1 -4
  39. package/dist/shared/{load-config-BgXwAVNp.cjs → load-config-B-Wrkmqo.cjs} +1 -1
  40. package/dist/shared/{load-config-_2H4hlKT.mjs → load-config-FXcGLoFh.mjs} +1 -1
  41. package/dist/shared/{parse-ast-index-CGTVCgvx.cjs → parse-ast-index-B0vXlNs8.cjs} +14 -2
  42. package/dist/shared/{parse-ast-index-BzdtcWzA.mjs → parse-ast-index-DQEVpsUG.mjs} +9 -3
  43. package/dist/shared/{src-C_vfq91X.mjs → src-DmJCtJ15.mjs} +499 -793
  44. package/dist/shared/{src-DT8g8X-x.cjs → src-dEUToPiW.cjs} +482 -782
  45. package/dist/{src-DJeuVN_z.js → src-BHNQaKQh.js} +532 -823
  46. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require('./chunk-DDkG_k5U.cjs');
2
- const require_dist = require('./dist-BMVjvV-v.cjs');
3
- const require_parse_ast_index = require('./parse-ast-index-CGTVCgvx.cjs');
2
+ const require_dist = require('./dist-BVAp8sOm.cjs');
3
+ const require_parse_ast_index = require('./parse-ast-index-B0vXlNs8.cjs');
4
4
  const src_rolldown_binding_wasi_cjs = require_chunk.__toESM(require("../rolldown-binding.wasi.cjs"));
5
5
  const node_path = require_chunk.__toESM(require("node:path"));
6
6
  const node_url = require_chunk.__toESM(require("node:url"));
@@ -8,9 +8,20 @@ const node_os = require_chunk.__toESM(require("node:os"));
8
8
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
9
9
 
10
10
  //#region package.json
11
- var version = "1.0.0-beta.22";
11
+ var version = "1.0.0-beta.24";
12
12
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
13
 
14
+ //#endregion
15
+ //#region src/utils/normalize-string-or-regex.ts
16
+ function normalizedStringOrRegex(pattern) {
17
+ if (!pattern) return void 0;
18
+ if (!isReadonlyArray(pattern)) return [pattern];
19
+ return pattern;
20
+ }
21
+ function isReadonlyArray(input) {
22
+ return Array.isArray(input);
23
+ }
24
+
14
25
  //#endregion
15
26
  //#region src/builtin-plugin/utils.ts
16
27
  function makeBuiltinPluginCallable(plugin) {
@@ -40,6 +51,10 @@ function modulePreloadPolyfillPlugin(config) {
40
51
  return new BuiltinPlugin("builtin:module-preload-polyfill", config);
41
52
  }
42
53
  function dynamicImportVarsPlugin(config) {
54
+ if (config) {
55
+ config.include = normalizedStringOrRegex(config.include);
56
+ config.exclude = normalizedStringOrRegex(config.exclude);
57
+ }
43
58
  return new BuiltinPlugin("builtin:dynamic-import-vars", config);
44
59
  }
45
60
  function importGlobPlugin(config) {
@@ -51,8 +66,8 @@ function reporterPlugin(config) {
51
66
  function manifestPlugin(config) {
52
67
  return new BuiltinPlugin("builtin:manifest", config);
53
68
  }
54
- function wasmHelperPlugin() {
55
- return new BuiltinPlugin("builtin:wasm-helper");
69
+ function wasmHelperPlugin(config) {
70
+ return new BuiltinPlugin("builtin:wasm-helper", config);
56
71
  }
57
72
  function wasmFallbackPlugin() {
58
73
  const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
@@ -1848,18 +1863,18 @@ function toJsonSchema(schema, config) {
1848
1863
  //#endregion
1849
1864
  //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
1850
1865
  var require_ansis = require_chunk.__commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs"(exports, module) {
1851
- 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) => {
1852
- 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);
1866
+ let e, t, r, { defineProperty: n, setPrototypeOf: l, create: o, keys: s } = Object, i$1 = "", { round: c, max: a$1 } = Math, p = (e$1) => {
1867
+ 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);
1853
1868
  return [
1854
1869
  n$1 >> 16 & 255,
1855
1870
  n$1 >> 8 & 255,
1856
1871
  255 & n$1
1857
1872
  ];
1858
- }, 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) => {
1859
- let t$2, r$1, n$1, l$1, o$1;
1860
- 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);
1873
+ }, 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) => {
1874
+ let t$1, r$1, n$1, l$1, o$1;
1875
+ 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);
1861
1876
  }, g = (() => {
1862
- 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;
1877
+ 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;
1863
1878
  try {
1864
1879
  e = "," + s(i$2).join(",");
1865
1880
  } catch (e$1) {
@@ -1872,31 +1887,31 @@ var require_ansis = require_chunk.__commonJS({ "../../node_modules/.pnpm/ansis@4
1872
1887
  2: 2,
1873
1888
  3: 3
1874
1889
  }[i$2[a$2]] ?? -1, u$3 = a$2 in i$2 && p$1 || r$1(/^--color=?(true|always)?$/);
1875
- return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t$1 = r$2.TERM, {
1890
+ return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t = r$2.TERM, {
1876
1891
  "24bit": 3,
1877
1892
  truecolor: 3,
1878
1893
  ansi256: 2,
1879
1894
  ansi: 1
1880
- }[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;
1895
+ }[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;
1881
1896
  })(), f = {
1882
1897
  open: i$1,
1883
1898
  close: i$1
1884
- }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$2, close: n$1 }) => {
1899
+ }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$1, close: n$1 }) => {
1885
1900
  let o$1 = (e$2, ...r$1) => {
1886
1901
  if (!e$2) {
1887
- if (t$2 && t$2 === n$1) return t$2;
1902
+ if (t$1 && t$1 === n$1) return t$1;
1888
1903
  if ((e$2 ?? i$1) === i$1) return i$1;
1889
1904
  }
1890
1905
  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;
1891
1906
  if (s$2.includes("\x1B")) for (; c$2; c$2 = c$2.p) {
1892
- let { open: e$3, close: t$3 } = c$2, r$2 = t$3.length, n$2 = i$1, o$2 = 0;
1893
- 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;
1907
+ let { open: e$3, close: t$2 } = c$2, r$2 = t$2.length, n$2 = i$1, o$2 = 0;
1908
+ 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;
1894
1909
  s$2 = n$2 + s$2.slice(o$2);
1895
1910
  }
1896
1911
  return a$2 + (s$2.includes("\n") ? s$2.replace(/(\r?\n)/g, p$1 + "$1" + a$2) : s$2) + p$1;
1897
- }, s$1 = t$2, c$1 = n$1;
1898
- return e$1 && (s$1 = e$1.o + t$2, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
1899
- open: t$2,
1912
+ }, s$1 = t$1, c$1 = n$1;
1913
+ return e$1 && (s$1 = e$1.o + t$1, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
1914
+ open: t$1,
1900
1915
  close: n$1,
1901
1916
  o: s$1,
1902
1917
  c: c$1,
@@ -1904,27 +1919,27 @@ var require_ansis = require_chunk.__commonJS({ "../../node_modules/.pnpm/ansis@4
1904
1919
  }, o$1.open = s$1, o$1.close = c$1, o$1;
1905
1920
  };
1906
1921
  const w = function(e$1 = g) {
1907
- let t$2 = {
1922
+ let t$1 = {
1908
1923
  Ansis: w,
1909
1924
  level: e$1,
1910
1925
  isSupported: () => s$1,
1911
1926
  strip: (e$2) => e$2.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i$1),
1912
1927
  extend(e$2) {
1913
- for (let t$3 in e$2) {
1914
- let r$1 = e$2[t$3], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
1915
- O[t$3] = "f" === l$1 ? { get() {
1928
+ for (let t$2 in e$2) {
1929
+ let r$1 = e$2[t$2], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
1930
+ O[t$2] = "f" === l$1 ? { get() {
1916
1931
  return (...e$3) => m(this, r$1(...e$3));
1917
1932
  } } : { get() {
1918
1933
  let e$3 = m(this, o$1);
1919
- return n(this, t$3, { value: e$3 }), e$3;
1934
+ return n(this, t$2, { value: e$3 }), e$3;
1920
1935
  } };
1921
1936
  }
1922
- return r = o({}, O), l(t$2, r), t$2;
1937
+ return r = o({}, O), l(t$1, r), t$1;
1923
1938
  }
1924
- }, s$1 = e$1 > 0, c$1 = (e$2, t$3) => s$1 ? {
1939
+ }, s$1 = e$1 > 0, c$1 = (e$2, t$2) => s$1 ? {
1925
1940
  open: `[${e$2}m`,
1926
- close: `[${t$3}m`
1927
- } : 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);
1941
+ close: `[${t$2}m`
1942
+ } : 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);
1928
1943
  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));
1929
1944
  let E, M = {
1930
1945
  fg: v,
@@ -1943,9 +1958,9 @@ var require_ansis = require_chunk.__commonJS({ "../../node_modules/.pnpm/ansis@4
1943
1958
  hidden: c$1(8, 28),
1944
1959
  strikethrough: c$1(9, 29)
1945
1960
  }, I = "Bright";
1946
- return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$3) => {
1947
- 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);
1948
- }), t$2.extend(M);
1961
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$2) => {
1962
+ 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);
1963
+ }), t$1.extend(M);
1949
1964
  }, y = new w();
1950
1965
  module.exports = y, y.default = y;
1951
1966
  } });
@@ -2102,6 +2117,7 @@ const TreeshakingOptionsSchema = union([boolean(), looseObject({
2102
2117
  unknownGlobalSideEffects: optional(boolean()),
2103
2118
  commonjs: optional(boolean())
2104
2119
  })]);
2120
+ const OptimizationOptionsSchema = strictObject({ inlineConst: pipe(optional(boolean()), description("Enable crossmodule constant inlining")) });
2105
2121
  const OnLogSchema = pipe(function_(), args(tuple([
2106
2122
  LogLevelSchema,
2107
2123
  RollupLogSchema,
@@ -2127,6 +2143,7 @@ const InputOptionsSchema = strictObject({
2127
2143
  ])), description(`Platform for which the code should be generated (node, ${ansis_default.underline("browser")}, neutral)`)),
2128
2144
  shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
2129
2145
  treeshake: optional(TreeshakingOptionsSchema),
2146
+ optimization: optional(OptimizationOptionsSchema),
2130
2147
  logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${ansis_default.dim("silent")}, ${ansis_default.underline(ansis_default.gray("info"))}, debug, ${ansis_default.yellow("warn")})`)),
2131
2148
  onLog: optional(OnLogSchema),
2132
2149
  onwarn: optional(OnwarnSchema),
@@ -2365,41 +2382,9 @@ function getJsonSchema() {
2365
2382
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2366
2383
  }
2367
2384
 
2368
- //#endregion
2369
- //#region src/constants/plugin-context.ts
2370
- /**
2371
- * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2372
- * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2373
- * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2374
- * internally.
2375
- */
2376
- const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2377
-
2378
- //#endregion
2379
- //#region src/options/normalized-input-options.ts
2380
- var NormalizedInputOptionsImpl = class {
2381
- inner;
2382
- constructor(inner, onLog) {
2383
- this.onLog = onLog;
2384
- this.inner = inner;
2385
- }
2386
- get shimMissingExports() {
2387
- return this.inner.shimMissingExports;
2388
- }
2389
- get input() {
2390
- return this.inner.input;
2391
- }
2392
- get cwd() {
2393
- return this.inner.cwd ?? void 0;
2394
- }
2395
- get platform() {
2396
- return this.inner.platform;
2397
- }
2398
- };
2399
-
2400
2385
  //#endregion
2401
2386
  //#region src/types/sourcemap.ts
2402
- function bindingifySourcemap(map) {
2387
+ function bindingifySourcemap$1(map) {
2403
2388
  if (map == null) return;
2404
2389
  return { inner: typeof map === "string" ? map : {
2405
2390
  file: map.file ?? void 0,
@@ -2515,8 +2500,8 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2515
2500
  //#endregion
2516
2501
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
2517
2502
  function u$1(o$1, n$1, a$2) {
2518
- let t$2 = (r$1) => o$1(r$1, ...n$1);
2519
- return a$2 === void 0 ? t$2 : Object.assign(t$2, {
2503
+ let t$1 = (r$1) => o$1(r$1, ...n$1);
2504
+ return a$2 === void 0 ? t$1 : Object.assign(t$1, {
2520
2505
  lazy: a$2,
2521
2506
  lazyArgs: n$1
2522
2507
  });
@@ -2536,18 +2521,12 @@ function u(r$1, n$1, o$1) {
2536
2521
  function d(...r$1) {
2537
2522
  return u(i, r$1);
2538
2523
  }
2539
- var i = (r$1, t$2) => {
2524
+ var i = (r$1, t$1) => {
2540
2525
  let a$2 = [[], []];
2541
- 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);
2526
+ 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);
2542
2527
  return a$2;
2543
2528
  };
2544
2529
 
2545
- //#endregion
2546
- //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
2547
- function t(...n$1) {
2548
- return u(Object.keys, n$1);
2549
- }
2550
-
2551
2530
  //#endregion
2552
2531
  //#region src/plugin/bindingify-hook-filter.ts
2553
2532
  function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
@@ -2852,7 +2831,7 @@ function bindingifyBuildStart(args$1) {
2852
2831
  const { handler, meta } = normalizeHook(hook);
2853
2832
  return {
2854
2833
  plugin: async (ctx, opts) => {
2855
- 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));
2834
+ 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));
2856
2835
  },
2857
2836
  meta: bindingifyPluginHookMeta(meta)
2858
2837
  };
@@ -2875,12 +2854,10 @@ function bindingifyResolveId(args$1) {
2875
2854
  return {
2876
2855
  plugin: async (ctx, specifier, importer, extraOptions) => {
2877
2856
  const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
2878
- const newExtraOptions = {
2857
+ 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, {
2879
2858
  ...extraOptions,
2880
- custom: contextResolveOptions?.custom,
2881
- [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
2882
- };
2883
- 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);
2859
+ custom: contextResolveOptions?.custom
2860
+ });
2884
2861
  if (ret == null) return;
2885
2862
  if (ret === false) return {
2886
2863
  id: specifier,
@@ -2951,7 +2928,7 @@ function bindingifyTransform(args$1) {
2951
2928
  });
2952
2929
  return {
2953
2930
  code: ret.code,
2954
- map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2931
+ map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2955
2932
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
2956
2933
  moduleType: ret.moduleType
2957
2934
  };
@@ -2977,7 +2954,7 @@ function bindingifyLoad(args$1) {
2977
2954
  let map = preProcessSourceMap(ret, id$1);
2978
2955
  return {
2979
2956
  code: ret.code,
2980
- map: bindingifySourcemap(map),
2957
+ map: bindingifySourcemap$1(map),
2981
2958
  moduleType: ret.moduleType,
2982
2959
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
2983
2960
  };
@@ -3008,25 +2985,6 @@ function bindingifyModuleParsed(args$1) {
3008
2985
  };
3009
2986
  }
3010
2987
 
3011
- //#endregion
3012
- //#region src/types/chunking-context.ts
3013
- var ChunkingContext = class {
3014
- constructor(context) {
3015
- this.context = context;
3016
- }
3017
- getModuleInfo(moduleId) {
3018
- const bindingInfo = this.context.getModuleInfo(moduleId);
3019
- if (bindingInfo) {
3020
- const info = transformModuleInfo(bindingInfo, {
3021
- moduleSideEffects: null,
3022
- meta: {}
3023
- });
3024
- return info;
3025
- }
3026
- return null;
3027
- }
3028
- };
3029
-
3030
2988
  //#endregion
3031
2989
  //#region src/utils/transform-rendered-module.ts
3032
2990
  function transformToRenderedModule(bindingRenderedModule) {
@@ -3093,338 +3051,125 @@ function transformChunkModules(modules) {
3093
3051
  }
3094
3052
 
3095
3053
  //#endregion
3096
- //#region src/utils/bindingify-output-options.ts
3097
- function bindingifyOutputOptions(outputOptions) {
3098
- const { dir, format, exports: exports$1, 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;
3099
- const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3100
- return {
3101
- dir,
3102
- file: file == null ? void 0 : file,
3103
- format: bindingifyFormat(format),
3104
- exports: exports$1,
3105
- hashCharacters,
3106
- sourcemap: bindingifySourcemap$1(sourcemap),
3107
- sourcemapDebugIds,
3108
- sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3109
- sourcemapPathTransform,
3110
- banner: bindingifyAddon(banner),
3111
- footer: bindingifyAddon(footer),
3112
- intro: bindingifyAddon(intro),
3113
- outro: bindingifyAddon(outro),
3114
- extend: outputOptions.extend,
3115
- globals,
3116
- esModule,
3117
- name,
3118
- assetFileNames: bindingifyAssetFilenames(assetFileNames),
3119
- entryFileNames,
3120
- chunkFileNames,
3121
- cssEntryFileNames,
3122
- cssChunkFileNames,
3123
- plugins: [],
3124
- minify: outputOptions.minify,
3125
- externalLiveBindings: outputOptions.externalLiveBindings,
3126
- inlineDynamicImports: outputOptions.inlineDynamicImports,
3127
- advancedChunks,
3128
- polyfillRequire: outputOptions.polyfillRequire,
3129
- sanitizeFileName,
3130
- preserveModules,
3131
- virtualDirname,
3132
- legalComments,
3133
- preserveModulesRoot
3054
+ //#region src/utils/transform-to-rollup-output.ts
3055
+ function transformToRollupSourceMap(map) {
3056
+ const parsed = JSON.parse(map);
3057
+ const obj = {
3058
+ ...parsed,
3059
+ toString() {
3060
+ return JSON.stringify(obj);
3061
+ },
3062
+ toUrl() {
3063
+ return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
3064
+ }
3134
3065
  };
3066
+ return obj;
3135
3067
  }
3136
- function bindingifyAddon(configAddon) {
3137
- return async (chunk) => {
3138
- if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3139
- return configAddon || "";
3068
+ function transformToRollupOutputChunk(bindingChunk, changed) {
3069
+ const chunk = {
3070
+ type: "chunk",
3071
+ get code() {
3072
+ return bindingChunk.code;
3073
+ },
3074
+ fileName: bindingChunk.fileName,
3075
+ name: bindingChunk.name,
3076
+ get modules() {
3077
+ return transformChunkModules(bindingChunk.modules);
3078
+ },
3079
+ get imports() {
3080
+ return bindingChunk.imports;
3081
+ },
3082
+ get dynamicImports() {
3083
+ return bindingChunk.dynamicImports;
3084
+ },
3085
+ exports: bindingChunk.exports,
3086
+ isEntry: bindingChunk.isEntry,
3087
+ facadeModuleId: bindingChunk.facadeModuleId || null,
3088
+ isDynamicEntry: bindingChunk.isDynamicEntry,
3089
+ get moduleIds() {
3090
+ return bindingChunk.moduleIds;
3091
+ },
3092
+ get map() {
3093
+ return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
3094
+ },
3095
+ sourcemapFileName: bindingChunk.sourcemapFileName || null,
3096
+ preliminaryFileName: bindingChunk.preliminaryFileName
3140
3097
  };
3098
+ const cache = {};
3099
+ return new Proxy(chunk, {
3100
+ get(target, p$1) {
3101
+ if (p$1 in cache) return cache[p$1];
3102
+ const value = target[p$1];
3103
+ cache[p$1] = value;
3104
+ return value;
3105
+ },
3106
+ set(target, p$1, newValue) {
3107
+ cache[p$1] = newValue;
3108
+ changed?.updated.add(bindingChunk.fileName);
3109
+ return true;
3110
+ },
3111
+ has(target, p$1) {
3112
+ if (p$1 in cache) return true;
3113
+ return p$1 in target;
3114
+ }
3115
+ });
3141
3116
  }
3142
- function bindingifyFormat(format) {
3143
- switch (format) {
3144
- case void 0:
3145
- case "es":
3146
- case "esm":
3147
- case "module": return "es";
3148
- case "cjs":
3149
- case "commonjs": return "cjs";
3150
- case "iife": return "iife";
3151
- case "umd": return "umd";
3152
- default: require_dist.unimplemented(`output.format: ${format}`);
3153
- }
3117
+ function transformToRollupOutputAsset(bindingAsset, changed) {
3118
+ const asset = {
3119
+ type: "asset",
3120
+ fileName: bindingAsset.fileName,
3121
+ originalFileName: bindingAsset.originalFileName || null,
3122
+ originalFileNames: bindingAsset.originalFileNames,
3123
+ get source() {
3124
+ return transformAssetSource(bindingAsset.source);
3125
+ },
3126
+ name: bindingAsset.name ?? void 0,
3127
+ names: bindingAsset.names
3128
+ };
3129
+ const cache = {};
3130
+ return new Proxy(asset, {
3131
+ get(target, p$1) {
3132
+ if (p$1 in cache) return cache[p$1];
3133
+ const value = target[p$1];
3134
+ cache[p$1] = value;
3135
+ return value;
3136
+ },
3137
+ set(target, p$1, newValue) {
3138
+ cache[p$1] = newValue;
3139
+ changed?.updated.add(bindingAsset.fileName);
3140
+ return true;
3141
+ }
3142
+ });
3154
3143
  }
3155
- function bindingifySourcemap$1(sourcemap) {
3156
- switch (sourcemap) {
3157
- case true: return "file";
3158
- case "inline": return "inline";
3159
- case false:
3160
- case void 0: return void 0;
3161
- case "hidden": return "hidden";
3162
- default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3163
- }
3144
+ function transformToRollupOutput(output, changed) {
3145
+ handleOutputErrors(output);
3146
+ const { chunks, assets } = output;
3147
+ return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
3164
3148
  }
3165
- function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3166
- return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3149
+ function handleOutputErrors(output) {
3150
+ const rawErrors = output.errors;
3151
+ if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
3167
3152
  }
3168
- function bindingifyAssetFilenames(assetFileNames) {
3169
- if (typeof assetFileNames === "function") return (asset) => {
3170
- return assetFileNames({
3171
- names: asset.names,
3172
- originalFileNames: asset.originalFileNames,
3173
- source: transformAssetSource(asset.source),
3174
- type: "asset"
3175
- });
3176
- };
3177
- return assetFileNames;
3178
- }
3179
- function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
3180
- if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3181
- else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
3182
- return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
3183
- } }] };
3184
- if (advancedChunks == null) return void 0;
3185
- const { groups,...restAdvancedChunks } = advancedChunks;
3186
- return {
3187
- ...restAdvancedChunks,
3188
- groups: groups?.map((group) => {
3189
- const { name,...restGroup } = group;
3190
- return {
3191
- ...restGroup,
3192
- name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContext(ctx)) : name
3193
- };
3194
- })
3195
- };
3196
- }
3197
-
3198
- //#endregion
3199
- //#region src/options/normalized-output-options.ts
3200
- var NormalizedOutputOptionsImpl = class {
3201
- constructor(inner, outputOptions, normalizedOutputPlugins) {
3202
- this.inner = inner;
3203
- this.outputOptions = outputOptions;
3204
- this.normalizedOutputPlugins = normalizedOutputPlugins;
3205
- }
3206
- get dir() {
3207
- return this.inner.dir ?? void 0;
3208
- }
3209
- get entryFileNames() {
3210
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3211
- }
3212
- get chunkFileNames() {
3213
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3214
- }
3215
- get assetFileNames() {
3216
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3217
- }
3218
- get format() {
3219
- return this.inner.format;
3220
- }
3221
- get exports() {
3222
- return this.inner.exports;
3223
- }
3224
- get sourcemap() {
3225
- return this.inner.sourcemap;
3226
- }
3227
- get cssEntryFileNames() {
3228
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3229
- }
3230
- get cssChunkFileNames() {
3231
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3232
- }
3233
- get shimMissingExports() {
3234
- return this.inner.shimMissingExports;
3235
- }
3236
- get name() {
3237
- return this.inner.name ?? void 0;
3238
- }
3239
- get file() {
3240
- return this.inner.file ?? void 0;
3241
- }
3242
- get inlineDynamicImports() {
3243
- return this.inner.inlineDynamicImports;
3244
- }
3245
- get externalLiveBindings() {
3246
- return this.inner.externalLiveBindings;
3247
- }
3248
- get banner() {
3249
- return normalizeAddon(this.outputOptions.banner);
3250
- }
3251
- get footer() {
3252
- return normalizeAddon(this.outputOptions.footer);
3253
- }
3254
- get intro() {
3255
- return normalizeAddon(this.outputOptions.intro);
3256
- }
3257
- get outro() {
3258
- return normalizeAddon(this.outputOptions.outro);
3259
- }
3260
- get esModule() {
3261
- return this.inner.esModule;
3262
- }
3263
- get extend() {
3264
- return this.inner.extend;
3265
- }
3266
- get globals() {
3267
- return this.inner.globals || this.outputOptions.globals;
3268
- }
3269
- get hashCharacters() {
3270
- return this.inner.hashCharacters;
3271
- }
3272
- get sourcemapDebugIds() {
3273
- return this.inner.sourcemapDebugIds;
3274
- }
3275
- get sourcemapIgnoreList() {
3276
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3277
- }
3278
- get sourcemapPathTransform() {
3279
- return this.outputOptions.sourcemapPathTransform;
3280
- }
3281
- get minify() {
3282
- return this.inner.minify;
3283
- }
3284
- get legalComments() {
3285
- return this.inner.legalComments;
3286
- }
3287
- get polyfillRequire() {
3288
- return this.inner.polyfillRequire;
3289
- }
3290
- get plugins() {
3291
- return this.normalizedOutputPlugins;
3292
- }
3293
- get preserveModules() {
3294
- return this.inner.preserveModules;
3295
- }
3296
- get preserveModulesRoot() {
3297
- return this.inner.preserveModulesRoot;
3298
- }
3299
- get virtualDirname() {
3300
- return this.inner.virtualDirname;
3301
- }
3302
- };
3303
- function normalizeAddon(value) {
3304
- if (typeof value === "function") return value;
3305
- return () => value || "";
3306
- }
3307
-
3308
- //#endregion
3309
- //#region src/utils/transform-to-rollup-output.ts
3310
- function transformToRollupSourceMap(map) {
3311
- const parsed = JSON.parse(map);
3312
- const obj = {
3313
- ...parsed,
3314
- toString() {
3315
- return JSON.stringify(obj);
3316
- },
3317
- toUrl() {
3318
- return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
3319
- }
3320
- };
3321
- return obj;
3322
- }
3323
- function transformToRollupOutputChunk(bindingChunk, changed) {
3324
- const chunk = {
3325
- type: "chunk",
3326
- get code() {
3327
- return bindingChunk.code;
3328
- },
3329
- fileName: bindingChunk.fileName,
3330
- name: bindingChunk.name,
3331
- get modules() {
3332
- return transformChunkModules(bindingChunk.modules);
3333
- },
3334
- get imports() {
3335
- return bindingChunk.imports;
3336
- },
3337
- get dynamicImports() {
3338
- return bindingChunk.dynamicImports;
3339
- },
3340
- exports: bindingChunk.exports,
3341
- isEntry: bindingChunk.isEntry,
3342
- facadeModuleId: bindingChunk.facadeModuleId || null,
3343
- isDynamicEntry: bindingChunk.isDynamicEntry,
3344
- get moduleIds() {
3345
- return bindingChunk.moduleIds;
3346
- },
3347
- get map() {
3348
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
3349
- },
3350
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
3351
- preliminaryFileName: bindingChunk.preliminaryFileName
3352
- };
3353
- const cache = {};
3354
- return new Proxy(chunk, {
3355
- get(target, p$1) {
3356
- if (p$1 in cache) return cache[p$1];
3357
- const value = target[p$1];
3358
- cache[p$1] = value;
3359
- return value;
3360
- },
3361
- set(target, p$1, newValue) {
3362
- cache[p$1] = newValue;
3363
- changed?.updated.add(bindingChunk.fileName);
3364
- return true;
3365
- },
3366
- has(target, p$1) {
3367
- if (p$1 in cache) return true;
3368
- return p$1 in target;
3369
- }
3370
- });
3371
- }
3372
- function transformToRollupOutputAsset(bindingAsset, changed) {
3373
- const asset = {
3374
- type: "asset",
3375
- fileName: bindingAsset.fileName,
3376
- originalFileName: bindingAsset.originalFileName || null,
3377
- originalFileNames: bindingAsset.originalFileNames,
3378
- get source() {
3379
- return transformAssetSource(bindingAsset.source);
3380
- },
3381
- name: bindingAsset.name ?? void 0,
3382
- names: bindingAsset.names
3383
- };
3384
- const cache = {};
3385
- return new Proxy(asset, {
3386
- get(target, p$1) {
3387
- if (p$1 in cache) return cache[p$1];
3388
- const value = target[p$1];
3389
- cache[p$1] = value;
3390
- return value;
3391
- },
3392
- set(target, p$1, newValue) {
3393
- cache[p$1] = newValue;
3394
- changed?.updated.add(bindingAsset.fileName);
3395
- return true;
3396
- }
3397
- });
3398
- }
3399
- function transformToRollupOutput(output, changed) {
3400
- handleOutputErrors(output);
3401
- const { chunks, assets } = output;
3402
- return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
3403
- }
3404
- function handleOutputErrors(output) {
3405
- const rawErrors = output.errors;
3406
- if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
3407
- }
3408
- function transformToOutputBundle(context, output, changed) {
3409
- const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
3410
- return new Proxy(bundle, {
3411
- set(_target, _p, _newValue, _receiver) {
3412
- const originalStackTraceLimit = Error.stackTraceLimit;
3413
- Error.stackTraceLimit = 2;
3414
- 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.";
3415
- const stack = new Error(message).stack ?? message;
3416
- Error.stackTraceLimit = originalStackTraceLimit;
3417
- context.warn({
3418
- message: stack,
3419
- code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
3420
- });
3421
- return true;
3422
- },
3423
- deleteProperty(target, property) {
3424
- if (typeof property === "string") changed.deleted.add(property);
3425
- return true;
3426
- }
3427
- });
3153
+ function transformToOutputBundle(context, output, changed) {
3154
+ const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
3155
+ return new Proxy(bundle, {
3156
+ set(_target, _p, _newValue, _receiver) {
3157
+ const originalStackTraceLimit = Error.stackTraceLimit;
3158
+ Error.stackTraceLimit = 2;
3159
+ 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.";
3160
+ const stack = new Error(message).stack ?? message;
3161
+ Error.stackTraceLimit = originalStackTraceLimit;
3162
+ context.warn({
3163
+ message: stack,
3164
+ code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
3165
+ });
3166
+ return true;
3167
+ },
3168
+ deleteProperty(target, property) {
3169
+ if (typeof property === "string") changed.deleted.add(property);
3170
+ return true;
3171
+ }
3172
+ });
3428
3173
  }
3429
3174
  function collectChangedBundle(changed, bundle) {
3430
3175
  const assets = [];
@@ -3450,7 +3195,7 @@ function collectChangedBundle(changed, bundle) {
3450
3195
  facadeModuleId: item.facadeModuleId || void 0,
3451
3196
  isDynamicEntry: item.isDynamicEntry,
3452
3197
  moduleIds: item.moduleIds,
3453
- map: bindingifySourcemap(item.map),
3198
+ map: bindingifySourcemap$1(item.map),
3454
3199
  sourcemapFilename: item.sourcemapFileName || void 0,
3455
3200
  preliminaryFilename: item.preliminaryFileName
3456
3201
  });
@@ -3470,7 +3215,7 @@ function bindingifyRenderStart(args$1) {
3470
3215
  const { handler, meta } = normalizeHook(hook);
3471
3216
  return {
3472
3217
  plugin: async (ctx, opts) => {
3473
- 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));
3218
+ 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));
3474
3219
  },
3475
3220
  meta: bindingifyPluginHookMeta(meta)
3476
3221
  };
@@ -3482,13 +3227,13 @@ function bindingifyRenderChunk(args$1) {
3482
3227
  return {
3483
3228
  plugin: async (ctx, code$1, chunk, opts, meta$1) => {
3484
3229
  if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
3485
- 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());
3230
+ 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());
3486
3231
  if (ret == null) return;
3487
3232
  if (typeof ret === "string") return { code: ret };
3488
3233
  if (!ret.map) return { code: ret.code };
3489
3234
  return {
3490
3235
  code: ret.code,
3491
- map: bindingifySourcemap(ret.map)
3236
+ map: bindingifySourcemap$1(ret.map)
3492
3237
  };
3493
3238
  },
3494
3239
  meta: bindingifyPluginHookMeta(meta),
@@ -3529,7 +3274,7 @@ function bindingifyGenerateBundle(args$1) {
3529
3274
  };
3530
3275
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3531
3276
  const output = transformToOutputBundle(context, bundle, changed);
3532
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output, isWrite);
3277
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
3533
3278
  return collectChangedBundle(changed, output);
3534
3279
  },
3535
3280
  meta: bindingifyPluginHookMeta(meta)
@@ -3547,7 +3292,7 @@ function bindingifyWriteBundle(args$1) {
3547
3292
  };
3548
3293
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3549
3294
  const output = transformToOutputBundle(context, bundle, changed);
3550
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output);
3295
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
3551
3296
  return collectChangedBundle(changed, output);
3552
3297
  },
3553
3298
  meta: bindingifyPluginHookMeta(meta)
@@ -3818,7 +3563,261 @@ function wrapHandlers(plugin) {
3818
3563
  }
3819
3564
  };
3820
3565
  }
3821
- return plugin;
3566
+ return plugin;
3567
+ }
3568
+
3569
+ //#endregion
3570
+ //#region src/options/normalized-input-options.ts
3571
+ var NormalizedInputOptionsImpl = class {
3572
+ inner;
3573
+ constructor(inner, onLog) {
3574
+ this.onLog = onLog;
3575
+ this.inner = inner;
3576
+ }
3577
+ get shimMissingExports() {
3578
+ return this.inner.shimMissingExports;
3579
+ }
3580
+ get input() {
3581
+ return this.inner.input;
3582
+ }
3583
+ get cwd() {
3584
+ return this.inner.cwd ?? void 0;
3585
+ }
3586
+ get platform() {
3587
+ return this.inner.platform;
3588
+ }
3589
+ };
3590
+
3591
+ //#endregion
3592
+ //#region src/types/chunking-context.ts
3593
+ var ChunkingContextImpl = class {
3594
+ constructor(context) {
3595
+ this.context = context;
3596
+ }
3597
+ getModuleInfo(moduleId) {
3598
+ const bindingInfo = this.context.getModuleInfo(moduleId);
3599
+ if (bindingInfo) {
3600
+ const info = transformModuleInfo(bindingInfo, {
3601
+ moduleSideEffects: null,
3602
+ meta: {}
3603
+ });
3604
+ return info;
3605
+ }
3606
+ return null;
3607
+ }
3608
+ };
3609
+
3610
+ //#endregion
3611
+ //#region src/utils/bindingify-output-options.ts
3612
+ function bindingifyOutputOptions(outputOptions) {
3613
+ const { dir, format, exports: exports$1, 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;
3614
+ const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3615
+ return {
3616
+ dir,
3617
+ file: file == null ? void 0 : file,
3618
+ format: bindingifyFormat(format),
3619
+ exports: exports$1,
3620
+ hashCharacters,
3621
+ sourcemap: bindingifySourcemap(sourcemap),
3622
+ sourcemapDebugIds,
3623
+ sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3624
+ sourcemapPathTransform,
3625
+ banner: bindingifyAddon(banner),
3626
+ footer: bindingifyAddon(footer),
3627
+ intro: bindingifyAddon(intro),
3628
+ outro: bindingifyAddon(outro),
3629
+ extend: outputOptions.extend,
3630
+ globals,
3631
+ esModule,
3632
+ name,
3633
+ assetFileNames: bindingifyAssetFilenames(assetFileNames),
3634
+ entryFileNames,
3635
+ chunkFileNames,
3636
+ cssEntryFileNames,
3637
+ cssChunkFileNames,
3638
+ plugins: [],
3639
+ minify: outputOptions.minify,
3640
+ externalLiveBindings: outputOptions.externalLiveBindings,
3641
+ inlineDynamicImports: outputOptions.inlineDynamicImports,
3642
+ advancedChunks,
3643
+ polyfillRequire: outputOptions.polyfillRequire,
3644
+ sanitizeFileName,
3645
+ preserveModules,
3646
+ virtualDirname,
3647
+ legalComments,
3648
+ preserveModulesRoot
3649
+ };
3650
+ }
3651
+ function bindingifyAddon(configAddon) {
3652
+ return async (chunk) => {
3653
+ if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3654
+ return configAddon || "";
3655
+ };
3656
+ }
3657
+ function bindingifyFormat(format) {
3658
+ switch (format) {
3659
+ case void 0:
3660
+ case "es":
3661
+ case "esm":
3662
+ case "module": return "es";
3663
+ case "cjs":
3664
+ case "commonjs": return "cjs";
3665
+ case "iife": return "iife";
3666
+ case "umd": return "umd";
3667
+ default: require_dist.unimplemented(`output.format: ${format}`);
3668
+ }
3669
+ }
3670
+ function bindingifySourcemap(sourcemap) {
3671
+ switch (sourcemap) {
3672
+ case true: return "file";
3673
+ case "inline": return "inline";
3674
+ case false:
3675
+ case void 0: return void 0;
3676
+ case "hidden": return "hidden";
3677
+ default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3678
+ }
3679
+ }
3680
+ function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3681
+ return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3682
+ }
3683
+ function bindingifyAssetFilenames(assetFileNames) {
3684
+ if (typeof assetFileNames === "function") return (asset) => {
3685
+ return assetFileNames({
3686
+ names: asset.names,
3687
+ originalFileNames: asset.originalFileNames,
3688
+ source: transformAssetSource(asset.source),
3689
+ type: "asset"
3690
+ });
3691
+ };
3692
+ return assetFileNames;
3693
+ }
3694
+ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
3695
+ if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3696
+ else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
3697
+ return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
3698
+ } }] };
3699
+ if (advancedChunks == null) return void 0;
3700
+ const { groups,...restAdvancedChunks } = advancedChunks;
3701
+ return {
3702
+ ...restAdvancedChunks,
3703
+ groups: groups?.map((group) => {
3704
+ const { name,...restGroup } = group;
3705
+ return {
3706
+ ...restGroup,
3707
+ name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContextImpl(ctx)) : name
3708
+ };
3709
+ })
3710
+ };
3711
+ }
3712
+
3713
+ //#endregion
3714
+ //#region src/options/normalized-output-options.ts
3715
+ var NormalizedOutputOptionsImpl = class {
3716
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
3717
+ this.inner = inner;
3718
+ this.outputOptions = outputOptions;
3719
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3720
+ }
3721
+ get dir() {
3722
+ return this.inner.dir ?? void 0;
3723
+ }
3724
+ get entryFileNames() {
3725
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3726
+ }
3727
+ get chunkFileNames() {
3728
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3729
+ }
3730
+ get assetFileNames() {
3731
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3732
+ }
3733
+ get format() {
3734
+ return this.inner.format;
3735
+ }
3736
+ get exports() {
3737
+ return this.inner.exports;
3738
+ }
3739
+ get sourcemap() {
3740
+ return this.inner.sourcemap;
3741
+ }
3742
+ get cssEntryFileNames() {
3743
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3744
+ }
3745
+ get cssChunkFileNames() {
3746
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3747
+ }
3748
+ get shimMissingExports() {
3749
+ return this.inner.shimMissingExports;
3750
+ }
3751
+ get name() {
3752
+ return this.inner.name ?? void 0;
3753
+ }
3754
+ get file() {
3755
+ return this.inner.file ?? void 0;
3756
+ }
3757
+ get inlineDynamicImports() {
3758
+ return this.inner.inlineDynamicImports;
3759
+ }
3760
+ get externalLiveBindings() {
3761
+ return this.inner.externalLiveBindings;
3762
+ }
3763
+ get banner() {
3764
+ return normalizeAddon(this.outputOptions.banner);
3765
+ }
3766
+ get footer() {
3767
+ return normalizeAddon(this.outputOptions.footer);
3768
+ }
3769
+ get intro() {
3770
+ return normalizeAddon(this.outputOptions.intro);
3771
+ }
3772
+ get outro() {
3773
+ return normalizeAddon(this.outputOptions.outro);
3774
+ }
3775
+ get esModule() {
3776
+ return this.inner.esModule;
3777
+ }
3778
+ get extend() {
3779
+ return this.inner.extend;
3780
+ }
3781
+ get globals() {
3782
+ return this.inner.globals || this.outputOptions.globals;
3783
+ }
3784
+ get hashCharacters() {
3785
+ return this.inner.hashCharacters;
3786
+ }
3787
+ get sourcemapDebugIds() {
3788
+ return this.inner.sourcemapDebugIds;
3789
+ }
3790
+ get sourcemapIgnoreList() {
3791
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3792
+ }
3793
+ get sourcemapPathTransform() {
3794
+ return this.outputOptions.sourcemapPathTransform;
3795
+ }
3796
+ get minify() {
3797
+ return this.inner.minify;
3798
+ }
3799
+ get legalComments() {
3800
+ return this.inner.legalComments;
3801
+ }
3802
+ get polyfillRequire() {
3803
+ return this.inner.polyfillRequire;
3804
+ }
3805
+ get plugins() {
3806
+ return this.normalizedOutputPlugins;
3807
+ }
3808
+ get preserveModules() {
3809
+ return this.inner.preserveModules;
3810
+ }
3811
+ get preserveModulesRoot() {
3812
+ return this.inner.preserveModulesRoot;
3813
+ }
3814
+ get virtualDirname() {
3815
+ return this.inner.virtualDirname;
3816
+ }
3817
+ };
3818
+ function normalizeAddon(value) {
3819
+ if (typeof value === "function") return value;
3820
+ return () => value || "";
3822
3821
  }
3823
3822
 
3824
3823
  //#endregion
@@ -3829,6 +3828,13 @@ var PluginContextData = class {
3829
3828
  loadModulePromiseMap = /* @__PURE__ */ new Map();
3830
3829
  loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3831
3830
  renderedChunkMeta = null;
3831
+ normalizedInputOptions = null;
3832
+ normalizedOutputOptions = null;
3833
+ constructor(onLog, outputOptions, normalizedOutputPlugins) {
3834
+ this.onLog = onLog;
3835
+ this.outputOptions = outputOptions;
3836
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3837
+ }
3832
3838
  updateModuleOption(id$1, option) {
3833
3839
  const existing = this.moduleOptionMap.get(id$1);
3834
3840
  if (existing) {
@@ -3899,6 +3905,14 @@ var PluginContextData = class {
3899
3905
  getRenderChunkMeta() {
3900
3906
  return this.renderedChunkMeta;
3901
3907
  }
3908
+ getInputOptions(opts) {
3909
+ this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
3910
+ return this.normalizedInputOptions;
3911
+ }
3912
+ getOutputOptions(opts) {
3913
+ this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
3914
+ return this.normalizedOutputOptions;
3915
+ }
3902
3916
  markModuleLoaded(id$1, _success) {
3903
3917
  const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
3904
3918
  if (resolve) resolve();
@@ -3910,28 +3924,16 @@ var PluginContextData = class {
3910
3924
  }
3911
3925
  };
3912
3926
 
3913
- //#endregion
3914
- //#region src/utils/normalize-string-or-regex.ts
3915
- function normalizedStringOrRegex(pattern) {
3916
- if (!pattern) return void 0;
3917
- if (!isReadonlyArray(pattern)) return [pattern];
3918
- return pattern;
3919
- }
3920
- function isReadonlyArray(input) {
3921
- return Array.isArray(input);
3922
- }
3923
-
3924
3927
  //#endregion
3925
3928
  //#region src/utils/bindingify-input-options.ts
3926
3929
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3927
- const pluginContextData = new PluginContextData();
3930
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3928
3931
  const plugins = rawPlugins.map((plugin) => {
3929
3932
  if ("_parallel" in plugin) return void 0;
3930
3933
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
3931
3934
  return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
3932
3935
  });
3933
- const { jsx, jsxTransform } = bindingifyJsx(inputOptions.jsx);
3934
- const transform = inputOptions.transform || jsxTransform;
3936
+ const { jsx, transform } = bindingifyJsx(onLog, inputOptions.jsx, inputOptions.transform);
3935
3937
  return {
3936
3938
  input: bindingifyInput(inputOptions.input),
3937
3939
  plugins,
@@ -3975,7 +3977,8 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
3975
3977
  debug: inputOptions.debug,
3976
3978
  invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
3977
3979
  markModuleLoaded: pluginContextData.markModuleLoaded.bind(pluginContextData),
3978
- preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures)
3980
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
3981
+ optimization: inputOptions.optimization
3979
3982
  };
3980
3983
  }
3981
3984
  function bindingifyHmr(hmr) {
@@ -4065,24 +4068,45 @@ function bindingifyInput(input) {
4065
4068
  };
4066
4069
  });
4067
4070
  }
4068
- function bindingifyJsx(input) {
4071
+ function bindingifyJsx(onLog, input, transform) {
4072
+ if (transform?.jsx) {
4073
+ if (input !== void 0) onLog(LOG_LEVEL_WARN, require_parse_ast_index.logDuplicateJsxConfig());
4074
+ return { transform };
4075
+ }
4069
4076
  if (typeof input === "object") {
4070
- if (input.mode === "preserve") return { jsx: src_rolldown_binding_wasi_cjs.BindingJsx.Preserve };
4077
+ if (input.mode === "preserve") return {
4078
+ jsx: src_rolldown_binding_wasi_cjs.BindingJsx.Preserve,
4079
+ transform
4080
+ };
4071
4081
  const mode = input.mode ?? "automatic";
4072
- return { jsxTransform: { jsx: {
4082
+ transform ??= {};
4083
+ transform.jsx = {
4073
4084
  runtime: mode,
4074
4085
  pragma: input.factory,
4075
4086
  pragmaFrag: input.fragment,
4076
4087
  importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0
4077
- } } };
4088
+ };
4089
+ return { transform };
4078
4090
  }
4091
+ let jsx;
4079
4092
  switch (input) {
4080
- case false: return { jsx: src_rolldown_binding_wasi_cjs.BindingJsx.Disable };
4081
- case "react": return { jsx: src_rolldown_binding_wasi_cjs.BindingJsx.React };
4082
- case "react-jsx": return { jsx: src_rolldown_binding_wasi_cjs.BindingJsx.ReactJsx };
4083
- case "preserve": return { jsx: src_rolldown_binding_wasi_cjs.BindingJsx.Preserve };
4084
- default: return { jsx: void 0 };
4093
+ case false:
4094
+ jsx = src_rolldown_binding_wasi_cjs.BindingJsx.Disable;
4095
+ break;
4096
+ case "react":
4097
+ jsx = src_rolldown_binding_wasi_cjs.BindingJsx.React;
4098
+ break;
4099
+ case "react-jsx":
4100
+ jsx = src_rolldown_binding_wasi_cjs.BindingJsx.ReactJsx;
4101
+ break;
4102
+ case "preserve":
4103
+ jsx = src_rolldown_binding_wasi_cjs.BindingJsx.Preserve;
4104
+ break;
4085
4105
  }
4106
+ return {
4107
+ jsx,
4108
+ transform
4109
+ };
4086
4110
  }
4087
4111
  function bindingifyWatch(watch$1) {
4088
4112
  if (watch$1) return {
@@ -4132,323 +4156,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4132
4156
  };
4133
4157
  }
4134
4158
 
4135
- //#endregion
4136
- //#region src/utils/plugin/index.ts
4137
- const isPluginHookName = function() {
4138
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4139
- return function isPluginHookName$1(hookName) {
4140
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
4141
- };
4142
- }();
4143
-
4144
- //#endregion
4145
- //#region src/utils/compose-js-plugins.ts
4146
- const unsupportedHookName = [
4147
- "augmentChunkHash",
4148
- "generateBundle",
4149
- "moduleParsed",
4150
- "onLog",
4151
- "options",
4152
- "outputOptions",
4153
- "renderError",
4154
- "renderStart",
4155
- "resolveDynamicImport",
4156
- "writeBundle"
4157
- ];
4158
- const unsupportedHooks = new Set(unsupportedHookName);
4159
- function isUnsupportedHooks(hookName) {
4160
- return unsupportedHooks.has(hookName);
4161
- }
4162
- function createComposedPlugin(plugins) {
4163
- const names = [];
4164
- const batchedHooks = {};
4165
- plugins.forEach((plugin, index) => {
4166
- const pluginName = plugin.name || `Anonymous(index: ${index})`;
4167
- names.push(pluginName);
4168
- t(plugin).forEach((pluginProp) => {
4169
- if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
4170
- if (!isPluginHookName(pluginProp)) return;
4171
- switch (pluginProp) {
4172
- case "buildStart": {
4173
- const handlers = batchedHooks.buildStart ?? [];
4174
- batchedHooks.buildStart = handlers;
4175
- if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
4176
- break;
4177
- }
4178
- case "load": {
4179
- const handlers = batchedHooks.load ?? [];
4180
- batchedHooks.load = handlers;
4181
- if (plugin.load) handlers.push([plugin.load, plugin]);
4182
- break;
4183
- }
4184
- case "transform": {
4185
- const handlers = batchedHooks.transform ?? [];
4186
- batchedHooks.transform = handlers;
4187
- if (plugin.transform) handlers.push([plugin.transform, plugin]);
4188
- break;
4189
- }
4190
- case "resolveId": {
4191
- const handlers = batchedHooks.resolveId ?? [];
4192
- batchedHooks.resolveId = handlers;
4193
- if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
4194
- break;
4195
- }
4196
- case "buildEnd": {
4197
- const handlers = batchedHooks.buildEnd ?? [];
4198
- batchedHooks.buildEnd = handlers;
4199
- if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
4200
- break;
4201
- }
4202
- case "renderChunk": {
4203
- const handlers = batchedHooks.renderChunk ?? [];
4204
- batchedHooks.renderChunk = handlers;
4205
- if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
4206
- break;
4207
- }
4208
- case "banner":
4209
- case "footer":
4210
- case "intro":
4211
- case "outro": {
4212
- const hook = plugin[pluginProp];
4213
- if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
4214
- break;
4215
- }
4216
- case "closeBundle": {
4217
- const handlers = batchedHooks.closeBundle ?? [];
4218
- batchedHooks.closeBundle = handlers;
4219
- if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
4220
- break;
4221
- }
4222
- case "watchChange": {
4223
- const handlers = batchedHooks.watchChange ?? [];
4224
- batchedHooks.watchChange = handlers;
4225
- if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
4226
- break;
4227
- }
4228
- case "closeWatcher": {
4229
- const handlers = batchedHooks.closeWatcher ?? [];
4230
- batchedHooks.closeWatcher = handlers;
4231
- if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
4232
- break;
4233
- }
4234
- default: {}
4235
- }
4236
- });
4237
- });
4238
- const composed = { name: `Composed(${names.join(", ")})` };
4239
- const createFixedPluginResolveFnMap = /* @__PURE__ */ new Map();
4240
- function applyFixedPluginResolveFn(ctx, plugin) {
4241
- const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
4242
- if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
4243
- return ctx;
4244
- }
4245
- if (batchedHooks.resolveId) {
4246
- const batchedHandlers = batchedHooks.resolveId;
4247
- const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
4248
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4249
- const [_handler, plugin] = batchedHandlers[handlerIdx];
4250
- const handlerSymbol = handlerSymbols[handlerIdx];
4251
- const createFixedPluginResolveFn = (ctx, resolve) => {
4252
- return (source, importer, rawContextResolveOptions) => {
4253
- const contextResolveOptions = rawContextResolveOptions ?? {};
4254
- if (contextResolveOptions.skipSelf) {
4255
- contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
4256
- contextResolveOptions.skipSelf = false;
4257
- }
4258
- return resolve(source, importer, contextResolveOptions);
4259
- };
4260
- };
4261
- createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
4262
- }
4263
- composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
4264
- const hookResolveIdOptions = rawHookResolveIdOptions;
4265
- const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
4266
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4267
- const [handler, plugin] = batchedHandlers[handlerIdx];
4268
- const handlerSymbol = handlerSymbols[handlerIdx];
4269
- if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
4270
- const { handler: handlerFn } = normalizeHook(handler);
4271
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
4272
- if (!require_dist.isNullish(result)) return result;
4273
- }
4274
- };
4275
- }
4276
- t(batchedHooks).forEach((hookName) => {
4277
- switch (hookName) {
4278
- case "resolveId": break;
4279
- case "buildStart": {
4280
- if (batchedHooks.buildStart) {
4281
- const batchedHandlers = batchedHooks.buildStart;
4282
- composed.buildStart = async function(options) {
4283
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4284
- const { handler: handlerFn } = normalizeHook(handler);
4285
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
4286
- }));
4287
- };
4288
- }
4289
- break;
4290
- }
4291
- case "load": {
4292
- if (batchedHooks.load) {
4293
- const batchedHandlers = batchedHooks.load;
4294
- composed.load = async function(id$1) {
4295
- for (const [handler, plugin] of batchedHandlers) {
4296
- const { handler: handlerFn } = normalizeHook(handler);
4297
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
4298
- if (!require_dist.isNullish(result)) return result;
4299
- }
4300
- };
4301
- }
4302
- break;
4303
- }
4304
- case "transform": {
4305
- if (batchedHooks.transform) {
4306
- const batchedHandlers = batchedHooks.transform;
4307
- composed.transform = async function(initialCode, id$1, moduleType$1) {
4308
- let code$1 = initialCode;
4309
- let moduleSideEffects = void 0;
4310
- function updateOutput(newCode, newModuleSideEffects) {
4311
- code$1 = newCode;
4312
- moduleSideEffects = newModuleSideEffects ?? void 0;
4313
- }
4314
- for (const [handler, plugin] of batchedHandlers) {
4315
- const { handler: handlerFn } = normalizeHook(handler);
4316
- this.getCombinedSourcemap = () => {
4317
- throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
4318
- };
4319
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
4320
- if (!require_dist.isNullish(result)) {
4321
- if (typeof result === "string") updateOutput(result);
4322
- else if (result.code) updateOutput(result.code, result.moduleSideEffects);
4323
- }
4324
- }
4325
- return {
4326
- code: code$1,
4327
- moduleSideEffects
4328
- };
4329
- };
4330
- }
4331
- break;
4332
- }
4333
- case "buildEnd": {
4334
- if (batchedHooks.buildEnd) {
4335
- const batchedHandlers = batchedHooks.buildEnd;
4336
- composed.buildEnd = async function(err) {
4337
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4338
- const { handler: handlerFn } = normalizeHook(handler);
4339
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
4340
- }));
4341
- };
4342
- }
4343
- break;
4344
- }
4345
- case "renderChunk": {
4346
- if (batchedHooks.renderChunk) {
4347
- const batchedHandlers = batchedHooks.renderChunk;
4348
- composed.renderChunk = async function(code$1, chunk, options, meta) {
4349
- for (const [handler, plugin] of batchedHandlers) {
4350
- const { handler: handlerFn } = normalizeHook(handler);
4351
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
4352
- if (!require_dist.isNullish(result)) return result;
4353
- }
4354
- };
4355
- }
4356
- break;
4357
- }
4358
- case "banner":
4359
- case "footer":
4360
- case "intro":
4361
- case "outro": {
4362
- const hooks = batchedHooks[hookName];
4363
- if (hooks?.length) composed[hookName] = async function(chunk) {
4364
- const ret = [];
4365
- for (const [hook, plugin] of hooks) {
4366
- const { handler } = normalizeHook(hook);
4367
- ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
4368
- }
4369
- return ret.join("\n");
4370
- };
4371
- break;
4372
- }
4373
- case "closeBundle": {
4374
- if (batchedHooks.closeBundle) {
4375
- const batchedHandlers = batchedHooks.closeBundle;
4376
- composed.closeBundle = async function() {
4377
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4378
- const { handler: handlerFn } = normalizeHook(handler);
4379
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4380
- }));
4381
- };
4382
- }
4383
- break;
4384
- }
4385
- case "watchChange": {
4386
- if (batchedHooks.watchChange) {
4387
- const batchedHandlers = batchedHooks.watchChange;
4388
- composed.watchChange = async function(id$1, event) {
4389
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4390
- const { handler: handlerFn } = normalizeHook(handler);
4391
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
4392
- }));
4393
- };
4394
- }
4395
- break;
4396
- }
4397
- case "closeWatcher": {
4398
- if (batchedHooks.closeWatcher) {
4399
- const batchedHandlers = batchedHooks.closeWatcher;
4400
- composed.closeWatcher = async function() {
4401
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4402
- const { handler: handlerFn } = normalizeHook(handler);
4403
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4404
- }));
4405
- };
4406
- }
4407
- break;
4408
- }
4409
- default: {}
4410
- }
4411
- });
4412
- return composed;
4413
- }
4414
- function isComposablePlugin(plugin) {
4415
- if (plugin instanceof BuiltinPlugin) return false;
4416
- if ("_parallel" in plugin) return false;
4417
- const hasNotComposablePattern = t(plugin).some((hookName) => {
4418
- if (!isPluginHookName(hookName)) return false;
4419
- const OK_TO_COMPOSE = false;
4420
- if (isUnsupportedHooks(hookName)) return true;
4421
- if (plugin[hookName]) {
4422
- const { meta } = normalizeHook(plugin[hookName]);
4423
- if (meta.order === "pre" || meta.order === "post") return true;
4424
- }
4425
- return OK_TO_COMPOSE;
4426
- });
4427
- if (hasNotComposablePattern) return false;
4428
- return true;
4429
- }
4430
- function composeJsPlugins(plugins) {
4431
- const newPlugins = [];
4432
- const toBeComposed = [];
4433
- plugins.forEach((plugin) => {
4434
- if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
4435
- else {
4436
- if (toBeComposed.length > 0) {
4437
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4438
- else newPlugins.push(toBeComposed[0]);
4439
- toBeComposed.length = 0;
4440
- }
4441
- newPlugins.push(plugin);
4442
- }
4443
- });
4444
- if (toBeComposed.length > 0) {
4445
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4446
- else newPlugins.push(toBeComposed[0]);
4447
- toBeComposed.length = 0;
4448
- }
4449
- return newPlugins;
4450
- }
4451
-
4452
4159
  //#endregion
4453
4160
  //#region src/utils/initialize-parallel-plugins.ts
4454
4161
  async function initializeParallelPlugins(plugins) {
@@ -4525,7 +4232,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4525
4232
  ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4526
4233
  ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4527
4234
  ];
4528
- if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
4529
4235
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4530
4236
  try {
4531
4237
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -4849,12 +4555,6 @@ Object.defineProperty(exports, 'buildImportAnalysisPlugin', {
4849
4555
  return buildImportAnalysisPlugin;
4850
4556
  }
4851
4557
  });
4852
- Object.defineProperty(exports, 'composeJsPlugins', {
4853
- enumerable: true,
4854
- get: function () {
4855
- return composeJsPlugins;
4856
- }
4857
- });
4858
4558
  Object.defineProperty(exports, 'createBundlerImpl', {
4859
4559
  enumerable: true,
4860
4560
  get: function () {