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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cli.cjs +3 -3
  2. package/dist/cli.mjs +3 -3
  3. package/dist/config.cjs +3 -3
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +3 -3
  7. package/dist/experimental-index.browser.mjs +2 -2
  8. package/dist/experimental-index.cjs +2 -3
  9. package/dist/experimental-index.d.cts +3 -6
  10. package/dist/experimental-index.d.mts +3 -6
  11. package/dist/experimental-index.mjs +3 -3
  12. package/dist/filter-index.cjs +1 -1
  13. package/dist/filter-index.d.cts +2 -2
  14. package/dist/filter-index.d.mts +2 -2
  15. package/dist/filter-index.mjs +1 -1
  16. package/dist/index.browser.mjs +1 -1
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.d.cts +3 -3
  19. package/dist/index.d.mts +3 -3
  20. package/dist/index.mjs +2 -2
  21. package/dist/parallel-plugin-worker.cjs +3 -3
  22. package/dist/parallel-plugin-worker.mjs +3 -3
  23. package/dist/parallel-plugin.d.cts +2 -2
  24. package/dist/parallel-plugin.d.mts +2 -2
  25. package/dist/parse-ast-index.d.cts +1 -1
  26. package/dist/parse-ast-index.d.mts +1 -1
  27. package/dist/rolldown-binding.wasi-browser.js +1 -0
  28. package/dist/rolldown-binding.wasi.cjs +1 -0
  29. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  30. package/dist/shared/{binding--Ro_HG7S.d.mts → binding-CMKStSph.d.cts} +5 -1
  31. package/dist/shared/{binding-DBnJxycu.d.cts → binding-DB58iXP8.d.mts} +5 -1
  32. package/dist/shared/{define-config-3jyxkSn6.d.mts → define-config-BRkYSF9E.d.cts} +30 -30
  33. package/dist/shared/{define-config-LuFmoc43.d.cts → define-config-CqVfqfZQ.d.mts} +30 -30
  34. package/dist/shared/{dist-BMVjvV-v.cjs → dist-BVAp8sOm.cjs} +0 -9
  35. package/dist/shared/{dist-BoWaIc-K.mjs → dist-DvBwroyk.mjs} +1 -4
  36. package/dist/shared/{load-config-DnUMpIsk.mjs → load-config-BWbXOTbl.mjs} +1 -1
  37. package/dist/shared/{load-config--g9e2MRO.cjs → load-config-Bh2dNRk9.cjs} +1 -1
  38. package/dist/shared/{src-DLhNmBff.mjs → src-BA5CL--T.mjs} +354 -635
  39. package/dist/shared/{src-B3ZW8_Y7.cjs → src-Co_Bf7DL.cjs} +353 -640
  40. package/dist/{src-jKfrtJ37.js → src-C1KTaRyZ.js} +383 -667
  41. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-DDkG_k5U.cjs');
2
- const require_dist = require('./dist-BMVjvV-v.cjs');
2
+ const require_dist = require('./dist-BVAp8sOm.cjs');
3
3
  const require_parse_ast_index = require('./parse-ast-index-CGTVCgvx.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"));
@@ -8,7 +8,7 @@ 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.21";
11
+ var version = "1.0.0-beta.23";
12
12
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
13
 
14
14
  //#endregion
@@ -51,8 +51,8 @@ function reporterPlugin(config) {
51
51
  function manifestPlugin(config) {
52
52
  return new BuiltinPlugin("builtin:manifest", config);
53
53
  }
54
- function wasmHelperPlugin() {
55
- return new BuiltinPlugin("builtin:wasm-helper");
54
+ function wasmHelperPlugin(config) {
55
+ return new BuiltinPlugin("builtin:wasm-helper", config);
56
56
  }
57
57
  function wasmFallbackPlugin() {
58
58
  const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
@@ -1848,18 +1848,18 @@ function toJsonSchema(schema, config) {
1848
1848
  //#endregion
1849
1849
  //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
1850
1850
  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);
1851
+ let e, t, r, { defineProperty: n, setPrototypeOf: l, create: o, keys: s } = Object, i$1 = "", { round: c, max: a$1 } = Math, p = (e$1) => {
1852
+ 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
1853
  return [
1854
1854
  n$1 >> 16 & 255,
1855
1855
  n$1 >> 8 & 255,
1856
1856
  255 & n$1
1857
1857
  ];
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);
1858
+ }, 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) => {
1859
+ let t$1, 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$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
1861
  }, 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;
1862
+ 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
1863
  try {
1864
1864
  e = "," + s(i$2).join(",");
1865
1865
  } catch (e$1) {
@@ -1872,31 +1872,31 @@ var require_ansis = require_chunk.__commonJS({ "../../node_modules/.pnpm/ansis@4
1872
1872
  2: 2,
1873
1873
  3: 3
1874
1874
  }[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, {
1875
+ return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t = r$2.TERM, {
1876
1876
  "24bit": 3,
1877
1877
  truecolor: 3,
1878
1878
  ansi256: 2,
1879
1879
  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;
1880
+ }[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
1881
  })(), f = {
1882
1882
  open: i$1,
1883
1883
  close: i$1
1884
- }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$2, close: n$1 }) => {
1884
+ }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$1, close: n$1 }) => {
1885
1885
  let o$1 = (e$2, ...r$1) => {
1886
1886
  if (!e$2) {
1887
- if (t$2 && t$2 === n$1) return t$2;
1887
+ if (t$1 && t$1 === n$1) return t$1;
1888
1888
  if ((e$2 ?? i$1) === i$1) return i$1;
1889
1889
  }
1890
1890
  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
1891
  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;
1892
+ let { open: e$3, close: t$2 } = c$2, r$2 = t$2.length, n$2 = i$1, o$2 = 0;
1893
+ 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
1894
  s$2 = n$2 + s$2.slice(o$2);
1895
1895
  }
1896
1896
  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,
1897
+ }, s$1 = t$1, c$1 = n$1;
1898
+ return e$1 && (s$1 = e$1.o + t$1, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
1899
+ open: t$1,
1900
1900
  close: n$1,
1901
1901
  o: s$1,
1902
1902
  c: c$1,
@@ -1904,27 +1904,27 @@ var require_ansis = require_chunk.__commonJS({ "../../node_modules/.pnpm/ansis@4
1904
1904
  }, o$1.open = s$1, o$1.close = c$1, o$1;
1905
1905
  };
1906
1906
  const w = function(e$1 = g) {
1907
- let t$2 = {
1907
+ let t$1 = {
1908
1908
  Ansis: w,
1909
1909
  level: e$1,
1910
1910
  isSupported: () => s$1,
1911
1911
  strip: (e$2) => e$2.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i$1),
1912
1912
  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() {
1913
+ for (let t$2 in e$2) {
1914
+ let r$1 = e$2[t$2], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
1915
+ O[t$2] = "f" === l$1 ? { get() {
1916
1916
  return (...e$3) => m(this, r$1(...e$3));
1917
1917
  } } : { get() {
1918
1918
  let e$3 = m(this, o$1);
1919
- return n(this, t$3, { value: e$3 }), e$3;
1919
+ return n(this, t$2, { value: e$3 }), e$3;
1920
1920
  } };
1921
1921
  }
1922
- return r = o({}, O), l(t$2, r), t$2;
1922
+ return r = o({}, O), l(t$1, r), t$1;
1923
1923
  }
1924
- }, s$1 = e$1 > 0, c$1 = (e$2, t$3) => s$1 ? {
1924
+ }, s$1 = e$1 > 0, c$1 = (e$2, t$2) => s$1 ? {
1925
1925
  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);
1926
+ close: `[${t$2}m`
1927
+ } : 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
1928
  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
1929
  let E, M = {
1930
1930
  fg: v,
@@ -1943,9 +1943,9 @@ var require_ansis = require_chunk.__commonJS({ "../../node_modules/.pnpm/ansis@4
1943
1943
  hidden: c$1(8, 28),
1944
1944
  strikethrough: c$1(9, 29)
1945
1945
  }, 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);
1946
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$2) => {
1947
+ 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);
1948
+ }), t$1.extend(M);
1949
1949
  }, y = new w();
1950
1950
  module.exports = y, y.default = y;
1951
1951
  } });
@@ -2099,7 +2099,8 @@ const ResolveOptionsSchema = strictObject({
2099
2099
  const TreeshakingOptionsSchema = union([boolean(), looseObject({
2100
2100
  annotations: optional(boolean()),
2101
2101
  manualPureFunctions: optional(array(string())),
2102
- unknownGlobalSideEffects: optional(boolean())
2102
+ unknownGlobalSideEffects: optional(boolean()),
2103
+ commonjs: optional(boolean())
2103
2104
  })]);
2104
2105
  const OnLogSchema = pipe(function_(), args(tuple([
2105
2106
  LogLevelSchema,
@@ -2364,41 +2365,9 @@ function getJsonSchema() {
2364
2365
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2365
2366
  }
2366
2367
 
2367
- //#endregion
2368
- //#region src/constants/plugin-context.ts
2369
- /**
2370
- * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2371
- * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2372
- * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2373
- * internally.
2374
- */
2375
- const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2376
-
2377
- //#endregion
2378
- //#region src/options/normalized-input-options.ts
2379
- var NormalizedInputOptionsImpl = class {
2380
- inner;
2381
- constructor(inner, onLog) {
2382
- this.onLog = onLog;
2383
- this.inner = inner;
2384
- }
2385
- get shimMissingExports() {
2386
- return this.inner.shimMissingExports;
2387
- }
2388
- get input() {
2389
- return this.inner.input;
2390
- }
2391
- get cwd() {
2392
- return this.inner.cwd ?? void 0;
2393
- }
2394
- get platform() {
2395
- return this.inner.platform;
2396
- }
2397
- };
2398
-
2399
2368
  //#endregion
2400
2369
  //#region src/types/sourcemap.ts
2401
- function bindingifySourcemap(map) {
2370
+ function bindingifySourcemap$1(map) {
2402
2371
  if (map == null) return;
2403
2372
  return { inner: typeof map === "string" ? map : {
2404
2373
  file: map.file ?? void 0,
@@ -2514,8 +2483,8 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2514
2483
  //#endregion
2515
2484
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
2516
2485
  function u$1(o$1, n$1, a$2) {
2517
- let t$2 = (r$1) => o$1(r$1, ...n$1);
2518
- return a$2 === void 0 ? t$2 : Object.assign(t$2, {
2486
+ let t$1 = (r$1) => o$1(r$1, ...n$1);
2487
+ return a$2 === void 0 ? t$1 : Object.assign(t$1, {
2519
2488
  lazy: a$2,
2520
2489
  lazyArgs: n$1
2521
2490
  });
@@ -2535,18 +2504,12 @@ function u(r$1, n$1, o$1) {
2535
2504
  function d(...r$1) {
2536
2505
  return u(i, r$1);
2537
2506
  }
2538
- var i = (r$1, t$2) => {
2507
+ var i = (r$1, t$1) => {
2539
2508
  let a$2 = [[], []];
2540
- 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);
2509
+ 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);
2541
2510
  return a$2;
2542
2511
  };
2543
2512
 
2544
- //#endregion
2545
- //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
2546
- function t(...n$1) {
2547
- return u(Object.keys, n$1);
2548
- }
2549
-
2550
2513
  //#endregion
2551
2514
  //#region src/plugin/bindingify-hook-filter.ts
2552
2515
  function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
@@ -2758,9 +2721,14 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
2758
2721
  async resolve(source, importer, options) {
2759
2722
  let receipt = void 0;
2760
2723
  if (options != null) receipt = this.data.saveResolveOptions(options);
2724
+ const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
2725
+ if (key.startsWith("vite:")) (acc ??= {})[key] = value;
2726
+ return acc;
2727
+ }, void 0);
2761
2728
  const res = await this.context.resolve(source, importer, {
2762
2729
  custom: receipt,
2763
- skipSelf: options?.skipSelf
2730
+ skipSelf: options?.skipSelf,
2731
+ vitePluginCustom
2764
2732
  });
2765
2733
  if (receipt != null) this.data.removeSavedResolveOptions(receipt);
2766
2734
  if (res == null) return null;
@@ -2846,7 +2814,7 @@ function bindingifyBuildStart(args$1) {
2846
2814
  const { handler, meta } = normalizeHook(hook);
2847
2815
  return {
2848
2816
  plugin: async (ctx, opts) => {
2849
- 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));
2817
+ 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));
2850
2818
  },
2851
2819
  meta: bindingifyPluginHookMeta(meta)
2852
2820
  };
@@ -2869,12 +2837,10 @@ function bindingifyResolveId(args$1) {
2869
2837
  return {
2870
2838
  plugin: async (ctx, specifier, importer, extraOptions) => {
2871
2839
  const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
2872
- const newExtraOptions = {
2840
+ 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, {
2873
2841
  ...extraOptions,
2874
- custom: contextResolveOptions?.custom,
2875
- [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
2876
- };
2877
- 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);
2842
+ custom: contextResolveOptions?.custom
2843
+ });
2878
2844
  if (ret == null) return;
2879
2845
  if (ret === false) return {
2880
2846
  id: specifier,
@@ -2945,7 +2911,7 @@ function bindingifyTransform(args$1) {
2945
2911
  });
2946
2912
  return {
2947
2913
  code: ret.code,
2948
- map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2914
+ map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2949
2915
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
2950
2916
  moduleType: ret.moduleType
2951
2917
  };
@@ -2971,7 +2937,7 @@ function bindingifyLoad(args$1) {
2971
2937
  let map = preProcessSourceMap(ret, id$1);
2972
2938
  return {
2973
2939
  code: ret.code,
2974
- map: bindingifySourcemap(map),
2940
+ map: bindingifySourcemap$1(map),
2975
2941
  moduleType: ret.moduleType,
2976
2942
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
2977
2943
  };
@@ -3067,205 +3033,6 @@ function transformChunkModules(modules) {
3067
3033
  return result;
3068
3034
  }
3069
3035
 
3070
- //#endregion
3071
- //#region src/utils/bindingify-output-options.ts
3072
- function bindingifyOutputOptions(outputOptions) {
3073
- 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;
3074
- let { advancedChunks } = outputOptions;
3075
- if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3076
- else if (manualChunks != null) advancedChunks = { groups: [{ name(id$1) {
3077
- return manualChunks(id$1, {});
3078
- } }] };
3079
- return {
3080
- dir,
3081
- file: file == null ? void 0 : file,
3082
- format: bindingifyFormat(format),
3083
- exports: exports$1,
3084
- hashCharacters,
3085
- sourcemap: bindingifySourcemap$1(sourcemap),
3086
- sourcemapDebugIds,
3087
- sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3088
- sourcemapPathTransform,
3089
- banner: bindingifyAddon(banner),
3090
- footer: bindingifyAddon(footer),
3091
- intro: bindingifyAddon(intro),
3092
- outro: bindingifyAddon(outro),
3093
- extend: outputOptions.extend,
3094
- globals,
3095
- esModule,
3096
- name,
3097
- assetFileNames: bindingifyAssetFilenames(assetFileNames),
3098
- entryFileNames,
3099
- chunkFileNames,
3100
- cssEntryFileNames,
3101
- cssChunkFileNames,
3102
- plugins: [],
3103
- minify: outputOptions.minify,
3104
- externalLiveBindings: outputOptions.externalLiveBindings,
3105
- inlineDynamicImports: outputOptions.inlineDynamicImports,
3106
- advancedChunks,
3107
- polyfillRequire: outputOptions.polyfillRequire,
3108
- sanitizeFileName,
3109
- preserveModules,
3110
- virtualDirname,
3111
- legalComments,
3112
- preserveModulesRoot
3113
- };
3114
- }
3115
- function bindingifyAddon(configAddon) {
3116
- return async (chunk) => {
3117
- if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3118
- return configAddon || "";
3119
- };
3120
- }
3121
- function bindingifyFormat(format) {
3122
- switch (format) {
3123
- case void 0:
3124
- case "es":
3125
- case "esm":
3126
- case "module": return "es";
3127
- case "cjs":
3128
- case "commonjs": return "cjs";
3129
- case "iife": return "iife";
3130
- case "umd": return "umd";
3131
- default: require_dist.unimplemented(`output.format: ${format}`);
3132
- }
3133
- }
3134
- function bindingifySourcemap$1(sourcemap) {
3135
- switch (sourcemap) {
3136
- case true: return "file";
3137
- case "inline": return "inline";
3138
- case false:
3139
- case void 0: return void 0;
3140
- case "hidden": return "hidden";
3141
- default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3142
- }
3143
- }
3144
- function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3145
- return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3146
- }
3147
- function bindingifyAssetFilenames(assetFileNames) {
3148
- if (typeof assetFileNames === "function") return (asset) => {
3149
- return assetFileNames({
3150
- names: asset.names,
3151
- originalFileNames: asset.originalFileNames,
3152
- source: transformAssetSource(asset.source),
3153
- type: "asset"
3154
- });
3155
- };
3156
- return assetFileNames;
3157
- }
3158
-
3159
- //#endregion
3160
- //#region src/options/normalized-output-options.ts
3161
- var NormalizedOutputOptionsImpl = class {
3162
- constructor(inner, outputOptions, normalizedOutputPlugins) {
3163
- this.inner = inner;
3164
- this.outputOptions = outputOptions;
3165
- this.normalizedOutputPlugins = normalizedOutputPlugins;
3166
- }
3167
- get dir() {
3168
- return this.inner.dir ?? void 0;
3169
- }
3170
- get entryFileNames() {
3171
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3172
- }
3173
- get chunkFileNames() {
3174
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3175
- }
3176
- get assetFileNames() {
3177
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3178
- }
3179
- get format() {
3180
- return this.inner.format;
3181
- }
3182
- get exports() {
3183
- return this.inner.exports;
3184
- }
3185
- get sourcemap() {
3186
- return this.inner.sourcemap;
3187
- }
3188
- get cssEntryFileNames() {
3189
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3190
- }
3191
- get cssChunkFileNames() {
3192
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3193
- }
3194
- get shimMissingExports() {
3195
- return this.inner.shimMissingExports;
3196
- }
3197
- get name() {
3198
- return this.inner.name ?? void 0;
3199
- }
3200
- get file() {
3201
- return this.inner.file ?? void 0;
3202
- }
3203
- get inlineDynamicImports() {
3204
- return this.inner.inlineDynamicImports;
3205
- }
3206
- get externalLiveBindings() {
3207
- return this.inner.externalLiveBindings;
3208
- }
3209
- get banner() {
3210
- return normalizeAddon(this.outputOptions.banner);
3211
- }
3212
- get footer() {
3213
- return normalizeAddon(this.outputOptions.footer);
3214
- }
3215
- get intro() {
3216
- return normalizeAddon(this.outputOptions.intro);
3217
- }
3218
- get outro() {
3219
- return normalizeAddon(this.outputOptions.outro);
3220
- }
3221
- get esModule() {
3222
- return this.inner.esModule;
3223
- }
3224
- get extend() {
3225
- return this.inner.extend;
3226
- }
3227
- get globals() {
3228
- return this.inner.globals || this.outputOptions.globals;
3229
- }
3230
- get hashCharacters() {
3231
- return this.inner.hashCharacters;
3232
- }
3233
- get sourcemapDebugIds() {
3234
- return this.inner.sourcemapDebugIds;
3235
- }
3236
- get sourcemapIgnoreList() {
3237
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3238
- }
3239
- get sourcemapPathTransform() {
3240
- return this.outputOptions.sourcemapPathTransform;
3241
- }
3242
- get minify() {
3243
- return this.inner.minify;
3244
- }
3245
- get legalComments() {
3246
- return this.inner.legalComments;
3247
- }
3248
- get polyfillRequire() {
3249
- return this.inner.polyfillRequire;
3250
- }
3251
- get plugins() {
3252
- return this.normalizedOutputPlugins;
3253
- }
3254
- get preserveModules() {
3255
- return this.inner.preserveModules;
3256
- }
3257
- get preserveModulesRoot() {
3258
- return this.inner.preserveModulesRoot;
3259
- }
3260
- get virtualDirname() {
3261
- return this.inner.virtualDirname;
3262
- }
3263
- };
3264
- function normalizeAddon(value) {
3265
- if (typeof value === "function") return value;
3266
- return () => value || "";
3267
- }
3268
-
3269
3036
  //#endregion
3270
3037
  //#region src/utils/transform-to-rollup-output.ts
3271
3038
  function transformToRollupSourceMap(map) {
@@ -3411,7 +3178,7 @@ function collectChangedBundle(changed, bundle) {
3411
3178
  facadeModuleId: item.facadeModuleId || void 0,
3412
3179
  isDynamicEntry: item.isDynamicEntry,
3413
3180
  moduleIds: item.moduleIds,
3414
- map: bindingifySourcemap(item.map),
3181
+ map: bindingifySourcemap$1(item.map),
3415
3182
  sourcemapFilename: item.sourcemapFileName || void 0,
3416
3183
  preliminaryFilename: item.preliminaryFileName
3417
3184
  });
@@ -3431,7 +3198,7 @@ function bindingifyRenderStart(args$1) {
3431
3198
  const { handler, meta } = normalizeHook(hook);
3432
3199
  return {
3433
3200
  plugin: async (ctx, opts) => {
3434
- 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));
3201
+ 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));
3435
3202
  },
3436
3203
  meta: bindingifyPluginHookMeta(meta)
3437
3204
  };
@@ -3443,13 +3210,13 @@ function bindingifyRenderChunk(args$1) {
3443
3210
  return {
3444
3211
  plugin: async (ctx, code$1, chunk, opts, meta$1) => {
3445
3212
  if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
3446
- 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());
3213
+ 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());
3447
3214
  if (ret == null) return;
3448
3215
  if (typeof ret === "string") return { code: ret };
3449
3216
  if (!ret.map) return { code: ret.code };
3450
3217
  return {
3451
3218
  code: ret.code,
3452
- map: bindingifySourcemap(ret.map)
3219
+ map: bindingifySourcemap$1(ret.map)
3453
3220
  };
3454
3221
  },
3455
3222
  meta: bindingifyPluginHookMeta(meta),
@@ -3490,7 +3257,7 @@ function bindingifyGenerateBundle(args$1) {
3490
3257
  };
3491
3258
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3492
3259
  const output = transformToOutputBundle(context, bundle, changed);
3493
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output, isWrite);
3260
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
3494
3261
  return collectChangedBundle(changed, output);
3495
3262
  },
3496
3263
  meta: bindingifyPluginHookMeta(meta)
@@ -3508,7 +3275,7 @@ function bindingifyWriteBundle(args$1) {
3508
3275
  };
3509
3276
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3510
3277
  const output = transformToOutputBundle(context, bundle, changed);
3511
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output);
3278
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
3512
3279
  return collectChangedBundle(changed, output);
3513
3280
  },
3514
3281
  meta: bindingifyPluginHookMeta(meta)
@@ -3783,32 +3550,293 @@ function wrapHandlers(plugin) {
3783
3550
  }
3784
3551
 
3785
3552
  //#endregion
3786
- //#region src/plugin/plugin-context-data.ts
3787
- var PluginContextData = class {
3788
- moduleOptionMap = /* @__PURE__ */ new Map();
3789
- resolveOptionsMap = /* @__PURE__ */ new Map();
3790
- loadModulePromiseMap = /* @__PURE__ */ new Map();
3791
- loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3792
- renderedChunkMeta = null;
3793
- updateModuleOption(id$1, option) {
3794
- const existing = this.moduleOptionMap.get(id$1);
3795
- if (existing) {
3796
- if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3797
- if (option.meta != null) Object.assign(existing.meta, option.meta);
3798
- if (option.invalidate != null) existing.invalidate = option.invalidate;
3799
- } else {
3800
- this.moduleOptionMap.set(id$1, option);
3801
- return option;
3802
- }
3803
- return existing;
3553
+ //#region src/options/normalized-input-options.ts
3554
+ var NormalizedInputOptionsImpl = class {
3555
+ inner;
3556
+ constructor(inner, onLog) {
3557
+ this.onLog = onLog;
3558
+ this.inner = inner;
3804
3559
  }
3805
- getModuleOption(id$1) {
3806
- const option = this.moduleOptionMap.get(id$1);
3807
- if (!option) {
3808
- const raw = {
3809
- moduleSideEffects: null,
3810
- meta: {}
3811
- };
3560
+ get shimMissingExports() {
3561
+ return this.inner.shimMissingExports;
3562
+ }
3563
+ get input() {
3564
+ return this.inner.input;
3565
+ }
3566
+ get cwd() {
3567
+ return this.inner.cwd ?? void 0;
3568
+ }
3569
+ get platform() {
3570
+ return this.inner.platform;
3571
+ }
3572
+ };
3573
+
3574
+ //#endregion
3575
+ //#region src/types/chunking-context.ts
3576
+ var ChunkingContextImpl = class {
3577
+ constructor(context) {
3578
+ this.context = context;
3579
+ }
3580
+ getModuleInfo(moduleId) {
3581
+ const bindingInfo = this.context.getModuleInfo(moduleId);
3582
+ if (bindingInfo) {
3583
+ const info = transformModuleInfo(bindingInfo, {
3584
+ moduleSideEffects: null,
3585
+ meta: {}
3586
+ });
3587
+ return info;
3588
+ }
3589
+ return null;
3590
+ }
3591
+ };
3592
+
3593
+ //#endregion
3594
+ //#region src/utils/bindingify-output-options.ts
3595
+ function bindingifyOutputOptions(outputOptions) {
3596
+ 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;
3597
+ const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3598
+ return {
3599
+ dir,
3600
+ file: file == null ? void 0 : file,
3601
+ format: bindingifyFormat(format),
3602
+ exports: exports$1,
3603
+ hashCharacters,
3604
+ sourcemap: bindingifySourcemap(sourcemap),
3605
+ sourcemapDebugIds,
3606
+ sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3607
+ sourcemapPathTransform,
3608
+ banner: bindingifyAddon(banner),
3609
+ footer: bindingifyAddon(footer),
3610
+ intro: bindingifyAddon(intro),
3611
+ outro: bindingifyAddon(outro),
3612
+ extend: outputOptions.extend,
3613
+ globals,
3614
+ esModule,
3615
+ name,
3616
+ assetFileNames: bindingifyAssetFilenames(assetFileNames),
3617
+ entryFileNames,
3618
+ chunkFileNames,
3619
+ cssEntryFileNames,
3620
+ cssChunkFileNames,
3621
+ plugins: [],
3622
+ minify: outputOptions.minify,
3623
+ externalLiveBindings: outputOptions.externalLiveBindings,
3624
+ inlineDynamicImports: outputOptions.inlineDynamicImports,
3625
+ advancedChunks,
3626
+ polyfillRequire: outputOptions.polyfillRequire,
3627
+ sanitizeFileName,
3628
+ preserveModules,
3629
+ virtualDirname,
3630
+ legalComments,
3631
+ preserveModulesRoot
3632
+ };
3633
+ }
3634
+ function bindingifyAddon(configAddon) {
3635
+ return async (chunk) => {
3636
+ if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3637
+ return configAddon || "";
3638
+ };
3639
+ }
3640
+ function bindingifyFormat(format) {
3641
+ switch (format) {
3642
+ case void 0:
3643
+ case "es":
3644
+ case "esm":
3645
+ case "module": return "es";
3646
+ case "cjs":
3647
+ case "commonjs": return "cjs";
3648
+ case "iife": return "iife";
3649
+ case "umd": return "umd";
3650
+ default: require_dist.unimplemented(`output.format: ${format}`);
3651
+ }
3652
+ }
3653
+ function bindingifySourcemap(sourcemap) {
3654
+ switch (sourcemap) {
3655
+ case true: return "file";
3656
+ case "inline": return "inline";
3657
+ case false:
3658
+ case void 0: return void 0;
3659
+ case "hidden": return "hidden";
3660
+ default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3661
+ }
3662
+ }
3663
+ function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3664
+ return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3665
+ }
3666
+ function bindingifyAssetFilenames(assetFileNames) {
3667
+ if (typeof assetFileNames === "function") return (asset) => {
3668
+ return assetFileNames({
3669
+ names: asset.names,
3670
+ originalFileNames: asset.originalFileNames,
3671
+ source: transformAssetSource(asset.source),
3672
+ type: "asset"
3673
+ });
3674
+ };
3675
+ return assetFileNames;
3676
+ }
3677
+ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
3678
+ if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3679
+ else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
3680
+ return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
3681
+ } }] };
3682
+ if (advancedChunks == null) return void 0;
3683
+ const { groups,...restAdvancedChunks } = advancedChunks;
3684
+ return {
3685
+ ...restAdvancedChunks,
3686
+ groups: groups?.map((group) => {
3687
+ const { name,...restGroup } = group;
3688
+ return {
3689
+ ...restGroup,
3690
+ name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContextImpl(ctx)) : name
3691
+ };
3692
+ })
3693
+ };
3694
+ }
3695
+
3696
+ //#endregion
3697
+ //#region src/options/normalized-output-options.ts
3698
+ var NormalizedOutputOptionsImpl = class {
3699
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
3700
+ this.inner = inner;
3701
+ this.outputOptions = outputOptions;
3702
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3703
+ }
3704
+ get dir() {
3705
+ return this.inner.dir ?? void 0;
3706
+ }
3707
+ get entryFileNames() {
3708
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3709
+ }
3710
+ get chunkFileNames() {
3711
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3712
+ }
3713
+ get assetFileNames() {
3714
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3715
+ }
3716
+ get format() {
3717
+ return this.inner.format;
3718
+ }
3719
+ get exports() {
3720
+ return this.inner.exports;
3721
+ }
3722
+ get sourcemap() {
3723
+ return this.inner.sourcemap;
3724
+ }
3725
+ get cssEntryFileNames() {
3726
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3727
+ }
3728
+ get cssChunkFileNames() {
3729
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3730
+ }
3731
+ get shimMissingExports() {
3732
+ return this.inner.shimMissingExports;
3733
+ }
3734
+ get name() {
3735
+ return this.inner.name ?? void 0;
3736
+ }
3737
+ get file() {
3738
+ return this.inner.file ?? void 0;
3739
+ }
3740
+ get inlineDynamicImports() {
3741
+ return this.inner.inlineDynamicImports;
3742
+ }
3743
+ get externalLiveBindings() {
3744
+ return this.inner.externalLiveBindings;
3745
+ }
3746
+ get banner() {
3747
+ return normalizeAddon(this.outputOptions.banner);
3748
+ }
3749
+ get footer() {
3750
+ return normalizeAddon(this.outputOptions.footer);
3751
+ }
3752
+ get intro() {
3753
+ return normalizeAddon(this.outputOptions.intro);
3754
+ }
3755
+ get outro() {
3756
+ return normalizeAddon(this.outputOptions.outro);
3757
+ }
3758
+ get esModule() {
3759
+ return this.inner.esModule;
3760
+ }
3761
+ get extend() {
3762
+ return this.inner.extend;
3763
+ }
3764
+ get globals() {
3765
+ return this.inner.globals || this.outputOptions.globals;
3766
+ }
3767
+ get hashCharacters() {
3768
+ return this.inner.hashCharacters;
3769
+ }
3770
+ get sourcemapDebugIds() {
3771
+ return this.inner.sourcemapDebugIds;
3772
+ }
3773
+ get sourcemapIgnoreList() {
3774
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3775
+ }
3776
+ get sourcemapPathTransform() {
3777
+ return this.outputOptions.sourcemapPathTransform;
3778
+ }
3779
+ get minify() {
3780
+ return this.inner.minify;
3781
+ }
3782
+ get legalComments() {
3783
+ return this.inner.legalComments;
3784
+ }
3785
+ get polyfillRequire() {
3786
+ return this.inner.polyfillRequire;
3787
+ }
3788
+ get plugins() {
3789
+ return this.normalizedOutputPlugins;
3790
+ }
3791
+ get preserveModules() {
3792
+ return this.inner.preserveModules;
3793
+ }
3794
+ get preserveModulesRoot() {
3795
+ return this.inner.preserveModulesRoot;
3796
+ }
3797
+ get virtualDirname() {
3798
+ return this.inner.virtualDirname;
3799
+ }
3800
+ };
3801
+ function normalizeAddon(value) {
3802
+ if (typeof value === "function") return value;
3803
+ return () => value || "";
3804
+ }
3805
+
3806
+ //#endregion
3807
+ //#region src/plugin/plugin-context-data.ts
3808
+ var PluginContextData = class {
3809
+ moduleOptionMap = /* @__PURE__ */ new Map();
3810
+ resolveOptionsMap = /* @__PURE__ */ new Map();
3811
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
3812
+ loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3813
+ renderedChunkMeta = null;
3814
+ normalizedInputOptions = null;
3815
+ normalizedOutputOptions = null;
3816
+ constructor(onLog, outputOptions, normalizedOutputPlugins) {
3817
+ this.onLog = onLog;
3818
+ this.outputOptions = outputOptions;
3819
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3820
+ }
3821
+ updateModuleOption(id$1, option) {
3822
+ const existing = this.moduleOptionMap.get(id$1);
3823
+ if (existing) {
3824
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3825
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
3826
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
3827
+ } else {
3828
+ this.moduleOptionMap.set(id$1, option);
3829
+ return option;
3830
+ }
3831
+ return existing;
3832
+ }
3833
+ getModuleOption(id$1) {
3834
+ const option = this.moduleOptionMap.get(id$1);
3835
+ if (!option) {
3836
+ const raw = {
3837
+ moduleSideEffects: null,
3838
+ meta: {}
3839
+ };
3812
3840
  this.moduleOptionMap.set(id$1, raw);
3813
3841
  return raw;
3814
3842
  }
@@ -3860,6 +3888,14 @@ var PluginContextData = class {
3860
3888
  getRenderChunkMeta() {
3861
3889
  return this.renderedChunkMeta;
3862
3890
  }
3891
+ getInputOptions(opts) {
3892
+ this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
3893
+ return this.normalizedInputOptions;
3894
+ }
3895
+ getOutputOptions(opts) {
3896
+ this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
3897
+ return this.normalizedOutputOptions;
3898
+ }
3863
3899
  markModuleLoaded(id$1, _success) {
3864
3900
  const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
3865
3901
  if (resolve) resolve();
@@ -3885,7 +3921,7 @@ function isReadonlyArray(input) {
3885
3921
  //#endregion
3886
3922
  //#region src/utils/bindingify-input-options.ts
3887
3923
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3888
- const pluginContextData = new PluginContextData();
3924
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3889
3925
  const plugins = rawPlugins.map((plugin) => {
3890
3926
  if ("_parallel" in plugin) return void 0;
3891
3927
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
@@ -4060,7 +4096,8 @@ function bindingifyTreeshakeOptions(config) {
4060
4096
  moduleSideEffects: true,
4061
4097
  annotations: config.annotations,
4062
4098
  manualPureFunctions: config.manualPureFunctions,
4063
- unknownGlobalSideEffects: config.unknownGlobalSideEffects
4099
+ unknownGlobalSideEffects: config.unknownGlobalSideEffects,
4100
+ commonjs: config.commonjs
4064
4101
  };
4065
4102
  if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
4066
4103
  else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
@@ -4092,323 +4129,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4092
4129
  };
4093
4130
  }
4094
4131
 
4095
- //#endregion
4096
- //#region src/utils/plugin/index.ts
4097
- const isPluginHookName = function() {
4098
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4099
- return function isPluginHookName$1(hookName) {
4100
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
4101
- };
4102
- }();
4103
-
4104
- //#endregion
4105
- //#region src/utils/compose-js-plugins.ts
4106
- const unsupportedHookName = [
4107
- "augmentChunkHash",
4108
- "generateBundle",
4109
- "moduleParsed",
4110
- "onLog",
4111
- "options",
4112
- "outputOptions",
4113
- "renderError",
4114
- "renderStart",
4115
- "resolveDynamicImport",
4116
- "writeBundle"
4117
- ];
4118
- const unsupportedHooks = new Set(unsupportedHookName);
4119
- function isUnsupportedHooks(hookName) {
4120
- return unsupportedHooks.has(hookName);
4121
- }
4122
- function createComposedPlugin(plugins) {
4123
- const names = [];
4124
- const batchedHooks = {};
4125
- plugins.forEach((plugin, index) => {
4126
- const pluginName = plugin.name || `Anonymous(index: ${index})`;
4127
- names.push(pluginName);
4128
- t(plugin).forEach((pluginProp) => {
4129
- if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
4130
- if (!isPluginHookName(pluginProp)) return;
4131
- switch (pluginProp) {
4132
- case "buildStart": {
4133
- const handlers = batchedHooks.buildStart ?? [];
4134
- batchedHooks.buildStart = handlers;
4135
- if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
4136
- break;
4137
- }
4138
- case "load": {
4139
- const handlers = batchedHooks.load ?? [];
4140
- batchedHooks.load = handlers;
4141
- if (plugin.load) handlers.push([plugin.load, plugin]);
4142
- break;
4143
- }
4144
- case "transform": {
4145
- const handlers = batchedHooks.transform ?? [];
4146
- batchedHooks.transform = handlers;
4147
- if (plugin.transform) handlers.push([plugin.transform, plugin]);
4148
- break;
4149
- }
4150
- case "resolveId": {
4151
- const handlers = batchedHooks.resolveId ?? [];
4152
- batchedHooks.resolveId = handlers;
4153
- if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
4154
- break;
4155
- }
4156
- case "buildEnd": {
4157
- const handlers = batchedHooks.buildEnd ?? [];
4158
- batchedHooks.buildEnd = handlers;
4159
- if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
4160
- break;
4161
- }
4162
- case "renderChunk": {
4163
- const handlers = batchedHooks.renderChunk ?? [];
4164
- batchedHooks.renderChunk = handlers;
4165
- if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
4166
- break;
4167
- }
4168
- case "banner":
4169
- case "footer":
4170
- case "intro":
4171
- case "outro": {
4172
- const hook = plugin[pluginProp];
4173
- if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
4174
- break;
4175
- }
4176
- case "closeBundle": {
4177
- const handlers = batchedHooks.closeBundle ?? [];
4178
- batchedHooks.closeBundle = handlers;
4179
- if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
4180
- break;
4181
- }
4182
- case "watchChange": {
4183
- const handlers = batchedHooks.watchChange ?? [];
4184
- batchedHooks.watchChange = handlers;
4185
- if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
4186
- break;
4187
- }
4188
- case "closeWatcher": {
4189
- const handlers = batchedHooks.closeWatcher ?? [];
4190
- batchedHooks.closeWatcher = handlers;
4191
- if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
4192
- break;
4193
- }
4194
- default: {}
4195
- }
4196
- });
4197
- });
4198
- const composed = { name: `Composed(${names.join(", ")})` };
4199
- const createFixedPluginResolveFnMap = /* @__PURE__ */ new Map();
4200
- function applyFixedPluginResolveFn(ctx, plugin) {
4201
- const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
4202
- if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
4203
- return ctx;
4204
- }
4205
- if (batchedHooks.resolveId) {
4206
- const batchedHandlers = batchedHooks.resolveId;
4207
- const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
4208
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4209
- const [_handler, plugin] = batchedHandlers[handlerIdx];
4210
- const handlerSymbol = handlerSymbols[handlerIdx];
4211
- const createFixedPluginResolveFn = (ctx, resolve) => {
4212
- return (source, importer, rawContextResolveOptions) => {
4213
- const contextResolveOptions = rawContextResolveOptions ?? {};
4214
- if (contextResolveOptions.skipSelf) {
4215
- contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
4216
- contextResolveOptions.skipSelf = false;
4217
- }
4218
- return resolve(source, importer, contextResolveOptions);
4219
- };
4220
- };
4221
- createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
4222
- }
4223
- composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
4224
- const hookResolveIdOptions = rawHookResolveIdOptions;
4225
- const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
4226
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4227
- const [handler, plugin] = batchedHandlers[handlerIdx];
4228
- const handlerSymbol = handlerSymbols[handlerIdx];
4229
- if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
4230
- const { handler: handlerFn } = normalizeHook(handler);
4231
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
4232
- if (!require_dist.isNullish(result)) return result;
4233
- }
4234
- };
4235
- }
4236
- t(batchedHooks).forEach((hookName) => {
4237
- switch (hookName) {
4238
- case "resolveId": break;
4239
- case "buildStart": {
4240
- if (batchedHooks.buildStart) {
4241
- const batchedHandlers = batchedHooks.buildStart;
4242
- composed.buildStart = async function(options) {
4243
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4244
- const { handler: handlerFn } = normalizeHook(handler);
4245
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
4246
- }));
4247
- };
4248
- }
4249
- break;
4250
- }
4251
- case "load": {
4252
- if (batchedHooks.load) {
4253
- const batchedHandlers = batchedHooks.load;
4254
- composed.load = async function(id$1) {
4255
- for (const [handler, plugin] of batchedHandlers) {
4256
- const { handler: handlerFn } = normalizeHook(handler);
4257
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
4258
- if (!require_dist.isNullish(result)) return result;
4259
- }
4260
- };
4261
- }
4262
- break;
4263
- }
4264
- case "transform": {
4265
- if (batchedHooks.transform) {
4266
- const batchedHandlers = batchedHooks.transform;
4267
- composed.transform = async function(initialCode, id$1, moduleType$1) {
4268
- let code$1 = initialCode;
4269
- let moduleSideEffects = void 0;
4270
- function updateOutput(newCode, newModuleSideEffects) {
4271
- code$1 = newCode;
4272
- moduleSideEffects = newModuleSideEffects ?? void 0;
4273
- }
4274
- for (const [handler, plugin] of batchedHandlers) {
4275
- const { handler: handlerFn } = normalizeHook(handler);
4276
- this.getCombinedSourcemap = () => {
4277
- throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
4278
- };
4279
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
4280
- if (!require_dist.isNullish(result)) {
4281
- if (typeof result === "string") updateOutput(result);
4282
- else if (result.code) updateOutput(result.code, result.moduleSideEffects);
4283
- }
4284
- }
4285
- return {
4286
- code: code$1,
4287
- moduleSideEffects
4288
- };
4289
- };
4290
- }
4291
- break;
4292
- }
4293
- case "buildEnd": {
4294
- if (batchedHooks.buildEnd) {
4295
- const batchedHandlers = batchedHooks.buildEnd;
4296
- composed.buildEnd = async function(err) {
4297
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4298
- const { handler: handlerFn } = normalizeHook(handler);
4299
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
4300
- }));
4301
- };
4302
- }
4303
- break;
4304
- }
4305
- case "renderChunk": {
4306
- if (batchedHooks.renderChunk) {
4307
- const batchedHandlers = batchedHooks.renderChunk;
4308
- composed.renderChunk = async function(code$1, chunk, options, meta) {
4309
- for (const [handler, plugin] of batchedHandlers) {
4310
- const { handler: handlerFn } = normalizeHook(handler);
4311
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
4312
- if (!require_dist.isNullish(result)) return result;
4313
- }
4314
- };
4315
- }
4316
- break;
4317
- }
4318
- case "banner":
4319
- case "footer":
4320
- case "intro":
4321
- case "outro": {
4322
- const hooks = batchedHooks[hookName];
4323
- if (hooks?.length) composed[hookName] = async function(chunk) {
4324
- const ret = [];
4325
- for (const [hook, plugin] of hooks) {
4326
- const { handler } = normalizeHook(hook);
4327
- ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
4328
- }
4329
- return ret.join("\n");
4330
- };
4331
- break;
4332
- }
4333
- case "closeBundle": {
4334
- if (batchedHooks.closeBundle) {
4335
- const batchedHandlers = batchedHooks.closeBundle;
4336
- composed.closeBundle = async function() {
4337
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4338
- const { handler: handlerFn } = normalizeHook(handler);
4339
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4340
- }));
4341
- };
4342
- }
4343
- break;
4344
- }
4345
- case "watchChange": {
4346
- if (batchedHooks.watchChange) {
4347
- const batchedHandlers = batchedHooks.watchChange;
4348
- composed.watchChange = async function(id$1, event) {
4349
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4350
- const { handler: handlerFn } = normalizeHook(handler);
4351
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
4352
- }));
4353
- };
4354
- }
4355
- break;
4356
- }
4357
- case "closeWatcher": {
4358
- if (batchedHooks.closeWatcher) {
4359
- const batchedHandlers = batchedHooks.closeWatcher;
4360
- composed.closeWatcher = async function() {
4361
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4362
- const { handler: handlerFn } = normalizeHook(handler);
4363
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4364
- }));
4365
- };
4366
- }
4367
- break;
4368
- }
4369
- default: {}
4370
- }
4371
- });
4372
- return composed;
4373
- }
4374
- function isComposablePlugin(plugin) {
4375
- if (plugin instanceof BuiltinPlugin) return false;
4376
- if ("_parallel" in plugin) return false;
4377
- const hasNotComposablePattern = t(plugin).some((hookName) => {
4378
- if (!isPluginHookName(hookName)) return false;
4379
- const OK_TO_COMPOSE = false;
4380
- if (isUnsupportedHooks(hookName)) return true;
4381
- if (plugin[hookName]) {
4382
- const { meta } = normalizeHook(plugin[hookName]);
4383
- if (meta.order === "pre" || meta.order === "post") return true;
4384
- }
4385
- return OK_TO_COMPOSE;
4386
- });
4387
- if (hasNotComposablePattern) return false;
4388
- return true;
4389
- }
4390
- function composeJsPlugins(plugins) {
4391
- const newPlugins = [];
4392
- const toBeComposed = [];
4393
- plugins.forEach((plugin) => {
4394
- if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
4395
- else {
4396
- if (toBeComposed.length > 0) {
4397
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4398
- else newPlugins.push(toBeComposed[0]);
4399
- toBeComposed.length = 0;
4400
- }
4401
- newPlugins.push(plugin);
4402
- }
4403
- });
4404
- if (toBeComposed.length > 0) {
4405
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4406
- else newPlugins.push(toBeComposed[0]);
4407
- toBeComposed.length = 0;
4408
- }
4409
- return newPlugins;
4410
- }
4411
-
4412
4132
  //#endregion
4413
4133
  //#region src/utils/initialize-parallel-plugins.ts
4414
4134
  async function initializeParallelPlugins(plugins) {
@@ -4485,7 +4205,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4485
4205
  ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4486
4206
  ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4487
4207
  ];
4488
- if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
4489
4208
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4490
4209
  try {
4491
4210
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -4809,12 +4528,6 @@ Object.defineProperty(exports, 'buildImportAnalysisPlugin', {
4809
4528
  return buildImportAnalysisPlugin;
4810
4529
  }
4811
4530
  });
4812
- Object.defineProperty(exports, 'composeJsPlugins', {
4813
- enumerable: true,
4814
- get: function () {
4815
- return composeJsPlugins;
4816
- }
4817
- });
4818
4531
  Object.defineProperty(exports, 'createBundlerImpl', {
4819
4532
  enumerable: true,
4820
4533
  get: function () {