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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/cli.cjs +3 -3
  2. package/dist/cli.mjs +3 -3
  3. package/dist/config.cjs +3 -3
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +3 -3
  7. package/dist/experimental-index.browser.mjs +2 -2
  8. package/dist/experimental-index.cjs +2 -3
  9. package/dist/experimental-index.d.cts +3 -6
  10. package/dist/experimental-index.d.mts +3 -6
  11. package/dist/experimental-index.mjs +3 -3
  12. package/dist/filter-index.cjs +1 -1
  13. package/dist/filter-index.d.cts +2 -2
  14. package/dist/filter-index.d.mts +2 -2
  15. package/dist/filter-index.mjs +1 -1
  16. package/dist/index.browser.mjs +1 -1
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.d.cts +3 -3
  19. package/dist/index.d.mts +3 -3
  20. package/dist/index.mjs +2 -2
  21. package/dist/parallel-plugin-worker.cjs +3 -3
  22. package/dist/parallel-plugin-worker.mjs +3 -3
  23. package/dist/parallel-plugin.d.cts +2 -2
  24. package/dist/parallel-plugin.d.mts +2 -2
  25. package/dist/parse-ast-index.d.cts +1 -1
  26. package/dist/parse-ast-index.d.mts +1 -1
  27. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  28. package/dist/shared/{binding-B8kHDLfO.d.mts → binding-CMKStSph.d.cts} +4 -14
  29. package/dist/shared/{binding-CbR_BHh9.d.cts → binding-DB58iXP8.d.mts} +4 -14
  30. package/dist/shared/{define-config-DZVEpUTF.d.cts → define-config-BRkYSF9E.d.cts} +11 -21
  31. package/dist/shared/{define-config-DsN80oVh.d.mts → define-config-CqVfqfZQ.d.mts} +11 -21
  32. package/dist/shared/{dist-BMVjvV-v.cjs → dist-BVAp8sOm.cjs} +0 -9
  33. package/dist/shared/{dist-BoWaIc-K.mjs → dist-DvBwroyk.mjs} +1 -4
  34. package/dist/shared/{load-config-_2H4hlKT.mjs → load-config-BWbXOTbl.mjs} +1 -1
  35. package/dist/shared/{load-config-BgXwAVNp.cjs → load-config-Bh2dNRk9.cjs} +1 -1
  36. package/dist/shared/{src-C_vfq91X.mjs → src-BA5CL--T.mjs} +454 -775
  37. package/dist/shared/{src-DT8g8X-x.cjs → src-Co_Bf7DL.cjs} +354 -681
  38. package/dist/{src-DJeuVN_z.js → src-C1KTaRyZ.js} +483 -807
  39. package/package.json +1 -1
@@ -1,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.22";
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
  } });
@@ -2365,41 +2365,9 @@ function getJsonSchema() {
2365
2365
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2366
2366
  }
2367
2367
 
2368
- //#endregion
2369
- //#region src/constants/plugin-context.ts
2370
- /**
2371
- * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2372
- * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2373
- * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2374
- * internally.
2375
- */
2376
- const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2377
-
2378
- //#endregion
2379
- //#region src/options/normalized-input-options.ts
2380
- var NormalizedInputOptionsImpl = class {
2381
- inner;
2382
- constructor(inner, onLog) {
2383
- this.onLog = onLog;
2384
- this.inner = inner;
2385
- }
2386
- get shimMissingExports() {
2387
- return this.inner.shimMissingExports;
2388
- }
2389
- get input() {
2390
- return this.inner.input;
2391
- }
2392
- get cwd() {
2393
- return this.inner.cwd ?? void 0;
2394
- }
2395
- get platform() {
2396
- return this.inner.platform;
2397
- }
2398
- };
2399
-
2400
2368
  //#endregion
2401
2369
  //#region src/types/sourcemap.ts
2402
- function bindingifySourcemap(map) {
2370
+ function bindingifySourcemap$1(map) {
2403
2371
  if (map == null) return;
2404
2372
  return { inner: typeof map === "string" ? map : {
2405
2373
  file: map.file ?? void 0,
@@ -2515,8 +2483,8 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2515
2483
  //#endregion
2516
2484
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
2517
2485
  function u$1(o$1, n$1, a$2) {
2518
- let t$2 = (r$1) => o$1(r$1, ...n$1);
2519
- return a$2 === void 0 ? t$2 : Object.assign(t$2, {
2486
+ let t$1 = (r$1) => o$1(r$1, ...n$1);
2487
+ return a$2 === void 0 ? t$1 : Object.assign(t$1, {
2520
2488
  lazy: a$2,
2521
2489
  lazyArgs: n$1
2522
2490
  });
@@ -2536,18 +2504,12 @@ function u(r$1, n$1, o$1) {
2536
2504
  function d(...r$1) {
2537
2505
  return u(i, r$1);
2538
2506
  }
2539
- var i = (r$1, t$2) => {
2507
+ var i = (r$1, t$1) => {
2540
2508
  let a$2 = [[], []];
2541
- for (let [o$1, e$1] of r$1.entries()) t$2(e$1, o$1, r$1) ? a$2[0].push(e$1) : a$2[1].push(e$1);
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);
2542
2510
  return a$2;
2543
2511
  };
2544
2512
 
2545
- //#endregion
2546
- //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
2547
- function t(...n$1) {
2548
- return u(Object.keys, n$1);
2549
- }
2550
-
2551
2513
  //#endregion
2552
2514
  //#region src/plugin/bindingify-hook-filter.ts
2553
2515
  function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
@@ -2852,7 +2814,7 @@ function bindingifyBuildStart(args$1) {
2852
2814
  const { handler, meta } = normalizeHook(hook);
2853
2815
  return {
2854
2816
  plugin: async (ctx, opts) => {
2855
- await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedInputOptionsImpl(opts, args$1.onLog));
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));
2856
2818
  },
2857
2819
  meta: bindingifyPluginHookMeta(meta)
2858
2820
  };
@@ -2875,12 +2837,10 @@ function bindingifyResolveId(args$1) {
2875
2837
  return {
2876
2838
  plugin: async (ctx, specifier, importer, extraOptions) => {
2877
2839
  const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
2878
- 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, {
2879
2841
  ...extraOptions,
2880
- custom: contextResolveOptions?.custom,
2881
- [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
2882
- };
2883
- const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), specifier, importer ?? void 0, newExtraOptions);
2842
+ custom: contextResolveOptions?.custom
2843
+ });
2884
2844
  if (ret == null) return;
2885
2845
  if (ret === false) return {
2886
2846
  id: specifier,
@@ -2951,7 +2911,7 @@ function bindingifyTransform(args$1) {
2951
2911
  });
2952
2912
  return {
2953
2913
  code: ret.code,
2954
- map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2914
+ map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
2955
2915
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
2956
2916
  moduleType: ret.moduleType
2957
2917
  };
@@ -2977,7 +2937,7 @@ function bindingifyLoad(args$1) {
2977
2937
  let map = preProcessSourceMap(ret, id$1);
2978
2938
  return {
2979
2939
  code: ret.code,
2980
- map: bindingifySourcemap(map),
2940
+ map: bindingifySourcemap$1(map),
2981
2941
  moduleType: ret.moduleType,
2982
2942
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
2983
2943
  };
@@ -3008,25 +2968,6 @@ function bindingifyModuleParsed(args$1) {
3008
2968
  };
3009
2969
  }
3010
2970
 
3011
- //#endregion
3012
- //#region src/types/chunking-context.ts
3013
- var ChunkingContext = class {
3014
- constructor(context) {
3015
- this.context = context;
3016
- }
3017
- getModuleInfo(moduleId) {
3018
- const bindingInfo = this.context.getModuleInfo(moduleId);
3019
- if (bindingInfo) {
3020
- const info = transformModuleInfo(bindingInfo, {
3021
- moduleSideEffects: null,
3022
- meta: {}
3023
- });
3024
- return info;
3025
- }
3026
- return null;
3027
- }
3028
- };
3029
-
3030
2971
  //#endregion
3031
2972
  //#region src/utils/transform-rendered-module.ts
3032
2973
  function transformToRenderedModule(bindingRenderedModule) {
@@ -3092,219 +3033,6 @@ function transformChunkModules(modules) {
3092
3033
  return result;
3093
3034
  }
3094
3035
 
3095
- //#endregion
3096
- //#region src/utils/bindingify-output-options.ts
3097
- function bindingifyOutputOptions(outputOptions) {
3098
- const { dir, format, exports: exports$1, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks } = outputOptions;
3099
- const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3100
- return {
3101
- dir,
3102
- file: file == null ? void 0 : file,
3103
- format: bindingifyFormat(format),
3104
- exports: exports$1,
3105
- hashCharacters,
3106
- sourcemap: bindingifySourcemap$1(sourcemap),
3107
- sourcemapDebugIds,
3108
- sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3109
- sourcemapPathTransform,
3110
- banner: bindingifyAddon(banner),
3111
- footer: bindingifyAddon(footer),
3112
- intro: bindingifyAddon(intro),
3113
- outro: bindingifyAddon(outro),
3114
- extend: outputOptions.extend,
3115
- globals,
3116
- esModule,
3117
- name,
3118
- assetFileNames: bindingifyAssetFilenames(assetFileNames),
3119
- entryFileNames,
3120
- chunkFileNames,
3121
- cssEntryFileNames,
3122
- cssChunkFileNames,
3123
- plugins: [],
3124
- minify: outputOptions.minify,
3125
- externalLiveBindings: outputOptions.externalLiveBindings,
3126
- inlineDynamicImports: outputOptions.inlineDynamicImports,
3127
- advancedChunks,
3128
- polyfillRequire: outputOptions.polyfillRequire,
3129
- sanitizeFileName,
3130
- preserveModules,
3131
- virtualDirname,
3132
- legalComments,
3133
- preserveModulesRoot
3134
- };
3135
- }
3136
- function bindingifyAddon(configAddon) {
3137
- return async (chunk) => {
3138
- if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3139
- return configAddon || "";
3140
- };
3141
- }
3142
- function bindingifyFormat(format) {
3143
- switch (format) {
3144
- case void 0:
3145
- case "es":
3146
- case "esm":
3147
- case "module": return "es";
3148
- case "cjs":
3149
- case "commonjs": return "cjs";
3150
- case "iife": return "iife";
3151
- case "umd": return "umd";
3152
- default: require_dist.unimplemented(`output.format: ${format}`);
3153
- }
3154
- }
3155
- function bindingifySourcemap$1(sourcemap) {
3156
- switch (sourcemap) {
3157
- case true: return "file";
3158
- case "inline": return "inline";
3159
- case false:
3160
- case void 0: return void 0;
3161
- case "hidden": return "hidden";
3162
- default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3163
- }
3164
- }
3165
- function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3166
- return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3167
- }
3168
- function bindingifyAssetFilenames(assetFileNames) {
3169
- if (typeof assetFileNames === "function") return (asset) => {
3170
- return assetFileNames({
3171
- names: asset.names,
3172
- originalFileNames: asset.originalFileNames,
3173
- source: transformAssetSource(asset.source),
3174
- type: "asset"
3175
- });
3176
- };
3177
- return assetFileNames;
3178
- }
3179
- function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
3180
- if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3181
- else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
3182
- return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
3183
- } }] };
3184
- if (advancedChunks == null) return void 0;
3185
- const { groups,...restAdvancedChunks } = advancedChunks;
3186
- return {
3187
- ...restAdvancedChunks,
3188
- groups: groups?.map((group) => {
3189
- const { name,...restGroup } = group;
3190
- return {
3191
- ...restGroup,
3192
- name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContext(ctx)) : name
3193
- };
3194
- })
3195
- };
3196
- }
3197
-
3198
- //#endregion
3199
- //#region src/options/normalized-output-options.ts
3200
- var NormalizedOutputOptionsImpl = class {
3201
- constructor(inner, outputOptions, normalizedOutputPlugins) {
3202
- this.inner = inner;
3203
- this.outputOptions = outputOptions;
3204
- this.normalizedOutputPlugins = normalizedOutputPlugins;
3205
- }
3206
- get dir() {
3207
- return this.inner.dir ?? void 0;
3208
- }
3209
- get entryFileNames() {
3210
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3211
- }
3212
- get chunkFileNames() {
3213
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3214
- }
3215
- get assetFileNames() {
3216
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3217
- }
3218
- get format() {
3219
- return this.inner.format;
3220
- }
3221
- get exports() {
3222
- return this.inner.exports;
3223
- }
3224
- get sourcemap() {
3225
- return this.inner.sourcemap;
3226
- }
3227
- get cssEntryFileNames() {
3228
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3229
- }
3230
- get cssChunkFileNames() {
3231
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3232
- }
3233
- get shimMissingExports() {
3234
- return this.inner.shimMissingExports;
3235
- }
3236
- get name() {
3237
- return this.inner.name ?? void 0;
3238
- }
3239
- get file() {
3240
- return this.inner.file ?? void 0;
3241
- }
3242
- get inlineDynamicImports() {
3243
- return this.inner.inlineDynamicImports;
3244
- }
3245
- get externalLiveBindings() {
3246
- return this.inner.externalLiveBindings;
3247
- }
3248
- get banner() {
3249
- return normalizeAddon(this.outputOptions.banner);
3250
- }
3251
- get footer() {
3252
- return normalizeAddon(this.outputOptions.footer);
3253
- }
3254
- get intro() {
3255
- return normalizeAddon(this.outputOptions.intro);
3256
- }
3257
- get outro() {
3258
- return normalizeAddon(this.outputOptions.outro);
3259
- }
3260
- get esModule() {
3261
- return this.inner.esModule;
3262
- }
3263
- get extend() {
3264
- return this.inner.extend;
3265
- }
3266
- get globals() {
3267
- return this.inner.globals || this.outputOptions.globals;
3268
- }
3269
- get hashCharacters() {
3270
- return this.inner.hashCharacters;
3271
- }
3272
- get sourcemapDebugIds() {
3273
- return this.inner.sourcemapDebugIds;
3274
- }
3275
- get sourcemapIgnoreList() {
3276
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3277
- }
3278
- get sourcemapPathTransform() {
3279
- return this.outputOptions.sourcemapPathTransform;
3280
- }
3281
- get minify() {
3282
- return this.inner.minify;
3283
- }
3284
- get legalComments() {
3285
- return this.inner.legalComments;
3286
- }
3287
- get polyfillRequire() {
3288
- return this.inner.polyfillRequire;
3289
- }
3290
- get plugins() {
3291
- return this.normalizedOutputPlugins;
3292
- }
3293
- get preserveModules() {
3294
- return this.inner.preserveModules;
3295
- }
3296
- get preserveModulesRoot() {
3297
- return this.inner.preserveModulesRoot;
3298
- }
3299
- get virtualDirname() {
3300
- return this.inner.virtualDirname;
3301
- }
3302
- };
3303
- function normalizeAddon(value) {
3304
- if (typeof value === "function") return value;
3305
- return () => value || "";
3306
- }
3307
-
3308
3036
  //#endregion
3309
3037
  //#region src/utils/transform-to-rollup-output.ts
3310
3038
  function transformToRollupSourceMap(map) {
@@ -3450,7 +3178,7 @@ function collectChangedBundle(changed, bundle) {
3450
3178
  facadeModuleId: item.facadeModuleId || void 0,
3451
3179
  isDynamicEntry: item.isDynamicEntry,
3452
3180
  moduleIds: item.moduleIds,
3453
- map: bindingifySourcemap(item.map),
3181
+ map: bindingifySourcemap$1(item.map),
3454
3182
  sourcemapFilename: item.sourcemapFileName || void 0,
3455
3183
  preliminaryFilename: item.preliminaryFileName
3456
3184
  });
@@ -3470,7 +3198,7 @@ function bindingifyRenderStart(args$1) {
3470
3198
  const { handler, meta } = normalizeHook(hook);
3471
3199
  return {
3472
3200
  plugin: async (ctx, opts) => {
3473
- handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), new NormalizedInputOptionsImpl(opts, args$1.onLog));
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));
3474
3202
  },
3475
3203
  meta: bindingifyPluginHookMeta(meta)
3476
3204
  };
@@ -3482,13 +3210,13 @@ function bindingifyRenderChunk(args$1) {
3482
3210
  return {
3483
3211
  plugin: async (ctx, code$1, chunk, opts, meta$1) => {
3484
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)])) });
3485
- const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), code$1, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), args$1.pluginContextData.getRenderChunkMeta());
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());
3486
3214
  if (ret == null) return;
3487
3215
  if (typeof ret === "string") return { code: ret };
3488
3216
  if (!ret.map) return { code: ret.code };
3489
3217
  return {
3490
3218
  code: ret.code,
3491
- map: bindingifySourcemap(ret.map)
3219
+ map: bindingifySourcemap$1(ret.map)
3492
3220
  };
3493
3221
  },
3494
3222
  meta: bindingifyPluginHookMeta(meta),
@@ -3529,7 +3257,7 @@ function bindingifyGenerateBundle(args$1) {
3529
3257
  };
3530
3258
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3531
3259
  const output = transformToOutputBundle(context, bundle, changed);
3532
- 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);
3533
3261
  return collectChangedBundle(changed, output);
3534
3262
  },
3535
3263
  meta: bindingifyPluginHookMeta(meta)
@@ -3547,7 +3275,7 @@ function bindingifyWriteBundle(args$1) {
3547
3275
  };
3548
3276
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3549
3277
  const output = transformToOutputBundle(context, bundle, changed);
3550
- 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);
3551
3279
  return collectChangedBundle(changed, output);
3552
3280
  },
3553
3281
  meta: bindingifyPluginHookMeta(meta)
@@ -3781,44 +3509,298 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
3781
3509
  closeWatcherMeta,
3782
3510
  hookUsage
3783
3511
  };
3784
- return wrapHandlers(result);
3512
+ return wrapHandlers(result);
3513
+ }
3514
+ function wrapHandlers(plugin) {
3515
+ for (const hookName of [
3516
+ "buildStart",
3517
+ "resolveId",
3518
+ "resolveDynamicImport",
3519
+ "buildEnd",
3520
+ "transform",
3521
+ "moduleParsed",
3522
+ "load",
3523
+ "renderChunk",
3524
+ "augmentChunkHash",
3525
+ "renderStart",
3526
+ "renderError",
3527
+ "generateBundle",
3528
+ "writeBundle",
3529
+ "closeBundle",
3530
+ "banner",
3531
+ "footer",
3532
+ "intro",
3533
+ "outro",
3534
+ "watchChange",
3535
+ "closeWatcher"
3536
+ ]) {
3537
+ const handler = plugin[hookName];
3538
+ if (handler) plugin[hookName] = async (...args$1) => {
3539
+ try {
3540
+ return await handler(...args$1);
3541
+ } catch (e$1) {
3542
+ return require_parse_ast_index.error(require_parse_ast_index.logPluginError(e$1, plugin.name, {
3543
+ hook: hookName,
3544
+ id: hookName === "transform" ? args$1[2] : void 0
3545
+ }));
3546
+ }
3547
+ };
3548
+ }
3549
+ return plugin;
3550
+ }
3551
+
3552
+ //#endregion
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;
3559
+ }
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
+ };
3785
3694
  }
3786
- function wrapHandlers(plugin) {
3787
- for (const hookName of [
3788
- "buildStart",
3789
- "resolveId",
3790
- "resolveDynamicImport",
3791
- "buildEnd",
3792
- "transform",
3793
- "moduleParsed",
3794
- "load",
3795
- "renderChunk",
3796
- "augmentChunkHash",
3797
- "renderStart",
3798
- "renderError",
3799
- "generateBundle",
3800
- "writeBundle",
3801
- "closeBundle",
3802
- "banner",
3803
- "footer",
3804
- "intro",
3805
- "outro",
3806
- "watchChange",
3807
- "closeWatcher"
3808
- ]) {
3809
- const handler = plugin[hookName];
3810
- if (handler) plugin[hookName] = async (...args$1) => {
3811
- try {
3812
- return await handler(...args$1);
3813
- } catch (e$1) {
3814
- return require_parse_ast_index.error(require_parse_ast_index.logPluginError(e$1, plugin.name, {
3815
- hook: hookName,
3816
- id: hookName === "transform" ? args$1[2] : void 0
3817
- }));
3818
- }
3819
- };
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;
3820
3703
  }
3821
- return plugin;
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 || "";
3822
3804
  }
3823
3805
 
3824
3806
  //#endregion
@@ -3829,6 +3811,13 @@ var PluginContextData = class {
3829
3811
  loadModulePromiseMap = /* @__PURE__ */ new Map();
3830
3812
  loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3831
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
+ }
3832
3821
  updateModuleOption(id$1, option) {
3833
3822
  const existing = this.moduleOptionMap.get(id$1);
3834
3823
  if (existing) {
@@ -3899,6 +3888,14 @@ var PluginContextData = class {
3899
3888
  getRenderChunkMeta() {
3900
3889
  return this.renderedChunkMeta;
3901
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
+ }
3902
3899
  markModuleLoaded(id$1, _success) {
3903
3900
  const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
3904
3901
  if (resolve) resolve();
@@ -3924,7 +3921,7 @@ function isReadonlyArray(input) {
3924
3921
  //#endregion
3925
3922
  //#region src/utils/bindingify-input-options.ts
3926
3923
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3927
- const pluginContextData = new PluginContextData();
3924
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3928
3925
  const plugins = rawPlugins.map((plugin) => {
3929
3926
  if ("_parallel" in plugin) return void 0;
3930
3927
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
@@ -4132,323 +4129,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4132
4129
  };
4133
4130
  }
4134
4131
 
4135
- //#endregion
4136
- //#region src/utils/plugin/index.ts
4137
- const isPluginHookName = function() {
4138
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4139
- return function isPluginHookName$1(hookName) {
4140
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
4141
- };
4142
- }();
4143
-
4144
- //#endregion
4145
- //#region src/utils/compose-js-plugins.ts
4146
- const unsupportedHookName = [
4147
- "augmentChunkHash",
4148
- "generateBundle",
4149
- "moduleParsed",
4150
- "onLog",
4151
- "options",
4152
- "outputOptions",
4153
- "renderError",
4154
- "renderStart",
4155
- "resolveDynamicImport",
4156
- "writeBundle"
4157
- ];
4158
- const unsupportedHooks = new Set(unsupportedHookName);
4159
- function isUnsupportedHooks(hookName) {
4160
- return unsupportedHooks.has(hookName);
4161
- }
4162
- function createComposedPlugin(plugins) {
4163
- const names = [];
4164
- const batchedHooks = {};
4165
- plugins.forEach((plugin, index) => {
4166
- const pluginName = plugin.name || `Anonymous(index: ${index})`;
4167
- names.push(pluginName);
4168
- t(plugin).forEach((pluginProp) => {
4169
- if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
4170
- if (!isPluginHookName(pluginProp)) return;
4171
- switch (pluginProp) {
4172
- case "buildStart": {
4173
- const handlers = batchedHooks.buildStart ?? [];
4174
- batchedHooks.buildStart = handlers;
4175
- if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
4176
- break;
4177
- }
4178
- case "load": {
4179
- const handlers = batchedHooks.load ?? [];
4180
- batchedHooks.load = handlers;
4181
- if (plugin.load) handlers.push([plugin.load, plugin]);
4182
- break;
4183
- }
4184
- case "transform": {
4185
- const handlers = batchedHooks.transform ?? [];
4186
- batchedHooks.transform = handlers;
4187
- if (plugin.transform) handlers.push([plugin.transform, plugin]);
4188
- break;
4189
- }
4190
- case "resolveId": {
4191
- const handlers = batchedHooks.resolveId ?? [];
4192
- batchedHooks.resolveId = handlers;
4193
- if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
4194
- break;
4195
- }
4196
- case "buildEnd": {
4197
- const handlers = batchedHooks.buildEnd ?? [];
4198
- batchedHooks.buildEnd = handlers;
4199
- if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
4200
- break;
4201
- }
4202
- case "renderChunk": {
4203
- const handlers = batchedHooks.renderChunk ?? [];
4204
- batchedHooks.renderChunk = handlers;
4205
- if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
4206
- break;
4207
- }
4208
- case "banner":
4209
- case "footer":
4210
- case "intro":
4211
- case "outro": {
4212
- const hook = plugin[pluginProp];
4213
- if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
4214
- break;
4215
- }
4216
- case "closeBundle": {
4217
- const handlers = batchedHooks.closeBundle ?? [];
4218
- batchedHooks.closeBundle = handlers;
4219
- if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
4220
- break;
4221
- }
4222
- case "watchChange": {
4223
- const handlers = batchedHooks.watchChange ?? [];
4224
- batchedHooks.watchChange = handlers;
4225
- if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
4226
- break;
4227
- }
4228
- case "closeWatcher": {
4229
- const handlers = batchedHooks.closeWatcher ?? [];
4230
- batchedHooks.closeWatcher = handlers;
4231
- if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
4232
- break;
4233
- }
4234
- default: {}
4235
- }
4236
- });
4237
- });
4238
- const composed = { name: `Composed(${names.join(", ")})` };
4239
- const createFixedPluginResolveFnMap = /* @__PURE__ */ new Map();
4240
- function applyFixedPluginResolveFn(ctx, plugin) {
4241
- const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
4242
- if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
4243
- return ctx;
4244
- }
4245
- if (batchedHooks.resolveId) {
4246
- const batchedHandlers = batchedHooks.resolveId;
4247
- const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
4248
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4249
- const [_handler, plugin] = batchedHandlers[handlerIdx];
4250
- const handlerSymbol = handlerSymbols[handlerIdx];
4251
- const createFixedPluginResolveFn = (ctx, resolve) => {
4252
- return (source, importer, rawContextResolveOptions) => {
4253
- const contextResolveOptions = rawContextResolveOptions ?? {};
4254
- if (contextResolveOptions.skipSelf) {
4255
- contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
4256
- contextResolveOptions.skipSelf = false;
4257
- }
4258
- return resolve(source, importer, contextResolveOptions);
4259
- };
4260
- };
4261
- createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
4262
- }
4263
- composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
4264
- const hookResolveIdOptions = rawHookResolveIdOptions;
4265
- const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
4266
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4267
- const [handler, plugin] = batchedHandlers[handlerIdx];
4268
- const handlerSymbol = handlerSymbols[handlerIdx];
4269
- if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
4270
- const { handler: handlerFn } = normalizeHook(handler);
4271
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
4272
- if (!require_dist.isNullish(result)) return result;
4273
- }
4274
- };
4275
- }
4276
- t(batchedHooks).forEach((hookName) => {
4277
- switch (hookName) {
4278
- case "resolveId": break;
4279
- case "buildStart": {
4280
- if (batchedHooks.buildStart) {
4281
- const batchedHandlers = batchedHooks.buildStart;
4282
- composed.buildStart = async function(options) {
4283
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4284
- const { handler: handlerFn } = normalizeHook(handler);
4285
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
4286
- }));
4287
- };
4288
- }
4289
- break;
4290
- }
4291
- case "load": {
4292
- if (batchedHooks.load) {
4293
- const batchedHandlers = batchedHooks.load;
4294
- composed.load = async function(id$1) {
4295
- for (const [handler, plugin] of batchedHandlers) {
4296
- const { handler: handlerFn } = normalizeHook(handler);
4297
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
4298
- if (!require_dist.isNullish(result)) return result;
4299
- }
4300
- };
4301
- }
4302
- break;
4303
- }
4304
- case "transform": {
4305
- if (batchedHooks.transform) {
4306
- const batchedHandlers = batchedHooks.transform;
4307
- composed.transform = async function(initialCode, id$1, moduleType$1) {
4308
- let code$1 = initialCode;
4309
- let moduleSideEffects = void 0;
4310
- function updateOutput(newCode, newModuleSideEffects) {
4311
- code$1 = newCode;
4312
- moduleSideEffects = newModuleSideEffects ?? void 0;
4313
- }
4314
- for (const [handler, plugin] of batchedHandlers) {
4315
- const { handler: handlerFn } = normalizeHook(handler);
4316
- this.getCombinedSourcemap = () => {
4317
- throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
4318
- };
4319
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
4320
- if (!require_dist.isNullish(result)) {
4321
- if (typeof result === "string") updateOutput(result);
4322
- else if (result.code) updateOutput(result.code, result.moduleSideEffects);
4323
- }
4324
- }
4325
- return {
4326
- code: code$1,
4327
- moduleSideEffects
4328
- };
4329
- };
4330
- }
4331
- break;
4332
- }
4333
- case "buildEnd": {
4334
- if (batchedHooks.buildEnd) {
4335
- const batchedHandlers = batchedHooks.buildEnd;
4336
- composed.buildEnd = async function(err) {
4337
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4338
- const { handler: handlerFn } = normalizeHook(handler);
4339
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
4340
- }));
4341
- };
4342
- }
4343
- break;
4344
- }
4345
- case "renderChunk": {
4346
- if (batchedHooks.renderChunk) {
4347
- const batchedHandlers = batchedHooks.renderChunk;
4348
- composed.renderChunk = async function(code$1, chunk, options, meta) {
4349
- for (const [handler, plugin] of batchedHandlers) {
4350
- const { handler: handlerFn } = normalizeHook(handler);
4351
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
4352
- if (!require_dist.isNullish(result)) return result;
4353
- }
4354
- };
4355
- }
4356
- break;
4357
- }
4358
- case "banner":
4359
- case "footer":
4360
- case "intro":
4361
- case "outro": {
4362
- const hooks = batchedHooks[hookName];
4363
- if (hooks?.length) composed[hookName] = async function(chunk) {
4364
- const ret = [];
4365
- for (const [hook, plugin] of hooks) {
4366
- const { handler } = normalizeHook(hook);
4367
- ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
4368
- }
4369
- return ret.join("\n");
4370
- };
4371
- break;
4372
- }
4373
- case "closeBundle": {
4374
- if (batchedHooks.closeBundle) {
4375
- const batchedHandlers = batchedHooks.closeBundle;
4376
- composed.closeBundle = async function() {
4377
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4378
- const { handler: handlerFn } = normalizeHook(handler);
4379
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4380
- }));
4381
- };
4382
- }
4383
- break;
4384
- }
4385
- case "watchChange": {
4386
- if (batchedHooks.watchChange) {
4387
- const batchedHandlers = batchedHooks.watchChange;
4388
- composed.watchChange = async function(id$1, event) {
4389
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4390
- const { handler: handlerFn } = normalizeHook(handler);
4391
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
4392
- }));
4393
- };
4394
- }
4395
- break;
4396
- }
4397
- case "closeWatcher": {
4398
- if (batchedHooks.closeWatcher) {
4399
- const batchedHandlers = batchedHooks.closeWatcher;
4400
- composed.closeWatcher = async function() {
4401
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4402
- const { handler: handlerFn } = normalizeHook(handler);
4403
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4404
- }));
4405
- };
4406
- }
4407
- break;
4408
- }
4409
- default: {}
4410
- }
4411
- });
4412
- return composed;
4413
- }
4414
- function isComposablePlugin(plugin) {
4415
- if (plugin instanceof BuiltinPlugin) return false;
4416
- if ("_parallel" in plugin) return false;
4417
- const hasNotComposablePattern = t(plugin).some((hookName) => {
4418
- if (!isPluginHookName(hookName)) return false;
4419
- const OK_TO_COMPOSE = false;
4420
- if (isUnsupportedHooks(hookName)) return true;
4421
- if (plugin[hookName]) {
4422
- const { meta } = normalizeHook(plugin[hookName]);
4423
- if (meta.order === "pre" || meta.order === "post") return true;
4424
- }
4425
- return OK_TO_COMPOSE;
4426
- });
4427
- if (hasNotComposablePattern) return false;
4428
- return true;
4429
- }
4430
- function composeJsPlugins(plugins) {
4431
- const newPlugins = [];
4432
- const toBeComposed = [];
4433
- plugins.forEach((plugin) => {
4434
- if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
4435
- else {
4436
- if (toBeComposed.length > 0) {
4437
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4438
- else newPlugins.push(toBeComposed[0]);
4439
- toBeComposed.length = 0;
4440
- }
4441
- newPlugins.push(plugin);
4442
- }
4443
- });
4444
- if (toBeComposed.length > 0) {
4445
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4446
- else newPlugins.push(toBeComposed[0]);
4447
- toBeComposed.length = 0;
4448
- }
4449
- return newPlugins;
4450
- }
4451
-
4452
4132
  //#endregion
4453
4133
  //#region src/utils/initialize-parallel-plugins.ts
4454
4134
  async function initializeParallelPlugins(plugins) {
@@ -4525,7 +4205,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4525
4205
  ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4526
4206
  ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4527
4207
  ];
4528
- if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
4529
4208
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
4530
4209
  try {
4531
4210
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -4849,12 +4528,6 @@ Object.defineProperty(exports, 'buildImportAnalysisPlugin', {
4849
4528
  return buildImportAnalysisPlugin;
4850
4529
  }
4851
4530
  });
4852
- Object.defineProperty(exports, 'composeJsPlugins', {
4853
- enumerable: true,
4854
- get: function () {
4855
- return composeJsPlugins;
4856
- }
4857
- });
4858
4531
  Object.defineProperty(exports, 'createBundlerImpl', {
4859
4532
  enumerable: true,
4860
4533
  get: function () {