@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,5 +1,5 @@
1
- import { and, arraify, code, exclude, id, include, isNullish, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-BoWaIc-K.mjs";
2
- import { augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-BzdtcWzA.mjs";
1
+ import { and, arraify, code, exclude, id, include, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-DvBwroyk.mjs";
2
+ import { augmentCodeLocation, error, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-DQEVpsUG.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";
5
5
  import { fileURLToPath } from "node:url";
@@ -33,9 +33,20 @@ 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.24";
37
37
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
38
38
 
39
+ //#endregion
40
+ //#region src/utils/normalize-string-or-regex.ts
41
+ function normalizedStringOrRegex(pattern) {
42
+ if (!pattern) return void 0;
43
+ if (!isReadonlyArray(pattern)) return [pattern];
44
+ return pattern;
45
+ }
46
+ function isReadonlyArray(input) {
47
+ return Array.isArray(input);
48
+ }
49
+
39
50
  //#endregion
40
51
  //#region src/builtin-plugin/utils.ts
41
52
  function makeBuiltinPluginCallable(plugin) {
@@ -65,6 +76,10 @@ function modulePreloadPolyfillPlugin(config) {
65
76
  return new BuiltinPlugin("builtin:module-preload-polyfill", config);
66
77
  }
67
78
  function dynamicImportVarsPlugin(config) {
79
+ if (config) {
80
+ config.include = normalizedStringOrRegex(config.include);
81
+ config.exclude = normalizedStringOrRegex(config.exclude);
82
+ }
68
83
  return new BuiltinPlugin("builtin:dynamic-import-vars", config);
69
84
  }
70
85
  function importGlobPlugin(config) {
@@ -76,8 +91,8 @@ function reporterPlugin(config) {
76
91
  function manifestPlugin(config) {
77
92
  return new BuiltinPlugin("builtin:manifest", config);
78
93
  }
79
- function wasmHelperPlugin() {
80
- return new BuiltinPlugin("builtin:wasm-helper");
94
+ function wasmHelperPlugin(config) {
95
+ return new BuiltinPlugin("builtin:wasm-helper", config);
81
96
  }
82
97
  function wasmFallbackPlugin() {
83
98
  const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
@@ -1873,18 +1888,18 @@ function toJsonSchema(schema, config) {
1873
1888
  //#endregion
1874
1889
  //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
1875
1890
  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);
1891
+ let e, t, r, { defineProperty: n, setPrototypeOf: l, create: o, keys: s } = Object, i$1 = "", { round: c, max: a$1 } = Math, p = (e$1) => {
1892
+ 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
1893
  return [
1879
1894
  n$1 >> 16 & 255,
1880
1895
  n$1 >> 8 & 255,
1881
1896
  255 & n$1
1882
1897
  ];
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);
1898
+ }, 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) => {
1899
+ let t$1, r$1, n$1, l$1, o$1;
1900
+ 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
1901
  }, 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;
1902
+ 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
1903
  try {
1889
1904
  e = "," + s(i$2).join(",");
1890
1905
  } catch (e$1) {
@@ -1897,31 +1912,31 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
1897
1912
  2: 2,
1898
1913
  3: 3
1899
1914
  }[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, {
1915
+ return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t = r$2.TERM, {
1901
1916
  "24bit": 3,
1902
1917
  truecolor: 3,
1903
1918
  ansi256: 2,
1904
1919
  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;
1920
+ }[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
1921
  })(), f = {
1907
1922
  open: i$1,
1908
1923
  close: i$1
1909
- }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$2, close: n$1 }) => {
1924
+ }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$1, close: n$1 }) => {
1910
1925
  let o$1 = (e$2, ...r$1) => {
1911
1926
  if (!e$2) {
1912
- if (t$2 && t$2 === n$1) return t$2;
1927
+ if (t$1 && t$1 === n$1) return t$1;
1913
1928
  if ((e$2 ?? i$1) === i$1) return i$1;
1914
1929
  }
1915
1930
  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
1931
  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;
1932
+ let { open: e$3, close: t$2 } = c$2, r$2 = t$2.length, n$2 = i$1, o$2 = 0;
1933
+ 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
1934
  s$2 = n$2 + s$2.slice(o$2);
1920
1935
  }
1921
1936
  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,
1937
+ }, s$1 = t$1, c$1 = n$1;
1938
+ return e$1 && (s$1 = e$1.o + t$1, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
1939
+ open: t$1,
1925
1940
  close: n$1,
1926
1941
  o: s$1,
1927
1942
  c: c$1,
@@ -1929,27 +1944,27 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
1929
1944
  }, o$1.open = s$1, o$1.close = c$1, o$1;
1930
1945
  };
1931
1946
  const w = function(e$1 = g) {
1932
- let t$2 = {
1947
+ let t$1 = {
1933
1948
  Ansis: w,
1934
1949
  level: e$1,
1935
1950
  isSupported: () => s$1,
1936
1951
  strip: (e$2) => e$2.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i$1),
1937
1952
  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() {
1953
+ for (let t$2 in e$2) {
1954
+ let r$1 = e$2[t$2], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
1955
+ O[t$2] = "f" === l$1 ? { get() {
1941
1956
  return (...e$3) => m(this, r$1(...e$3));
1942
1957
  } } : { get() {
1943
1958
  let e$3 = m(this, o$1);
1944
- return n(this, t$3, { value: e$3 }), e$3;
1959
+ return n(this, t$2, { value: e$3 }), e$3;
1945
1960
  } };
1946
1961
  }
1947
- return r = o({}, O), l(t$2, r), t$2;
1962
+ return r = o({}, O), l(t$1, r), t$1;
1948
1963
  }
1949
- }, s$1 = e$1 > 0, c$1 = (e$2, t$3) => s$1 ? {
1964
+ }, s$1 = e$1 > 0, c$1 = (e$2, t$2) => s$1 ? {
1950
1965
  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);
1966
+ close: `[${t$2}m`
1967
+ } : 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
1968
  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
1969
  let E, M = {
1955
1970
  fg: v,
@@ -1968,9 +1983,9 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
1968
1983
  hidden: c$1(8, 28),
1969
1984
  strikethrough: c$1(9, 29)
1970
1985
  }, 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);
1986
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$2) => {
1987
+ 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);
1988
+ }), t$1.extend(M);
1974
1989
  }, y = new w();
1975
1990
  module.exports = y, y.default = y;
1976
1991
  } });
@@ -2127,6 +2142,7 @@ const TreeshakingOptionsSchema = union([boolean(), looseObject({
2127
2142
  unknownGlobalSideEffects: optional(boolean()),
2128
2143
  commonjs: optional(boolean())
2129
2144
  })]);
2145
+ const OptimizationOptionsSchema = strictObject({ inlineConst: pipe(optional(boolean()), description("Enable crossmodule constant inlining")) });
2130
2146
  const OnLogSchema = pipe(function_(), args(tuple([
2131
2147
  LogLevelSchema,
2132
2148
  RollupLogSchema,
@@ -2152,6 +2168,7 @@ const InputOptionsSchema = strictObject({
2152
2168
  ])), description(`Platform for which the code should be generated (node, ${ansis_default.underline("browser")}, neutral)`)),
2153
2169
  shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
2154
2170
  treeshake: optional(TreeshakingOptionsSchema),
2171
+ optimization: optional(OptimizationOptionsSchema),
2155
2172
  logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${ansis_default.dim("silent")}, ${ansis_default.underline(ansis_default.gray("info"))}, debug, ${ansis_default.yellow("warn")})`)),
2156
2173
  onLog: optional(OnLogSchema),
2157
2174
  onwarn: optional(OnwarnSchema),
@@ -2390,41 +2407,9 @@ function getJsonSchema() {
2390
2407
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2391
2408
  }
2392
2409
 
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
2410
  //#endregion
2426
2411
  //#region src/types/sourcemap.ts
2427
- function bindingifySourcemap(map) {
2412
+ function bindingifySourcemap$1(map) {
2428
2413
  if (map == null) return;
2429
2414
  return { inner: typeof map === "string" ? map : {
2430
2415
  file: map.file ?? void 0,
@@ -2540,8 +2525,8 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2540
2525
  //#endregion
2541
2526
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
2542
2527
  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, {
2528
+ let t$1 = (r$1) => o$1(r$1, ...n$1);
2529
+ return a$2 === void 0 ? t$1 : Object.assign(t$1, {
2545
2530
  lazy: a$2,
2546
2531
  lazyArgs: n$1
2547
2532
  });
@@ -2561,18 +2546,12 @@ function u(r$1, n$1, o$1) {
2561
2546
  function d(...r$1) {
2562
2547
  return u(i, r$1);
2563
2548
  }
2564
- var i = (r$1, t$2) => {
2549
+ var i = (r$1, t$1) => {
2565
2550
  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);
2551
+ 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
2552
  return a$2;
2568
2553
  };
2569
2554
 
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
2555
  //#endregion
2577
2556
  //#region src/plugin/bindingify-hook-filter.ts
2578
2557
  function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
@@ -2877,7 +2856,7 @@ function bindingifyBuildStart(args$1) {
2877
2856
  const { handler, meta } = normalizeHook(hook);
2878
2857
  return {
2879
2858
  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));
2859
+ 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
2860
  },
2882
2861
  meta: bindingifyPluginHookMeta(meta)
2883
2862
  };
@@ -2900,12 +2879,10 @@ function bindingifyResolveId(args$1) {
2900
2879
  return {
2901
2880
  plugin: async (ctx, specifier, importer, extraOptions) => {
2902
2881
  const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
2903
- const newExtraOptions = {
2882
+ 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
2883
  ...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);
2884
+ custom: contextResolveOptions?.custom
2885
+ });
2909
2886
  if (ret == null) return;
2910
2887
  if (ret === false) return {
2911
2888
  id: specifier,
@@ -2976,7 +2953,7 @@ function bindingifyTransform(args$1) {
2976
2953
  });
2977
2954
  return {
2978
2955
  code: ret.code,
2979
- map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2956
+ map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2980
2957
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
2981
2958
  moduleType: ret.moduleType
2982
2959
  };
@@ -3002,7 +2979,7 @@ function bindingifyLoad(args$1) {
3002
2979
  let map = preProcessSourceMap(ret, id$1);
3003
2980
  return {
3004
2981
  code: ret.code,
3005
- map: bindingifySourcemap(map),
2982
+ map: bindingifySourcemap$1(map),
3006
2983
  moduleType: ret.moduleType,
3007
2984
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
3008
2985
  };
@@ -3033,25 +3010,6 @@ function bindingifyModuleParsed(args$1) {
3033
3010
  };
3034
3011
  }
3035
3012
 
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
3013
  //#endregion
3056
3014
  //#region src/utils/transform-rendered-module.ts
3057
3015
  function transformToRenderedModule(bindingRenderedModule) {
@@ -3118,338 +3076,125 @@ function transformChunkModules(modules) {
3118
3076
  }
3119
3077
 
3120
3078
  //#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
3079
+ //#region src/utils/transform-to-rollup-output.ts
3080
+ function transformToRollupSourceMap(map) {
3081
+ const parsed = JSON.parse(map);
3082
+ const obj = {
3083
+ ...parsed,
3084
+ toString() {
3085
+ return JSON.stringify(obj);
3086
+ },
3087
+ toUrl() {
3088
+ return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
3089
+ }
3159
3090
  };
3091
+ return obj;
3160
3092
  }
3161
- function bindingifyAddon(configAddon) {
3162
- return async (chunk) => {
3163
- if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3164
- return configAddon || "";
3093
+ function transformToRollupOutputChunk(bindingChunk, changed) {
3094
+ const chunk = {
3095
+ type: "chunk",
3096
+ get code() {
3097
+ return bindingChunk.code;
3098
+ },
3099
+ fileName: bindingChunk.fileName,
3100
+ name: bindingChunk.name,
3101
+ get modules() {
3102
+ return transformChunkModules(bindingChunk.modules);
3103
+ },
3104
+ get imports() {
3105
+ return bindingChunk.imports;
3106
+ },
3107
+ get dynamicImports() {
3108
+ return bindingChunk.dynamicImports;
3109
+ },
3110
+ exports: bindingChunk.exports,
3111
+ isEntry: bindingChunk.isEntry,
3112
+ facadeModuleId: bindingChunk.facadeModuleId || null,
3113
+ isDynamicEntry: bindingChunk.isDynamicEntry,
3114
+ get moduleIds() {
3115
+ return bindingChunk.moduleIds;
3116
+ },
3117
+ get map() {
3118
+ return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
3119
+ },
3120
+ sourcemapFileName: bindingChunk.sourcemapFileName || null,
3121
+ preliminaryFileName: bindingChunk.preliminaryFileName
3165
3122
  };
3123
+ const cache = {};
3124
+ return new Proxy(chunk, {
3125
+ get(target, p$1) {
3126
+ if (p$1 in cache) return cache[p$1];
3127
+ const value = target[p$1];
3128
+ cache[p$1] = value;
3129
+ return value;
3130
+ },
3131
+ set(target, p$1, newValue) {
3132
+ cache[p$1] = newValue;
3133
+ changed?.updated.add(bindingChunk.fileName);
3134
+ return true;
3135
+ },
3136
+ has(target, p$1) {
3137
+ if (p$1 in cache) return true;
3138
+ return p$1 in target;
3139
+ }
3140
+ });
3166
3141
  }
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
- }
3142
+ function transformToRollupOutputAsset(bindingAsset, changed) {
3143
+ const asset = {
3144
+ type: "asset",
3145
+ fileName: bindingAsset.fileName,
3146
+ originalFileName: bindingAsset.originalFileName || null,
3147
+ originalFileNames: bindingAsset.originalFileNames,
3148
+ get source() {
3149
+ return transformAssetSource(bindingAsset.source);
3150
+ },
3151
+ name: bindingAsset.name ?? void 0,
3152
+ names: bindingAsset.names
3153
+ };
3154
+ const cache = {};
3155
+ return new Proxy(asset, {
3156
+ get(target, p$1) {
3157
+ if (p$1 in cache) return cache[p$1];
3158
+ const value = target[p$1];
3159
+ cache[p$1] = value;
3160
+ return value;
3161
+ },
3162
+ set(target, p$1, newValue) {
3163
+ cache[p$1] = newValue;
3164
+ changed?.updated.add(bindingAsset.fileName);
3165
+ return true;
3166
+ }
3167
+ });
3179
3168
  }
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
- }
3169
+ function transformToRollupOutput(output, changed) {
3170
+ handleOutputErrors(output);
3171
+ const { chunks, assets } = output;
3172
+ return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
3189
3173
  }
3190
- function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3191
- return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3174
+ function handleOutputErrors(output) {
3175
+ const rawErrors = output.errors;
3176
+ if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
3192
3177
  }
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;
3203
- }
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
- });
3178
+ function transformToOutputBundle(context, output, changed) {
3179
+ const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
3180
+ return new Proxy(bundle, {
3181
+ set(_target, _p, _newValue, _receiver) {
3182
+ const originalStackTraceLimit = Error.stackTraceLimit;
3183
+ Error.stackTraceLimit = 2;
3184
+ 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.";
3185
+ const stack = new Error(message).stack ?? message;
3186
+ Error.stackTraceLimit = originalStackTraceLimit;
3187
+ context.warn({
3188
+ message: stack,
3189
+ code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
3190
+ });
3191
+ return true;
3192
+ },
3193
+ deleteProperty(target, property) {
3194
+ if (typeof property === "string") changed.deleted.add(property);
3195
+ return true;
3196
+ }
3197
+ });
3453
3198
  }
3454
3199
  function collectChangedBundle(changed, bundle) {
3455
3200
  const assets = [];
@@ -3475,7 +3220,7 @@ function collectChangedBundle(changed, bundle) {
3475
3220
  facadeModuleId: item.facadeModuleId || void 0,
3476
3221
  isDynamicEntry: item.isDynamicEntry,
3477
3222
  moduleIds: item.moduleIds,
3478
- map: bindingifySourcemap(item.map),
3223
+ map: bindingifySourcemap$1(item.map),
3479
3224
  sourcemapFilename: item.sourcemapFileName || void 0,
3480
3225
  preliminaryFilename: item.preliminaryFileName
3481
3226
  });
@@ -3495,7 +3240,7 @@ function bindingifyRenderStart(args$1) {
3495
3240
  const { handler, meta } = normalizeHook(hook);
3496
3241
  return {
3497
3242
  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));
3243
+ 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
3244
  },
3500
3245
  meta: bindingifyPluginHookMeta(meta)
3501
3246
  };
@@ -3507,13 +3252,13 @@ function bindingifyRenderChunk(args$1) {
3507
3252
  return {
3508
3253
  plugin: async (ctx, code$1, chunk, opts, meta$1) => {
3509
3254
  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());
3255
+ 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
3256
  if (ret == null) return;
3512
3257
  if (typeof ret === "string") return { code: ret };
3513
3258
  if (!ret.map) return { code: ret.code };
3514
3259
  return {
3515
3260
  code: ret.code,
3516
- map: bindingifySourcemap(ret.map)
3261
+ map: bindingifySourcemap$1(ret.map)
3517
3262
  };
3518
3263
  },
3519
3264
  meta: bindingifyPluginHookMeta(meta),
@@ -3554,7 +3299,7 @@ function bindingifyGenerateBundle(args$1) {
3554
3299
  };
3555
3300
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3556
3301
  const output = transformToOutputBundle(context, bundle, changed);
3557
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output, isWrite);
3302
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
3558
3303
  return collectChangedBundle(changed, output);
3559
3304
  },
3560
3305
  meta: bindingifyPluginHookMeta(meta)
@@ -3572,7 +3317,7 @@ function bindingifyWriteBundle(args$1) {
3572
3317
  };
3573
3318
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3574
3319
  const output = transformToOutputBundle(context, bundle, changed);
3575
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output);
3320
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
3576
3321
  return collectChangedBundle(changed, output);
3577
3322
  },
3578
3323
  meta: bindingifyPluginHookMeta(meta)
@@ -3847,23 +3592,284 @@ function wrapHandlers(plugin) {
3847
3592
  }
3848
3593
 
3849
3594
  //#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
- }
3595
+ //#region src/options/normalized-input-options.ts
3596
+ var NormalizedInputOptionsImpl = class {
3597
+ inner;
3598
+ constructor(inner, onLog) {
3599
+ this.onLog = onLog;
3600
+ this.inner = inner;
3601
+ }
3602
+ get shimMissingExports() {
3603
+ return this.inner.shimMissingExports;
3604
+ }
3605
+ get input() {
3606
+ return this.inner.input;
3607
+ }
3608
+ get cwd() {
3609
+ return this.inner.cwd ?? void 0;
3610
+ }
3611
+ get platform() {
3612
+ return this.inner.platform;
3613
+ }
3614
+ };
3615
+
3616
+ //#endregion
3617
+ //#region src/types/chunking-context.ts
3618
+ var ChunkingContextImpl = class {
3619
+ constructor(context) {
3620
+ this.context = context;
3621
+ }
3622
+ getModuleInfo(moduleId) {
3623
+ const bindingInfo = this.context.getModuleInfo(moduleId);
3624
+ if (bindingInfo) {
3625
+ const info = transformModuleInfo(bindingInfo, {
3626
+ moduleSideEffects: null,
3627
+ meta: {}
3628
+ });
3629
+ return info;
3630
+ }
3631
+ return null;
3632
+ }
3633
+ };
3634
+
3635
+ //#endregion
3636
+ //#region src/utils/bindingify-output-options.ts
3637
+ function bindingifyOutputOptions(outputOptions) {
3638
+ 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;
3639
+ const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3640
+ return {
3641
+ dir,
3642
+ file: file == null ? void 0 : file,
3643
+ format: bindingifyFormat(format),
3644
+ exports,
3645
+ hashCharacters,
3646
+ sourcemap: bindingifySourcemap(sourcemap),
3647
+ sourcemapDebugIds,
3648
+ sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3649
+ sourcemapPathTransform,
3650
+ banner: bindingifyAddon(banner),
3651
+ footer: bindingifyAddon(footer),
3652
+ intro: bindingifyAddon(intro),
3653
+ outro: bindingifyAddon(outro),
3654
+ extend: outputOptions.extend,
3655
+ globals,
3656
+ esModule,
3657
+ name,
3658
+ assetFileNames: bindingifyAssetFilenames(assetFileNames),
3659
+ entryFileNames,
3660
+ chunkFileNames,
3661
+ cssEntryFileNames,
3662
+ cssChunkFileNames,
3663
+ plugins: [],
3664
+ minify: outputOptions.minify,
3665
+ externalLiveBindings: outputOptions.externalLiveBindings,
3666
+ inlineDynamicImports: outputOptions.inlineDynamicImports,
3667
+ advancedChunks,
3668
+ polyfillRequire: outputOptions.polyfillRequire,
3669
+ sanitizeFileName,
3670
+ preserveModules,
3671
+ virtualDirname,
3672
+ legalComments,
3673
+ preserveModulesRoot
3674
+ };
3675
+ }
3676
+ function bindingifyAddon(configAddon) {
3677
+ return async (chunk) => {
3678
+ if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3679
+ return configAddon || "";
3680
+ };
3681
+ }
3682
+ function bindingifyFormat(format) {
3683
+ switch (format) {
3684
+ case void 0:
3685
+ case "es":
3686
+ case "esm":
3687
+ case "module": return "es";
3688
+ case "cjs":
3689
+ case "commonjs": return "cjs";
3690
+ case "iife": return "iife";
3691
+ case "umd": return "umd";
3692
+ default: unimplemented(`output.format: ${format}`);
3693
+ }
3694
+ }
3695
+ function bindingifySourcemap(sourcemap) {
3696
+ switch (sourcemap) {
3697
+ case true: return "file";
3698
+ case "inline": return "inline";
3699
+ case false:
3700
+ case void 0: return void 0;
3701
+ case "hidden": return "hidden";
3702
+ default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3703
+ }
3704
+ }
3705
+ function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3706
+ return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3707
+ }
3708
+ function bindingifyAssetFilenames(assetFileNames) {
3709
+ if (typeof assetFileNames === "function") return (asset) => {
3710
+ return assetFileNames({
3711
+ names: asset.names,
3712
+ originalFileNames: asset.originalFileNames,
3713
+ source: transformAssetSource(asset.source),
3714
+ type: "asset"
3715
+ });
3716
+ };
3717
+ return assetFileNames;
3718
+ }
3719
+ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
3720
+ if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3721
+ else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
3722
+ return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
3723
+ } }] };
3724
+ if (advancedChunks == null) return void 0;
3725
+ const { groups,...restAdvancedChunks } = advancedChunks;
3726
+ return {
3727
+ ...restAdvancedChunks,
3728
+ groups: groups?.map((group) => {
3729
+ const { name,...restGroup } = group;
3730
+ return {
3731
+ ...restGroup,
3732
+ name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContextImpl(ctx)) : name
3733
+ };
3734
+ })
3735
+ };
3736
+ }
3737
+
3738
+ //#endregion
3739
+ //#region src/options/normalized-output-options.ts
3740
+ var NormalizedOutputOptionsImpl = class {
3741
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
3742
+ this.inner = inner;
3743
+ this.outputOptions = outputOptions;
3744
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3745
+ }
3746
+ get dir() {
3747
+ return this.inner.dir ?? void 0;
3748
+ }
3749
+ get entryFileNames() {
3750
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3751
+ }
3752
+ get chunkFileNames() {
3753
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3754
+ }
3755
+ get assetFileNames() {
3756
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3757
+ }
3758
+ get format() {
3759
+ return this.inner.format;
3760
+ }
3761
+ get exports() {
3762
+ return this.inner.exports;
3763
+ }
3764
+ get sourcemap() {
3765
+ return this.inner.sourcemap;
3766
+ }
3767
+ get cssEntryFileNames() {
3768
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3769
+ }
3770
+ get cssChunkFileNames() {
3771
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3772
+ }
3773
+ get shimMissingExports() {
3774
+ return this.inner.shimMissingExports;
3775
+ }
3776
+ get name() {
3777
+ return this.inner.name ?? void 0;
3778
+ }
3779
+ get file() {
3780
+ return this.inner.file ?? void 0;
3781
+ }
3782
+ get inlineDynamicImports() {
3783
+ return this.inner.inlineDynamicImports;
3784
+ }
3785
+ get externalLiveBindings() {
3786
+ return this.inner.externalLiveBindings;
3787
+ }
3788
+ get banner() {
3789
+ return normalizeAddon(this.outputOptions.banner);
3790
+ }
3791
+ get footer() {
3792
+ return normalizeAddon(this.outputOptions.footer);
3793
+ }
3794
+ get intro() {
3795
+ return normalizeAddon(this.outputOptions.intro);
3796
+ }
3797
+ get outro() {
3798
+ return normalizeAddon(this.outputOptions.outro);
3799
+ }
3800
+ get esModule() {
3801
+ return this.inner.esModule;
3802
+ }
3803
+ get extend() {
3804
+ return this.inner.extend;
3805
+ }
3806
+ get globals() {
3807
+ return this.inner.globals || this.outputOptions.globals;
3808
+ }
3809
+ get hashCharacters() {
3810
+ return this.inner.hashCharacters;
3811
+ }
3812
+ get sourcemapDebugIds() {
3813
+ return this.inner.sourcemapDebugIds;
3814
+ }
3815
+ get sourcemapIgnoreList() {
3816
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3817
+ }
3818
+ get sourcemapPathTransform() {
3819
+ return this.outputOptions.sourcemapPathTransform;
3820
+ }
3821
+ get minify() {
3822
+ return this.inner.minify;
3823
+ }
3824
+ get legalComments() {
3825
+ return this.inner.legalComments;
3826
+ }
3827
+ get polyfillRequire() {
3828
+ return this.inner.polyfillRequire;
3829
+ }
3830
+ get plugins() {
3831
+ return this.normalizedOutputPlugins;
3832
+ }
3833
+ get preserveModules() {
3834
+ return this.inner.preserveModules;
3835
+ }
3836
+ get preserveModulesRoot() {
3837
+ return this.inner.preserveModulesRoot;
3838
+ }
3839
+ get virtualDirname() {
3840
+ return this.inner.virtualDirname;
3841
+ }
3842
+ };
3843
+ function normalizeAddon(value) {
3844
+ if (typeof value === "function") return value;
3845
+ return () => value || "";
3846
+ }
3847
+
3848
+ //#endregion
3849
+ //#region src/plugin/plugin-context-data.ts
3850
+ var PluginContextData = class {
3851
+ moduleOptionMap = /* @__PURE__ */ new Map();
3852
+ resolveOptionsMap = /* @__PURE__ */ new Map();
3853
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
3854
+ loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3855
+ renderedChunkMeta = null;
3856
+ normalizedInputOptions = null;
3857
+ normalizedOutputOptions = null;
3858
+ constructor(onLog, outputOptions, normalizedOutputPlugins) {
3859
+ this.onLog = onLog;
3860
+ this.outputOptions = outputOptions;
3861
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3862
+ }
3863
+ updateModuleOption(id$1, option) {
3864
+ const existing = this.moduleOptionMap.get(id$1);
3865
+ if (existing) {
3866
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3867
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
3868
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
3869
+ } else {
3870
+ this.moduleOptionMap.set(id$1, option);
3871
+ return option;
3872
+ }
3867
3873
  return existing;
3868
3874
  }
3869
3875
  getModuleOption(id$1) {
@@ -3924,6 +3930,14 @@ var PluginContextData = class {
3924
3930
  getRenderChunkMeta() {
3925
3931
  return this.renderedChunkMeta;
3926
3932
  }
3933
+ getInputOptions(opts) {
3934
+ this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
3935
+ return this.normalizedInputOptions;
3936
+ }
3937
+ getOutputOptions(opts) {
3938
+ this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
3939
+ return this.normalizedOutputOptions;
3940
+ }
3927
3941
  markModuleLoaded(id$1, _success) {
3928
3942
  const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
3929
3943
  if (resolve) resolve();
@@ -3935,28 +3949,16 @@ var PluginContextData = class {
3935
3949
  }
3936
3950
  };
3937
3951
 
3938
- //#endregion
3939
- //#region src/utils/normalize-string-or-regex.ts
3940
- function normalizedStringOrRegex(pattern) {
3941
- if (!pattern) return void 0;
3942
- if (!isReadonlyArray(pattern)) return [pattern];
3943
- return pattern;
3944
- }
3945
- function isReadonlyArray(input) {
3946
- return Array.isArray(input);
3947
- }
3948
-
3949
3952
  //#endregion
3950
3953
  //#region src/utils/bindingify-input-options.ts
3951
3954
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3952
- const pluginContextData = new PluginContextData();
3955
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3953
3956
  const plugins = rawPlugins.map((plugin) => {
3954
3957
  if ("_parallel" in plugin) return void 0;
3955
3958
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
3956
3959
  return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
3957
3960
  });
3958
- const { jsx, jsxTransform } = bindingifyJsx(inputOptions.jsx);
3959
- const transform = inputOptions.transform || jsxTransform;
3961
+ const { jsx, transform } = bindingifyJsx(onLog, inputOptions.jsx, inputOptions.transform);
3960
3962
  return {
3961
3963
  input: bindingifyInput(inputOptions.input),
3962
3964
  plugins,
@@ -4000,7 +4002,8 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
4000
4002
  debug: inputOptions.debug,
4001
4003
  invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
4002
4004
  markModuleLoaded: pluginContextData.markModuleLoaded.bind(pluginContextData),
4003
- preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures)
4005
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
4006
+ optimization: inputOptions.optimization
4004
4007
  };
4005
4008
  }
4006
4009
  function bindingifyHmr(hmr) {
@@ -4090,24 +4093,45 @@ function bindingifyInput(input) {
4090
4093
  };
4091
4094
  });
4092
4095
  }
4093
- function bindingifyJsx(input) {
4096
+ function bindingifyJsx(onLog, input, transform) {
4097
+ if (transform?.jsx) {
4098
+ if (input !== void 0) onLog(LOG_LEVEL_WARN, logDuplicateJsxConfig());
4099
+ return { transform };
4100
+ }
4094
4101
  if (typeof input === "object") {
4095
- if (input.mode === "preserve") return { jsx: BindingJsx.Preserve };
4102
+ if (input.mode === "preserve") return {
4103
+ jsx: BindingJsx.Preserve,
4104
+ transform
4105
+ };
4096
4106
  const mode = input.mode ?? "automatic";
4097
- return { jsxTransform: { jsx: {
4107
+ transform ??= {};
4108
+ transform.jsx = {
4098
4109
  runtime: mode,
4099
4110
  pragma: input.factory,
4100
4111
  pragmaFrag: input.fragment,
4101
4112
  importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0
4102
- } } };
4113
+ };
4114
+ return { transform };
4103
4115
  }
4116
+ let jsx;
4104
4117
  switch (input) {
4105
- case false: return { jsx: BindingJsx.Disable };
4106
- case "react": return { jsx: BindingJsx.React };
4107
- case "react-jsx": return { jsx: BindingJsx.ReactJsx };
4108
- case "preserve": return { jsx: BindingJsx.Preserve };
4109
- default: return { jsx: void 0 };
4118
+ case false:
4119
+ jsx = BindingJsx.Disable;
4120
+ break;
4121
+ case "react":
4122
+ jsx = BindingJsx.React;
4123
+ break;
4124
+ case "react-jsx":
4125
+ jsx = BindingJsx.ReactJsx;
4126
+ break;
4127
+ case "preserve":
4128
+ jsx = BindingJsx.Preserve;
4129
+ break;
4110
4130
  }
4131
+ return {
4132
+ jsx,
4133
+ transform
4134
+ };
4111
4135
  }
4112
4136
  function bindingifyWatch(watch$1) {
4113
4137
  if (watch$1) return {
@@ -4157,323 +4181,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4157
4181
  };
4158
4182
  }
4159
4183
 
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
4184
  //#endregion
4478
4185
  //#region src/utils/initialize-parallel-plugins.ts
4479
4186
  async function initializeParallelPlugins(plugins) {
@@ -4550,7 +4257,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4550
4257
  ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4551
4258
  ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4552
4259
  ];
4553
- if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
4554
4260
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4555
4261
  try {
4556
4262
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -4820,4 +4526,4 @@ function defineConfig(config) {
4820
4526
  const VERSION = version;
4821
4527
 
4822
4528
  //#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 };
4529
+ 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 };