@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
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
 
28
28
  //#endregion
29
29
  //#region package.json
30
- var version = "1.0.0-beta.21";
30
+ var version = "1.0.0-beta.23";
31
31
 
32
32
  //#endregion
33
33
  //#region src/builtin-plugin/utils.ts
@@ -69,8 +69,8 @@ function reporterPlugin(config) {
69
69
  function manifestPlugin(config) {
70
70
  return new BuiltinPlugin("builtin:manifest", config);
71
71
  }
72
- function wasmHelperPlugin() {
73
- return new BuiltinPlugin("builtin:wasm-helper");
72
+ function wasmHelperPlugin(config) {
73
+ return new BuiltinPlugin("builtin:wasm-helper", config);
74
74
  }
75
75
  function wasmFallbackPlugin() {
76
76
  const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
@@ -131,9 +131,9 @@ let _lazyMatch = () => {
131
131
  enumerable: true
132
132
  });
133
133
  }, H = (r$1, e$1, n$1, a$2) => {
134
- if (e$1 && typeof e$1 == "object" || typeof e$1 == "function") for (let t$2 of G(e$1)) !T.call(r$1, t$2) && t$2 !== n$1 && m$1(r$1, t$2, {
135
- get: () => e$1[t$2],
136
- enumerable: !(a$2 = V(e$1, t$2)) || a$2.enumerable
134
+ if (e$1 && typeof e$1 == "object" || typeof e$1 == "function") for (let t$1 of G(e$1)) !T.call(r$1, t$1) && t$1 !== n$1 && m$1(r$1, t$1, {
135
+ get: () => e$1[t$1],
136
+ enumerable: !(a$2 = V(e$1, t$1)) || a$2.enumerable
137
137
  });
138
138
  return r$1;
139
139
  }, J = (r$1) => H(m$1({}, "__esModule", { value: true }), r$1), w$1 = {};
@@ -143,8 +143,8 @@ let _lazyMatch = () => {
143
143
  return (n$1) => {
144
144
  const a$2 = e$1.get(n$1);
145
145
  if (a$2) return a$2;
146
- const t$2 = r$1(n$1);
147
- return e$1.set(n$1, t$2), t$2;
146
+ const t$1 = r$1(n$1);
147
+ return e$1.set(n$1, t$1), t$1;
148
148
  };
149
149
  }, rr = (r$1, e$1, n$1 = {}) => {
150
150
  const a$2 = {
@@ -161,16 +161,16 @@ let _lazyMatch = () => {
161
161
  const n$1 = {};
162
162
  for (const a$2 of r$1) {
163
163
  if (a$2.length !== 1) throw new Error(`Invalid character: "${a$2}"`);
164
- const t$2 = a$2.charCodeAt(0);
165
- n$1[t$2] = true;
164
+ const t$1 = a$2.charCodeAt(0);
165
+ n$1[t$1] = true;
166
166
  }
167
167
  return (a$2) => {
168
- const t$2 = a$2.index, o$1 = a$2.input;
168
+ const t$1 = a$2.index, o$1 = a$2.input;
169
169
  for (; a$2.index < o$1.length && o$1.charCodeAt(a$2.index) in n$1;) a$2.index += 1;
170
170
  const u$3 = a$2.index;
171
- if (u$3 > t$2) {
171
+ if (u$3 > t$1) {
172
172
  if (!h$1(e$1) && !a$2.options.silent) {
173
- const s$1 = a$2.input.slice(t$2, u$3), c$1 = d$2(e$1) ? e$1(s$1, o$1, String(t$2)) : e$1;
173
+ const s$1 = a$2.input.slice(t$1, u$3), c$1 = d$2(e$1) ? e$1(s$1, o$1, String(t$1)) : e$1;
174
174
  h$1(c$1) || a$2.output.push(c$1);
175
175
  }
176
176
  a$2.indexMax = Math.max(a$2.indexMax, a$2.index);
@@ -178,10 +178,10 @@ let _lazyMatch = () => {
178
178
  return true;
179
179
  };
180
180
  }, nr = (r$1, e$1) => {
181
- const n$1 = r$1.source, a$2 = r$1.flags.replace(/y|$/, "y"), t$2 = new RegExp(n$1, a$2);
181
+ const n$1 = r$1.source, a$2 = r$1.flags.replace(/y|$/, "y"), t$1 = new RegExp(n$1, a$2);
182
182
  return g$1((o$1) => {
183
- t$2.lastIndex = o$1.index;
184
- const u$3 = t$2.exec(o$1.input);
183
+ t$1.lastIndex = o$1.index;
184
+ const u$3 = t$1.exec(o$1.input);
185
185
  if (u$3) {
186
186
  if (!h$1(e$1) && !o$1.options.silent) {
187
187
  const s$1 = d$2(e$1) ? e$1(...u$3, o$1.input, String(o$1.index)) : e$1;
@@ -193,38 +193,38 @@ let _lazyMatch = () => {
193
193
  }, ar = (r$1, e$1) => (n$1) => {
194
194
  if (n$1.input.startsWith(r$1, n$1.index)) {
195
195
  if (!h$1(e$1) && !n$1.options.silent) {
196
- const t$2 = d$2(e$1) ? e$1(r$1, n$1.input, String(n$1.index)) : e$1;
197
- h$1(t$2) || n$1.output.push(t$2);
196
+ const t$1 = d$2(e$1) ? e$1(r$1, n$1.input, String(n$1.index)) : e$1;
197
+ h$1(t$1) || n$1.output.push(t$1);
198
198
  }
199
199
  return n$1.index += r$1.length, n$1.indexMax = Math.max(n$1.indexMax, n$1.index), true;
200
200
  } else return false;
201
201
  }, C = (r$1, e$1, n$1, a$2) => {
202
- const t$2 = v(r$1);
202
+ const t$1 = v(r$1);
203
203
  return g$1(_(M((o$1) => {
204
204
  let u$3 = 0;
205
205
  for (; u$3 < n$1;) {
206
206
  const s$1 = o$1.index;
207
- if (!t$2(o$1) || (u$3 += 1, o$1.index === s$1)) break;
207
+ if (!t$1(o$1) || (u$3 += 1, o$1.index === s$1)) break;
208
208
  }
209
209
  return u$3 >= e$1;
210
210
  })));
211
211
  }, tr = (r$1, e$1) => C(r$1, 0, 1), f$1 = (r$1, e$1) => C(r$1, 0, Infinity), x = (r$1, e$1) => {
212
212
  const n$1 = r$1.map(v);
213
213
  return g$1(_(M((a$2) => {
214
- for (let t$2 = 0, o$1 = n$1.length; t$2 < o$1; t$2++) if (!n$1[t$2](a$2)) return false;
214
+ for (let t$1 = 0, o$1 = n$1.length; t$1 < o$1; t$1++) if (!n$1[t$1](a$2)) return false;
215
215
  return true;
216
216
  })));
217
217
  }, l$1 = (r$1, e$1) => {
218
218
  const n$1 = r$1.map(v);
219
219
  return g$1(_((a$2) => {
220
- for (let t$2 = 0, o$1 = n$1.length; t$2 < o$1; t$2++) if (n$1[t$2](a$2)) return true;
220
+ for (let t$1 = 0, o$1 = n$1.length; t$1 < o$1; t$1++) if (n$1[t$1](a$2)) return true;
221
221
  return false;
222
222
  }));
223
223
  }, M = (r$1, e$1 = false) => {
224
224
  const n$1 = v(r$1);
225
225
  return (a$2) => {
226
- const t$2 = a$2.index, o$1 = a$2.output.length, u$3 = n$1(a$2);
227
- return (!u$3 || e$1) && (a$2.index = t$2, a$2.output.length !== o$1 && (a$2.output.length = o$1)), u$3;
226
+ const t$1 = a$2.index, o$1 = a$2.output.length, u$3 = n$1(a$2);
227
+ return (!u$3 || e$1) && (a$2.index = t$1, a$2.output.length !== o$1 && (a$2.output.length = o$1)), u$3;
228
228
  };
229
229
  }, _ = (r$1, e$1) => {
230
230
  const n$1 = v(r$1);
@@ -233,19 +233,19 @@ let _lazyMatch = () => {
233
233
  let r$1 = 0;
234
234
  return (e$1) => {
235
235
  const n$1 = v(e$1), a$2 = r$1 += 1;
236
- return (t$2) => {
236
+ return (t$1) => {
237
237
  var o$1;
238
- if (t$2.options.memoization === false) return n$1(t$2);
239
- const u$3 = t$2.index, s$1 = (o$1 = t$2.cache)[a$2] || (o$1[a$2] = /* @__PURE__ */ new Map()), c$1 = s$1.get(u$3);
238
+ if (t$1.options.memoization === false) return n$1(t$1);
239
+ const u$3 = t$1.index, s$1 = (o$1 = t$1.cache)[a$2] || (o$1[a$2] = /* @__PURE__ */ new Map()), c$1 = s$1.get(u$3);
240
240
  if (c$1 === false) return false;
241
- if (W(c$1)) return t$2.index = c$1, true;
242
- if (c$1) return t$2.index = c$1.index, c$1.output?.length && t$2.output.push(...c$1.output), true;
241
+ if (W(c$1)) return t$1.index = c$1, true;
242
+ if (c$1) return t$1.index = c$1.index, c$1.output?.length && t$1.output.push(...c$1.output), true;
243
243
  {
244
- const Z = t$2.output.length;
245
- if (n$1(t$2)) {
246
- const D = t$2.index, U = t$2.output.length;
244
+ const Z = t$1.output.length;
245
+ if (n$1(t$1)) {
246
+ const D = t$1.index, U = t$1.output.length;
247
247
  if (U > Z) {
248
- const ee = t$2.output.slice(Z, U);
248
+ const ee = t$1.output.slice(Z, U);
249
249
  s$1.set(u$3, {
250
250
  index: D,
251
251
  output: ee
@@ -345,7 +345,7 @@ let _lazyMatch = () => {
345
345
  ])), Kr = Wr, Xr = z(Kr), Yr = Xr, $ = (r$1, e$1) => {
346
346
  const n$1 = Array.isArray(r$1) ? r$1 : [r$1];
347
347
  if (!n$1.length) return false;
348
- const a$2 = n$1.map($.compile), t$2 = n$1.every((s$1) => /(\/(?:\*\*)?|\[\/\])$/.test(s$1)), o$1 = e$1.replace(/[\\\/]+/g, "/").replace(/\/$/, t$2 ? "/" : "");
348
+ const a$2 = n$1.map($.compile), t$1 = n$1.every((s$1) => /(\/(?:\*\*)?|\[\/\])$/.test(s$1)), o$1 = e$1.replace(/[\\\/]+/g, "/").replace(/\/$/, t$1 ? "/" : "");
349
349
  return a$2.some((s$1) => s$1.test(o$1));
350
350
  };
351
351
  $.compile = (r$1) => new RegExp(`^${L(Yr(r$1))}$`, "s");
@@ -580,9 +580,6 @@ const win32 = /* @__PURE__ */ mix(";");
580
580
  function arraify(value) {
581
581
  return Array.isArray(value) ? value : [value];
582
582
  }
583
- function isNullish(value) {
584
- return value === null || value === void 0;
585
- }
586
583
  function unimplemented(info) {
587
584
  if (info) throw new Error(`unimplemented: ${info}`);
588
585
  throw new Error("unimplemented");
@@ -2059,18 +2056,18 @@ function safeParse(schema, input, config2) {
2059
2056
  //#endregion
2060
2057
  //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
2061
2058
  var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs"(exports, module) {
2062
- 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) => {
2063
- 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);
2059
+ let e, t, r, { defineProperty: n, setPrototypeOf: l, create: o, keys: s } = Object, i$1 = "", { round: c, max: a$1 } = Math, p = (e$1) => {
2060
+ 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);
2064
2061
  return [
2065
2062
  n$1 >> 16 & 255,
2066
2063
  n$1 >> 8 & 255,
2067
2064
  255 & n$1
2068
2065
  ];
2069
- }, 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) => {
2070
- let t$2, r$1, n$1, l$1, o$1;
2071
- 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);
2066
+ }, 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) => {
2067
+ let t$1, r$1, n$1, l$1, o$1;
2068
+ 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);
2072
2069
  }, g = (() => {
2073
- 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;
2070
+ 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;
2074
2071
  try {
2075
2072
  e = "," + s(i$2).join(",");
2076
2073
  } catch (e$1) {
@@ -2083,31 +2080,31 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
2083
2080
  2: 2,
2084
2081
  3: 3
2085
2082
  }[i$2[a$2]] ?? -1, u$3 = a$2 in i$2 && p$1 || r$1(/^--color=?(true|always)?$/);
2086
- return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t$1 = r$2.TERM, {
2083
+ return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t = r$2.TERM, {
2087
2084
  "24bit": 3,
2088
2085
  truecolor: 3,
2089
2086
  ansi256: 2,
2090
2087
  ansi: 1
2091
- }[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;
2088
+ }[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;
2092
2089
  })(), f = {
2093
2090
  open: i$1,
2094
2091
  close: i$1
2095
- }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$2, close: n$1 }) => {
2092
+ }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$1, close: n$1 }) => {
2096
2093
  let o$1 = (e$2, ...r$1) => {
2097
2094
  if (!e$2) {
2098
- if (t$2 && t$2 === n$1) return t$2;
2095
+ if (t$1 && t$1 === n$1) return t$1;
2099
2096
  if ((e$2 ?? i$1) === i$1) return i$1;
2100
2097
  }
2101
2098
  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;
2102
2099
  if (s$2.includes("\x1B")) for (; c$2; c$2 = c$2.p) {
2103
- let { open: e$3, close: t$3 } = c$2, r$2 = t$3.length, n$2 = i$1, o$2 = 0;
2104
- 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;
2100
+ let { open: e$3, close: t$2 } = c$2, r$2 = t$2.length, n$2 = i$1, o$2 = 0;
2101
+ 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;
2105
2102
  s$2 = n$2 + s$2.slice(o$2);
2106
2103
  }
2107
2104
  return a$2 + (s$2.includes("\n") ? s$2.replace(/(\r?\n)/g, p$1 + "$1" + a$2) : s$2) + p$1;
2108
- }, s$1 = t$2, c$1 = n$1;
2109
- return e$1 && (s$1 = e$1.o + t$2, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
2110
- open: t$2,
2105
+ }, s$1 = t$1, c$1 = n$1;
2106
+ return e$1 && (s$1 = e$1.o + t$1, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
2107
+ open: t$1,
2111
2108
  close: n$1,
2112
2109
  o: s$1,
2113
2110
  c: c$1,
@@ -2115,27 +2112,27 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
2115
2112
  }, o$1.open = s$1, o$1.close = c$1, o$1;
2116
2113
  };
2117
2114
  const w = function(e$1 = g) {
2118
- let t$2 = {
2115
+ let t$1 = {
2119
2116
  Ansis: w,
2120
2117
  level: e$1,
2121
2118
  isSupported: () => s$1,
2122
2119
  strip: (e$2) => e$2.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i$1),
2123
2120
  extend(e$2) {
2124
- for (let t$3 in e$2) {
2125
- let r$1 = e$2[t$3], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
2126
- O[t$3] = "f" === l$1 ? { get() {
2121
+ for (let t$2 in e$2) {
2122
+ let r$1 = e$2[t$2], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
2123
+ O[t$2] = "f" === l$1 ? { get() {
2127
2124
  return (...e$3) => m(this, r$1(...e$3));
2128
2125
  } } : { get() {
2129
2126
  let e$3 = m(this, o$1);
2130
- return n(this, t$3, { value: e$3 }), e$3;
2127
+ return n(this, t$2, { value: e$3 }), e$3;
2131
2128
  } };
2132
2129
  }
2133
- return r = o({}, O), l(t$2, r), t$2;
2130
+ return r = o({}, O), l(t$1, r), t$1;
2134
2131
  }
2135
- }, s$1 = e$1 > 0, c$1 = (e$2, t$3) => s$1 ? {
2132
+ }, s$1 = e$1 > 0, c$1 = (e$2, t$2) => s$1 ? {
2136
2133
  open: `[${e$2}m`,
2137
- close: `[${t$3}m`
2138
- } : 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);
2134
+ close: `[${t$2}m`
2135
+ } : 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);
2139
2136
  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));
2140
2137
  let E, M = {
2141
2138
  fg: v,
@@ -2154,9 +2151,9 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
2154
2151
  hidden: c$1(8, 28),
2155
2152
  strikethrough: c$1(9, 29)
2156
2153
  }, I = "Bright";
2157
- return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$3) => {
2158
- 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);
2159
- }), t$2.extend(M);
2154
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$2) => {
2155
+ 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);
2156
+ }), t$1.extend(M);
2160
2157
  }, y = new w();
2161
2158
  module.exports = y, y.default = y;
2162
2159
  } });
@@ -2310,7 +2307,8 @@ const ResolveOptionsSchema = strictObject({
2310
2307
  const TreeshakingOptionsSchema = union([boolean(), looseObject({
2311
2308
  annotations: optional(boolean()),
2312
2309
  manualPureFunctions: optional(array(string())),
2313
- unknownGlobalSideEffects: optional(boolean())
2310
+ unknownGlobalSideEffects: optional(boolean()),
2311
+ commonjs: optional(boolean())
2314
2312
  })]);
2315
2313
  const OnLogSchema = pipe(function_(), args(tuple([
2316
2314
  LogLevelSchema,
@@ -2559,41 +2557,9 @@ function validateOption(key, options) {
2559
2557
  }
2560
2558
  }
2561
2559
 
2562
- //#endregion
2563
- //#region src/constants/plugin-context.ts
2564
- /**
2565
- * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2566
- * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2567
- * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2568
- * internally.
2569
- */
2570
- const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2571
-
2572
- //#endregion
2573
- //#region src/options/normalized-input-options.ts
2574
- var NormalizedInputOptionsImpl = class {
2575
- inner;
2576
- constructor(inner, onLog) {
2577
- this.onLog = onLog;
2578
- this.inner = inner;
2579
- }
2580
- get shimMissingExports() {
2581
- return this.inner.shimMissingExports;
2582
- }
2583
- get input() {
2584
- return this.inner.input;
2585
- }
2586
- get cwd() {
2587
- return this.inner.cwd ?? void 0;
2588
- }
2589
- get platform() {
2590
- return this.inner.platform;
2591
- }
2592
- };
2593
-
2594
2560
  //#endregion
2595
2561
  //#region src/types/sourcemap.ts
2596
- function bindingifySourcemap(map) {
2562
+ function bindingifySourcemap$1(map) {
2597
2563
  if (map == null) return;
2598
2564
  return { inner: typeof map === "string" ? map : {
2599
2565
  file: map.file ?? void 0,
@@ -2793,8 +2759,8 @@ function exclude(expr) {
2793
2759
  //#endregion
2794
2760
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
2795
2761
  function u$1(o$1, n$1, a$2) {
2796
- let t$2 = (r$1) => o$1(r$1, ...n$1);
2797
- return a$2 === void 0 ? t$2 : Object.assign(t$2, {
2762
+ let t$1 = (r$1) => o$1(r$1, ...n$1);
2763
+ return a$2 === void 0 ? t$1 : Object.assign(t$1, {
2798
2764
  lazy: a$2,
2799
2765
  lazyArgs: n$1
2800
2766
  });
@@ -2814,18 +2780,12 @@ function u(r$1, n$1, o$1) {
2814
2780
  function d(...r$1) {
2815
2781
  return u(i, r$1);
2816
2782
  }
2817
- var i = (r$1, t$2) => {
2783
+ var i = (r$1, t$1) => {
2818
2784
  let a$2 = [[], []];
2819
- 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);
2785
+ 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);
2820
2786
  return a$2;
2821
2787
  };
2822
2788
 
2823
- //#endregion
2824
- //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
2825
- function t(...n$1) {
2826
- return u(Object.keys, n$1);
2827
- }
2828
-
2829
2789
  //#endregion
2830
2790
  //#region src/plugin/bindingify-hook-filter.ts
2831
2791
  function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
@@ -3108,9 +3068,14 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
3108
3068
  async resolve(source, importer, options) {
3109
3069
  let receipt = void 0;
3110
3070
  if (options != null) receipt = this.data.saveResolveOptions(options);
3071
+ const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
3072
+ if (key.startsWith("vite:")) (acc ??= {})[key] = value;
3073
+ return acc;
3074
+ }, void 0);
3111
3075
  const res = await this.context.resolve(source, importer, {
3112
3076
  custom: receipt,
3113
- skipSelf: options?.skipSelf
3077
+ skipSelf: options?.skipSelf,
3078
+ vitePluginCustom
3114
3079
  });
3115
3080
  if (receipt != null) this.data.removeSavedResolveOptions(receipt);
3116
3081
  if (res == null) return null;
@@ -3196,7 +3161,7 @@ function bindingifyBuildStart(args$1) {
3196
3161
  const { handler, meta } = normalizeHook(hook);
3197
3162
  return {
3198
3163
  plugin: async (ctx, opts) => {
3199
- 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));
3164
+ 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));
3200
3165
  },
3201
3166
  meta: bindingifyPluginHookMeta(meta)
3202
3167
  };
@@ -3219,12 +3184,10 @@ function bindingifyResolveId(args$1) {
3219
3184
  return {
3220
3185
  plugin: async (ctx, specifier, importer, extraOptions) => {
3221
3186
  const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
3222
- const newExtraOptions = {
3187
+ 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, {
3223
3188
  ...extraOptions,
3224
- custom: contextResolveOptions?.custom,
3225
- [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
3226
- };
3227
- 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);
3189
+ custom: contextResolveOptions?.custom
3190
+ });
3228
3191
  if (ret == null) return;
3229
3192
  if (ret === false) return {
3230
3193
  id: specifier,
@@ -3295,7 +3258,7 @@ function bindingifyTransform(args$1) {
3295
3258
  });
3296
3259
  return {
3297
3260
  code: ret.code,
3298
- map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
3261
+ map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
3299
3262
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
3300
3263
  moduleType: ret.moduleType
3301
3264
  };
@@ -3321,7 +3284,7 @@ function bindingifyLoad(args$1) {
3321
3284
  let map = preProcessSourceMap(ret, id$1);
3322
3285
  return {
3323
3286
  code: ret.code,
3324
- map: bindingifySourcemap(map),
3287
+ map: bindingifySourcemap$1(map),
3325
3288
  moduleType: ret.moduleType,
3326
3289
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
3327
3290
  };
@@ -3417,205 +3380,6 @@ function transformChunkModules(modules) {
3417
3380
  return result;
3418
3381
  }
3419
3382
 
3420
- //#endregion
3421
- //#region src/utils/bindingify-output-options.ts
3422
- function bindingifyOutputOptions(outputOptions) {
3423
- const { dir, format: format$1, exports, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks } = outputOptions;
3424
- let { advancedChunks } = outputOptions;
3425
- if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
3426
- else if (manualChunks != null) advancedChunks = { groups: [{ name(id$1) {
3427
- return manualChunks(id$1, {});
3428
- } }] };
3429
- return {
3430
- dir,
3431
- file: file == null ? void 0 : file,
3432
- format: bindingifyFormat(format$1),
3433
- exports,
3434
- hashCharacters,
3435
- sourcemap: bindingifySourcemap$1(sourcemap),
3436
- sourcemapDebugIds,
3437
- sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3438
- sourcemapPathTransform,
3439
- banner: bindingifyAddon(banner),
3440
- footer: bindingifyAddon(footer),
3441
- intro: bindingifyAddon(intro),
3442
- outro: bindingifyAddon(outro),
3443
- extend: outputOptions.extend,
3444
- globals,
3445
- esModule,
3446
- name,
3447
- assetFileNames: bindingifyAssetFilenames(assetFileNames),
3448
- entryFileNames,
3449
- chunkFileNames,
3450
- cssEntryFileNames,
3451
- cssChunkFileNames,
3452
- plugins: [],
3453
- minify: outputOptions.minify,
3454
- externalLiveBindings: outputOptions.externalLiveBindings,
3455
- inlineDynamicImports: outputOptions.inlineDynamicImports,
3456
- advancedChunks,
3457
- polyfillRequire: outputOptions.polyfillRequire,
3458
- sanitizeFileName,
3459
- preserveModules,
3460
- virtualDirname,
3461
- legalComments,
3462
- preserveModulesRoot
3463
- };
3464
- }
3465
- function bindingifyAddon(configAddon) {
3466
- return async (chunk) => {
3467
- if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3468
- return configAddon || "";
3469
- };
3470
- }
3471
- function bindingifyFormat(format$1) {
3472
- switch (format$1) {
3473
- case void 0:
3474
- case "es":
3475
- case "esm":
3476
- case "module": return "es";
3477
- case "cjs":
3478
- case "commonjs": return "cjs";
3479
- case "iife": return "iife";
3480
- case "umd": return "umd";
3481
- default: unimplemented(`output.format: ${format$1}`);
3482
- }
3483
- }
3484
- function bindingifySourcemap$1(sourcemap) {
3485
- switch (sourcemap) {
3486
- case true: return "file";
3487
- case "inline": return "inline";
3488
- case false:
3489
- case void 0: return void 0;
3490
- case "hidden": return "hidden";
3491
- default: throw new Error(`unknown sourcemap: ${sourcemap}`);
3492
- }
3493
- }
3494
- function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
3495
- return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
3496
- }
3497
- function bindingifyAssetFilenames(assetFileNames) {
3498
- if (typeof assetFileNames === "function") return (asset) => {
3499
- return assetFileNames({
3500
- names: asset.names,
3501
- originalFileNames: asset.originalFileNames,
3502
- source: transformAssetSource(asset.source),
3503
- type: "asset"
3504
- });
3505
- };
3506
- return assetFileNames;
3507
- }
3508
-
3509
- //#endregion
3510
- //#region src/options/normalized-output-options.ts
3511
- var NormalizedOutputOptionsImpl = class {
3512
- constructor(inner, outputOptions, normalizedOutputPlugins) {
3513
- this.inner = inner;
3514
- this.outputOptions = outputOptions;
3515
- this.normalizedOutputPlugins = normalizedOutputPlugins;
3516
- }
3517
- get dir() {
3518
- return this.inner.dir ?? void 0;
3519
- }
3520
- get entryFileNames() {
3521
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3522
- }
3523
- get chunkFileNames() {
3524
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3525
- }
3526
- get assetFileNames() {
3527
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3528
- }
3529
- get format() {
3530
- return this.inner.format;
3531
- }
3532
- get exports() {
3533
- return this.inner.exports;
3534
- }
3535
- get sourcemap() {
3536
- return this.inner.sourcemap;
3537
- }
3538
- get cssEntryFileNames() {
3539
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3540
- }
3541
- get cssChunkFileNames() {
3542
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3543
- }
3544
- get shimMissingExports() {
3545
- return this.inner.shimMissingExports;
3546
- }
3547
- get name() {
3548
- return this.inner.name ?? void 0;
3549
- }
3550
- get file() {
3551
- return this.inner.file ?? void 0;
3552
- }
3553
- get inlineDynamicImports() {
3554
- return this.inner.inlineDynamicImports;
3555
- }
3556
- get externalLiveBindings() {
3557
- return this.inner.externalLiveBindings;
3558
- }
3559
- get banner() {
3560
- return normalizeAddon(this.outputOptions.banner);
3561
- }
3562
- get footer() {
3563
- return normalizeAddon(this.outputOptions.footer);
3564
- }
3565
- get intro() {
3566
- return normalizeAddon(this.outputOptions.intro);
3567
- }
3568
- get outro() {
3569
- return normalizeAddon(this.outputOptions.outro);
3570
- }
3571
- get esModule() {
3572
- return this.inner.esModule;
3573
- }
3574
- get extend() {
3575
- return this.inner.extend;
3576
- }
3577
- get globals() {
3578
- return this.inner.globals || this.outputOptions.globals;
3579
- }
3580
- get hashCharacters() {
3581
- return this.inner.hashCharacters;
3582
- }
3583
- get sourcemapDebugIds() {
3584
- return this.inner.sourcemapDebugIds;
3585
- }
3586
- get sourcemapIgnoreList() {
3587
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3588
- }
3589
- get sourcemapPathTransform() {
3590
- return this.outputOptions.sourcemapPathTransform;
3591
- }
3592
- get minify() {
3593
- return this.inner.minify;
3594
- }
3595
- get legalComments() {
3596
- return this.inner.legalComments;
3597
- }
3598
- get polyfillRequire() {
3599
- return this.inner.polyfillRequire;
3600
- }
3601
- get plugins() {
3602
- return this.normalizedOutputPlugins;
3603
- }
3604
- get preserveModules() {
3605
- return this.inner.preserveModules;
3606
- }
3607
- get preserveModulesRoot() {
3608
- return this.inner.preserveModulesRoot;
3609
- }
3610
- get virtualDirname() {
3611
- return this.inner.virtualDirname;
3612
- }
3613
- };
3614
- function normalizeAddon(value) {
3615
- if (typeof value === "function") return value;
3616
- return () => value || "";
3617
- }
3618
-
3619
3383
  //#endregion
3620
3384
  //#region src/utils/transform-to-rollup-output.ts
3621
3385
  function transformToRollupSourceMap(map) {
@@ -3761,7 +3525,7 @@ function collectChangedBundle(changed, bundle) {
3761
3525
  facadeModuleId: item.facadeModuleId || void 0,
3762
3526
  isDynamicEntry: item.isDynamicEntry,
3763
3527
  moduleIds: item.moduleIds,
3764
- map: bindingifySourcemap(item.map),
3528
+ map: bindingifySourcemap$1(item.map),
3765
3529
  sourcemapFilename: item.sourcemapFileName || void 0,
3766
3530
  preliminaryFilename: item.preliminaryFileName
3767
3531
  });
@@ -3781,7 +3545,7 @@ function bindingifyRenderStart(args$1) {
3781
3545
  const { handler, meta } = normalizeHook(hook);
3782
3546
  return {
3783
3547
  plugin: async (ctx, opts) => {
3784
- 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));
3548
+ 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));
3785
3549
  },
3786
3550
  meta: bindingifyPluginHookMeta(meta)
3787
3551
  };
@@ -3793,13 +3557,13 @@ function bindingifyRenderChunk(args$1) {
3793
3557
  return {
3794
3558
  plugin: async (ctx, code$1, chunk, opts, meta$1) => {
3795
3559
  if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
3796
- 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());
3560
+ 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());
3797
3561
  if (ret == null) return;
3798
3562
  if (typeof ret === "string") return { code: ret };
3799
3563
  if (!ret.map) return { code: ret.code };
3800
3564
  return {
3801
3565
  code: ret.code,
3802
- map: bindingifySourcemap(ret.map)
3566
+ map: bindingifySourcemap$1(ret.map)
3803
3567
  };
3804
3568
  },
3805
3569
  meta: bindingifyPluginHookMeta(meta),
@@ -3840,7 +3604,7 @@ function bindingifyGenerateBundle(args$1) {
3840
3604
  };
3841
3605
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3842
3606
  const output = transformToOutputBundle(context, bundle, changed);
3843
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output, isWrite);
3607
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
3844
3608
  return collectChangedBundle(changed, output);
3845
3609
  },
3846
3610
  meta: bindingifyPluginHookMeta(meta)
@@ -3858,7 +3622,7 @@ function bindingifyWriteBundle(args$1) {
3858
3622
  };
3859
3623
  const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
3860
3624
  const output = transformToOutputBundle(context, bundle, changed);
3861
- await handler.call(context, new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output);
3625
+ await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
3862
3626
  return collectChangedBundle(changed, output);
3863
3627
  },
3864
3628
  meta: bindingifyPluginHookMeta(meta)
@@ -4133,31 +3897,292 @@ function wrapHandlers(plugin) {
4133
3897
  }
4134
3898
 
4135
3899
  //#endregion
4136
- //#region src/plugin/plugin-context-data.ts
4137
- var PluginContextData = class {
4138
- moduleOptionMap = /* @__PURE__ */ new Map();
4139
- resolveOptionsMap = /* @__PURE__ */ new Map();
4140
- loadModulePromiseMap = /* @__PURE__ */ new Map();
4141
- loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
4142
- renderedChunkMeta = null;
4143
- updateModuleOption(id$1, option) {
4144
- const existing = this.moduleOptionMap.get(id$1);
4145
- if (existing) {
4146
- if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
4147
- if (option.meta != null) Object.assign(existing.meta, option.meta);
4148
- if (option.invalidate != null) existing.invalidate = option.invalidate;
4149
- } else {
4150
- this.moduleOptionMap.set(id$1, option);
4151
- return option;
4152
- }
4153
- return existing;
3900
+ //#region src/options/normalized-input-options.ts
3901
+ var NormalizedInputOptionsImpl = class {
3902
+ inner;
3903
+ constructor(inner, onLog) {
3904
+ this.onLog = onLog;
3905
+ this.inner = inner;
4154
3906
  }
4155
- getModuleOption(id$1) {
4156
- const option = this.moduleOptionMap.get(id$1);
4157
- if (!option) {
4158
- const raw = {
4159
- moduleSideEffects: null,
4160
- meta: {}
3907
+ get shimMissingExports() {
3908
+ return this.inner.shimMissingExports;
3909
+ }
3910
+ get input() {
3911
+ return this.inner.input;
3912
+ }
3913
+ get cwd() {
3914
+ return this.inner.cwd ?? void 0;
3915
+ }
3916
+ get platform() {
3917
+ return this.inner.platform;
3918
+ }
3919
+ };
3920
+
3921
+ //#endregion
3922
+ //#region src/types/chunking-context.ts
3923
+ var ChunkingContextImpl = class {
3924
+ constructor(context) {
3925
+ this.context = context;
3926
+ }
3927
+ getModuleInfo(moduleId) {
3928
+ const bindingInfo = this.context.getModuleInfo(moduleId);
3929
+ if (bindingInfo) {
3930
+ const info = transformModuleInfo(bindingInfo, {
3931
+ moduleSideEffects: null,
3932
+ meta: {}
3933
+ });
3934
+ return info;
3935
+ }
3936
+ return null;
3937
+ }
3938
+ };
3939
+
3940
+ //#endregion
3941
+ //#region src/utils/bindingify-output-options.ts
3942
+ function bindingifyOutputOptions(outputOptions) {
3943
+ const { dir, format: format$1, exports, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks } = outputOptions;
3944
+ const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
3945
+ return {
3946
+ dir,
3947
+ file: file == null ? void 0 : file,
3948
+ format: bindingifyFormat(format$1),
3949
+ exports,
3950
+ hashCharacters,
3951
+ sourcemap: bindingifySourcemap(sourcemap),
3952
+ sourcemapDebugIds,
3953
+ sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
3954
+ sourcemapPathTransform,
3955
+ banner: bindingifyAddon(banner),
3956
+ footer: bindingifyAddon(footer),
3957
+ intro: bindingifyAddon(intro),
3958
+ outro: bindingifyAddon(outro),
3959
+ extend: outputOptions.extend,
3960
+ globals,
3961
+ esModule,
3962
+ name,
3963
+ assetFileNames: bindingifyAssetFilenames(assetFileNames),
3964
+ entryFileNames,
3965
+ chunkFileNames,
3966
+ cssEntryFileNames,
3967
+ cssChunkFileNames,
3968
+ plugins: [],
3969
+ minify: outputOptions.minify,
3970
+ externalLiveBindings: outputOptions.externalLiveBindings,
3971
+ inlineDynamicImports: outputOptions.inlineDynamicImports,
3972
+ advancedChunks,
3973
+ polyfillRequire: outputOptions.polyfillRequire,
3974
+ sanitizeFileName,
3975
+ preserveModules,
3976
+ virtualDirname,
3977
+ legalComments,
3978
+ preserveModulesRoot
3979
+ };
3980
+ }
3981
+ function bindingifyAddon(configAddon) {
3982
+ return async (chunk) => {
3983
+ if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
3984
+ return configAddon || "";
3985
+ };
3986
+ }
3987
+ function bindingifyFormat(format$1) {
3988
+ switch (format$1) {
3989
+ case void 0:
3990
+ case "es":
3991
+ case "esm":
3992
+ case "module": return "es";
3993
+ case "cjs":
3994
+ case "commonjs": return "cjs";
3995
+ case "iife": return "iife";
3996
+ case "umd": return "umd";
3997
+ default: unimplemented(`output.format: ${format$1}`);
3998
+ }
3999
+ }
4000
+ function bindingifySourcemap(sourcemap) {
4001
+ switch (sourcemap) {
4002
+ case true: return "file";
4003
+ case "inline": return "inline";
4004
+ case false:
4005
+ case void 0: return void 0;
4006
+ case "hidden": return "hidden";
4007
+ default: throw new Error(`unknown sourcemap: ${sourcemap}`);
4008
+ }
4009
+ }
4010
+ function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
4011
+ return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
4012
+ }
4013
+ function bindingifyAssetFilenames(assetFileNames) {
4014
+ if (typeof assetFileNames === "function") return (asset) => {
4015
+ return assetFileNames({
4016
+ names: asset.names,
4017
+ originalFileNames: asset.originalFileNames,
4018
+ source: transformAssetSource(asset.source),
4019
+ type: "asset"
4020
+ });
4021
+ };
4022
+ return assetFileNames;
4023
+ }
4024
+ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
4025
+ if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
4026
+ else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
4027
+ return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
4028
+ } }] };
4029
+ if (advancedChunks == null) return void 0;
4030
+ const { groups,...restAdvancedChunks } = advancedChunks;
4031
+ return {
4032
+ ...restAdvancedChunks,
4033
+ groups: groups?.map((group) => {
4034
+ const { name,...restGroup } = group;
4035
+ return {
4036
+ ...restGroup,
4037
+ name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContextImpl(ctx)) : name
4038
+ };
4039
+ })
4040
+ };
4041
+ }
4042
+
4043
+ //#endregion
4044
+ //#region src/options/normalized-output-options.ts
4045
+ var NormalizedOutputOptionsImpl = class {
4046
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
4047
+ this.inner = inner;
4048
+ this.outputOptions = outputOptions;
4049
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
4050
+ }
4051
+ get dir() {
4052
+ return this.inner.dir ?? void 0;
4053
+ }
4054
+ get entryFileNames() {
4055
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
4056
+ }
4057
+ get chunkFileNames() {
4058
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
4059
+ }
4060
+ get assetFileNames() {
4061
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
4062
+ }
4063
+ get format() {
4064
+ return this.inner.format;
4065
+ }
4066
+ get exports() {
4067
+ return this.inner.exports;
4068
+ }
4069
+ get sourcemap() {
4070
+ return this.inner.sourcemap;
4071
+ }
4072
+ get cssEntryFileNames() {
4073
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
4074
+ }
4075
+ get cssChunkFileNames() {
4076
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
4077
+ }
4078
+ get shimMissingExports() {
4079
+ return this.inner.shimMissingExports;
4080
+ }
4081
+ get name() {
4082
+ return this.inner.name ?? void 0;
4083
+ }
4084
+ get file() {
4085
+ return this.inner.file ?? void 0;
4086
+ }
4087
+ get inlineDynamicImports() {
4088
+ return this.inner.inlineDynamicImports;
4089
+ }
4090
+ get externalLiveBindings() {
4091
+ return this.inner.externalLiveBindings;
4092
+ }
4093
+ get banner() {
4094
+ return normalizeAddon(this.outputOptions.banner);
4095
+ }
4096
+ get footer() {
4097
+ return normalizeAddon(this.outputOptions.footer);
4098
+ }
4099
+ get intro() {
4100
+ return normalizeAddon(this.outputOptions.intro);
4101
+ }
4102
+ get outro() {
4103
+ return normalizeAddon(this.outputOptions.outro);
4104
+ }
4105
+ get esModule() {
4106
+ return this.inner.esModule;
4107
+ }
4108
+ get extend() {
4109
+ return this.inner.extend;
4110
+ }
4111
+ get globals() {
4112
+ return this.inner.globals || this.outputOptions.globals;
4113
+ }
4114
+ get hashCharacters() {
4115
+ return this.inner.hashCharacters;
4116
+ }
4117
+ get sourcemapDebugIds() {
4118
+ return this.inner.sourcemapDebugIds;
4119
+ }
4120
+ get sourcemapIgnoreList() {
4121
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
4122
+ }
4123
+ get sourcemapPathTransform() {
4124
+ return this.outputOptions.sourcemapPathTransform;
4125
+ }
4126
+ get minify() {
4127
+ return this.inner.minify;
4128
+ }
4129
+ get legalComments() {
4130
+ return this.inner.legalComments;
4131
+ }
4132
+ get polyfillRequire() {
4133
+ return this.inner.polyfillRequire;
4134
+ }
4135
+ get plugins() {
4136
+ return this.normalizedOutputPlugins;
4137
+ }
4138
+ get preserveModules() {
4139
+ return this.inner.preserveModules;
4140
+ }
4141
+ get preserveModulesRoot() {
4142
+ return this.inner.preserveModulesRoot;
4143
+ }
4144
+ get virtualDirname() {
4145
+ return this.inner.virtualDirname;
4146
+ }
4147
+ };
4148
+ function normalizeAddon(value) {
4149
+ if (typeof value === "function") return value;
4150
+ return () => value || "";
4151
+ }
4152
+
4153
+ //#endregion
4154
+ //#region src/plugin/plugin-context-data.ts
4155
+ var PluginContextData = class {
4156
+ moduleOptionMap = /* @__PURE__ */ new Map();
4157
+ resolveOptionsMap = /* @__PURE__ */ new Map();
4158
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
4159
+ loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
4160
+ renderedChunkMeta = null;
4161
+ normalizedInputOptions = null;
4162
+ normalizedOutputOptions = null;
4163
+ constructor(onLog, outputOptions, normalizedOutputPlugins) {
4164
+ this.onLog = onLog;
4165
+ this.outputOptions = outputOptions;
4166
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
4167
+ }
4168
+ updateModuleOption(id$1, option) {
4169
+ const existing = this.moduleOptionMap.get(id$1);
4170
+ if (existing) {
4171
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
4172
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
4173
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
4174
+ } else {
4175
+ this.moduleOptionMap.set(id$1, option);
4176
+ return option;
4177
+ }
4178
+ return existing;
4179
+ }
4180
+ getModuleOption(id$1) {
4181
+ const option = this.moduleOptionMap.get(id$1);
4182
+ if (!option) {
4183
+ const raw = {
4184
+ moduleSideEffects: null,
4185
+ meta: {}
4161
4186
  };
4162
4187
  this.moduleOptionMap.set(id$1, raw);
4163
4188
  return raw;
@@ -4210,6 +4235,14 @@ var PluginContextData = class {
4210
4235
  getRenderChunkMeta() {
4211
4236
  return this.renderedChunkMeta;
4212
4237
  }
4238
+ getInputOptions(opts) {
4239
+ this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
4240
+ return this.normalizedInputOptions;
4241
+ }
4242
+ getOutputOptions(opts) {
4243
+ this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
4244
+ return this.normalizedOutputOptions;
4245
+ }
4213
4246
  markModuleLoaded(id$1, _success) {
4214
4247
  const resolve$1 = this.loadModulePromiseResolveFnMap.get(id$1);
4215
4248
  if (resolve$1) resolve$1();
@@ -4235,7 +4268,7 @@ function isReadonlyArray(input) {
4235
4268
  //#endregion
4236
4269
  //#region src/utils/bindingify-input-options.ts
4237
4270
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
4238
- const pluginContextData = new PluginContextData();
4271
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
4239
4272
  const plugins = rawPlugins.map((plugin) => {
4240
4273
  if ("_parallel" in plugin) return void 0;
4241
4274
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
@@ -4410,7 +4443,8 @@ function bindingifyTreeshakeOptions(config) {
4410
4443
  moduleSideEffects: true,
4411
4444
  annotations: config.annotations,
4412
4445
  manualPureFunctions: config.manualPureFunctions,
4413
- unknownGlobalSideEffects: config.unknownGlobalSideEffects
4446
+ unknownGlobalSideEffects: config.unknownGlobalSideEffects,
4447
+ commonjs: config.commonjs
4414
4448
  };
4415
4449
  if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
4416
4450
  else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
@@ -4442,323 +4476,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4442
4476
  };
4443
4477
  }
4444
4478
 
4445
- //#endregion
4446
- //#region src/utils/plugin/index.ts
4447
- const isPluginHookName = function() {
4448
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4449
- return function isPluginHookName$1(hookName) {
4450
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
4451
- };
4452
- }();
4453
-
4454
- //#endregion
4455
- //#region src/utils/compose-js-plugins.ts
4456
- const unsupportedHookName = [
4457
- "augmentChunkHash",
4458
- "generateBundle",
4459
- "moduleParsed",
4460
- "onLog",
4461
- "options",
4462
- "outputOptions",
4463
- "renderError",
4464
- "renderStart",
4465
- "resolveDynamicImport",
4466
- "writeBundle"
4467
- ];
4468
- const unsupportedHooks = new Set(unsupportedHookName);
4469
- function isUnsupportedHooks(hookName) {
4470
- return unsupportedHooks.has(hookName);
4471
- }
4472
- function createComposedPlugin(plugins) {
4473
- const names = [];
4474
- const batchedHooks = {};
4475
- plugins.forEach((plugin, index) => {
4476
- const pluginName = plugin.name || `Anonymous(index: ${index})`;
4477
- names.push(pluginName);
4478
- t(plugin).forEach((pluginProp) => {
4479
- if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
4480
- if (!isPluginHookName(pluginProp)) return;
4481
- switch (pluginProp) {
4482
- case "buildStart": {
4483
- const handlers = batchedHooks.buildStart ?? [];
4484
- batchedHooks.buildStart = handlers;
4485
- if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
4486
- break;
4487
- }
4488
- case "load": {
4489
- const handlers = batchedHooks.load ?? [];
4490
- batchedHooks.load = handlers;
4491
- if (plugin.load) handlers.push([plugin.load, plugin]);
4492
- break;
4493
- }
4494
- case "transform": {
4495
- const handlers = batchedHooks.transform ?? [];
4496
- batchedHooks.transform = handlers;
4497
- if (plugin.transform) handlers.push([plugin.transform, plugin]);
4498
- break;
4499
- }
4500
- case "resolveId": {
4501
- const handlers = batchedHooks.resolveId ?? [];
4502
- batchedHooks.resolveId = handlers;
4503
- if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
4504
- break;
4505
- }
4506
- case "buildEnd": {
4507
- const handlers = batchedHooks.buildEnd ?? [];
4508
- batchedHooks.buildEnd = handlers;
4509
- if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
4510
- break;
4511
- }
4512
- case "renderChunk": {
4513
- const handlers = batchedHooks.renderChunk ?? [];
4514
- batchedHooks.renderChunk = handlers;
4515
- if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
4516
- break;
4517
- }
4518
- case "banner":
4519
- case "footer":
4520
- case "intro":
4521
- case "outro": {
4522
- const hook = plugin[pluginProp];
4523
- if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
4524
- break;
4525
- }
4526
- case "closeBundle": {
4527
- const handlers = batchedHooks.closeBundle ?? [];
4528
- batchedHooks.closeBundle = handlers;
4529
- if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
4530
- break;
4531
- }
4532
- case "watchChange": {
4533
- const handlers = batchedHooks.watchChange ?? [];
4534
- batchedHooks.watchChange = handlers;
4535
- if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
4536
- break;
4537
- }
4538
- case "closeWatcher": {
4539
- const handlers = batchedHooks.closeWatcher ?? [];
4540
- batchedHooks.closeWatcher = handlers;
4541
- if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
4542
- break;
4543
- }
4544
- default: {}
4545
- }
4546
- });
4547
- });
4548
- const composed = { name: `Composed(${names.join(", ")})` };
4549
- const createFixedPluginResolveFnMap = /* @__PURE__ */ new Map();
4550
- function applyFixedPluginResolveFn(ctx, plugin) {
4551
- const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
4552
- if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
4553
- return ctx;
4554
- }
4555
- if (batchedHooks.resolveId) {
4556
- const batchedHandlers = batchedHooks.resolveId;
4557
- const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
4558
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4559
- const [_handler, plugin] = batchedHandlers[handlerIdx];
4560
- const handlerSymbol = handlerSymbols[handlerIdx];
4561
- const createFixedPluginResolveFn = (ctx, resolve$1) => {
4562
- return (source, importer, rawContextResolveOptions) => {
4563
- const contextResolveOptions = rawContextResolveOptions ?? {};
4564
- if (contextResolveOptions.skipSelf) {
4565
- contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
4566
- contextResolveOptions.skipSelf = false;
4567
- }
4568
- return resolve$1(source, importer, contextResolveOptions);
4569
- };
4570
- };
4571
- createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
4572
- }
4573
- composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
4574
- const hookResolveIdOptions = rawHookResolveIdOptions;
4575
- const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
4576
- for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
4577
- const [handler, plugin] = batchedHandlers[handlerIdx];
4578
- const handlerSymbol = handlerSymbols[handlerIdx];
4579
- if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
4580
- const { handler: handlerFn } = normalizeHook(handler);
4581
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
4582
- if (!isNullish(result)) return result;
4583
- }
4584
- };
4585
- }
4586
- t(batchedHooks).forEach((hookName) => {
4587
- switch (hookName) {
4588
- case "resolveId": break;
4589
- case "buildStart": {
4590
- if (batchedHooks.buildStart) {
4591
- const batchedHandlers = batchedHooks.buildStart;
4592
- composed.buildStart = async function(options) {
4593
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4594
- const { handler: handlerFn } = normalizeHook(handler);
4595
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
4596
- }));
4597
- };
4598
- }
4599
- break;
4600
- }
4601
- case "load": {
4602
- if (batchedHooks.load) {
4603
- const batchedHandlers = batchedHooks.load;
4604
- composed.load = async function(id$1) {
4605
- for (const [handler, plugin] of batchedHandlers) {
4606
- const { handler: handlerFn } = normalizeHook(handler);
4607
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
4608
- if (!isNullish(result)) return result;
4609
- }
4610
- };
4611
- }
4612
- break;
4613
- }
4614
- case "transform": {
4615
- if (batchedHooks.transform) {
4616
- const batchedHandlers = batchedHooks.transform;
4617
- composed.transform = async function(initialCode, id$1, moduleType$1) {
4618
- let code$1 = initialCode;
4619
- let moduleSideEffects = void 0;
4620
- function updateOutput(newCode, newModuleSideEffects) {
4621
- code$1 = newCode;
4622
- moduleSideEffects = newModuleSideEffects ?? void 0;
4623
- }
4624
- for (const [handler, plugin] of batchedHandlers) {
4625
- const { handler: handlerFn } = normalizeHook(handler);
4626
- this.getCombinedSourcemap = () => {
4627
- throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
4628
- };
4629
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
4630
- if (!isNullish(result)) {
4631
- if (typeof result === "string") updateOutput(result);
4632
- else if (result.code) updateOutput(result.code, result.moduleSideEffects);
4633
- }
4634
- }
4635
- return {
4636
- code: code$1,
4637
- moduleSideEffects
4638
- };
4639
- };
4640
- }
4641
- break;
4642
- }
4643
- case "buildEnd": {
4644
- if (batchedHooks.buildEnd) {
4645
- const batchedHandlers = batchedHooks.buildEnd;
4646
- composed.buildEnd = async function(err) {
4647
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4648
- const { handler: handlerFn } = normalizeHook(handler);
4649
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
4650
- }));
4651
- };
4652
- }
4653
- break;
4654
- }
4655
- case "renderChunk": {
4656
- if (batchedHooks.renderChunk) {
4657
- const batchedHandlers = batchedHooks.renderChunk;
4658
- composed.renderChunk = async function(code$1, chunk, options, meta) {
4659
- for (const [handler, plugin] of batchedHandlers) {
4660
- const { handler: handlerFn } = normalizeHook(handler);
4661
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
4662
- if (!isNullish(result)) return result;
4663
- }
4664
- };
4665
- }
4666
- break;
4667
- }
4668
- case "banner":
4669
- case "footer":
4670
- case "intro":
4671
- case "outro": {
4672
- const hooks = batchedHooks[hookName];
4673
- if (hooks?.length) composed[hookName] = async function(chunk) {
4674
- const ret = [];
4675
- for (const [hook, plugin] of hooks) {
4676
- const { handler } = normalizeHook(hook);
4677
- ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
4678
- }
4679
- return ret.join("\n");
4680
- };
4681
- break;
4682
- }
4683
- case "closeBundle": {
4684
- if (batchedHooks.closeBundle) {
4685
- const batchedHandlers = batchedHooks.closeBundle;
4686
- composed.closeBundle = async function() {
4687
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4688
- const { handler: handlerFn } = normalizeHook(handler);
4689
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4690
- }));
4691
- };
4692
- }
4693
- break;
4694
- }
4695
- case "watchChange": {
4696
- if (batchedHooks.watchChange) {
4697
- const batchedHandlers = batchedHooks.watchChange;
4698
- composed.watchChange = async function(id$1, event) {
4699
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4700
- const { handler: handlerFn } = normalizeHook(handler);
4701
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
4702
- }));
4703
- };
4704
- }
4705
- break;
4706
- }
4707
- case "closeWatcher": {
4708
- if (batchedHooks.closeWatcher) {
4709
- const batchedHandlers = batchedHooks.closeWatcher;
4710
- composed.closeWatcher = async function() {
4711
- await Promise.all(batchedHandlers.map(([handler, plugin]) => {
4712
- const { handler: handlerFn } = normalizeHook(handler);
4713
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
4714
- }));
4715
- };
4716
- }
4717
- break;
4718
- }
4719
- default: {}
4720
- }
4721
- });
4722
- return composed;
4723
- }
4724
- function isComposablePlugin(plugin) {
4725
- if (plugin instanceof BuiltinPlugin) return false;
4726
- if ("_parallel" in plugin) return false;
4727
- const hasNotComposablePattern = t(plugin).some((hookName) => {
4728
- if (!isPluginHookName(hookName)) return false;
4729
- const OK_TO_COMPOSE = false;
4730
- if (isUnsupportedHooks(hookName)) return true;
4731
- if (plugin[hookName]) {
4732
- const { meta } = normalizeHook(plugin[hookName]);
4733
- if (meta.order === "pre" || meta.order === "post") return true;
4734
- }
4735
- return OK_TO_COMPOSE;
4736
- });
4737
- if (hasNotComposablePattern) return false;
4738
- return true;
4739
- }
4740
- function composeJsPlugins(plugins) {
4741
- const newPlugins = [];
4742
- const toBeComposed = [];
4743
- plugins.forEach((plugin) => {
4744
- if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
4745
- else {
4746
- if (toBeComposed.length > 0) {
4747
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4748
- else newPlugins.push(toBeComposed[0]);
4749
- toBeComposed.length = 0;
4750
- }
4751
- newPlugins.push(plugin);
4752
- }
4753
- });
4754
- if (toBeComposed.length > 0) {
4755
- if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
4756
- else newPlugins.push(toBeComposed[0]);
4757
- toBeComposed.length = 0;
4758
- }
4759
- return newPlugins;
4760
- }
4761
-
4762
4479
  //#endregion
4763
4480
  //#region src/utils/create-bundler-option.ts
4764
4481
  async function createBundlerOptions(inputOptions, outputOptions, watchMode, isClose) {
@@ -4773,7 +4490,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4773
4490
  ...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
4774
4491
  ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
4775
4492
  ];
4776
- if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
4777
4493
  const parallelPluginInitResult = void 0;
4778
4494
  try {
4779
4495
  const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
@@ -5043,4 +4759,4 @@ function defineConfig(config) {
5043
4759
  const VERSION = version;
5044
4760
 
5045
4761
  //#endregion
5046
- export { BuiltinPlugin, PluginDriver, VERSION, assetPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundlerImpl, defineConfig, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };
4762
+ export { BuiltinPlugin, PluginDriver, VERSION, assetPlugin, build, buildImportAnalysisPlugin, createBundlerImpl, defineConfig, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };