@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.
- package/dist/cli.cjs +3 -3
- package/dist/cli.mjs +3 -3
- package/dist/config.cjs +3 -3
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +3 -3
- package/dist/experimental-index.browser.mjs +2 -2
- package/dist/experimental-index.cjs +2 -3
- package/dist/experimental-index.d.cts +3 -6
- package/dist/experimental-index.d.mts +3 -6
- package/dist/experimental-index.mjs +3 -3
- package/dist/filter-index.cjs +1 -1
- package/dist/filter-index.d.cts +2 -2
- package/dist/filter-index.d.mts +2 -2
- package/dist/filter-index.mjs +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/parallel-plugin-worker.cjs +3 -3
- package/dist/parallel-plugin-worker.mjs +3 -3
- package/dist/parallel-plugin.d.cts +2 -2
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.cts +1 -1
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/rolldown-binding.wasi-browser.js +1 -0
- package/dist/rolldown-binding.wasi.cjs +1 -0
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/{binding--Ro_HG7S.d.mts → binding-CMKStSph.d.cts} +5 -1
- package/dist/shared/{binding-DBnJxycu.d.cts → binding-DB58iXP8.d.mts} +5 -1
- package/dist/shared/{define-config-3jyxkSn6.d.mts → define-config-BRkYSF9E.d.cts} +30 -30
- package/dist/shared/{define-config-LuFmoc43.d.cts → define-config-CqVfqfZQ.d.mts} +30 -30
- package/dist/shared/{dist-BMVjvV-v.cjs → dist-BVAp8sOm.cjs} +0 -9
- package/dist/shared/{dist-BoWaIc-K.mjs → dist-DvBwroyk.mjs} +1 -4
- package/dist/shared/{load-config-DnUMpIsk.mjs → load-config-BWbXOTbl.mjs} +1 -1
- package/dist/shared/{load-config--g9e2MRO.cjs → load-config-Bh2dNRk9.cjs} +1 -1
- package/dist/shared/{src-DLhNmBff.mjs → src-BA5CL--T.mjs} +354 -635
- package/dist/shared/{src-B3ZW8_Y7.cjs → src-Co_Bf7DL.cjs} +353 -640
- package/dist/{src-jKfrtJ37.js → src-C1KTaRyZ.js} +383 -667
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { and, arraify, code, exclude, id, include,
|
|
1
|
+
import { and, arraify, code, exclude, id, include, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-DvBwroyk.mjs";
|
|
2
2
|
import { augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-BzdtcWzA.mjs";
|
|
3
3
|
import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, shutdownAsyncRuntime, startAsyncRuntime } from "../rolldown-binding.wasi.cjs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -33,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region package.json
|
|
36
|
-
var version = "1.0.0-beta.
|
|
36
|
+
var version = "1.0.0-beta.23";
|
|
37
37
|
var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
@@ -76,8 +76,8 @@ function reporterPlugin(config) {
|
|
|
76
76
|
function manifestPlugin(config) {
|
|
77
77
|
return new BuiltinPlugin("builtin:manifest", config);
|
|
78
78
|
}
|
|
79
|
-
function wasmHelperPlugin() {
|
|
80
|
-
return new BuiltinPlugin("builtin:wasm-helper");
|
|
79
|
+
function wasmHelperPlugin(config) {
|
|
80
|
+
return new BuiltinPlugin("builtin:wasm-helper", config);
|
|
81
81
|
}
|
|
82
82
|
function wasmFallbackPlugin() {
|
|
83
83
|
const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
|
|
@@ -1873,18 +1873,18 @@ function toJsonSchema(schema, config) {
|
|
|
1873
1873
|
//#endregion
|
|
1874
1874
|
//#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
|
|
1875
1875
|
var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs"(exports, module) {
|
|
1876
|
-
let e, t
|
|
1877
|
-
let t$
|
|
1876
|
+
let e, t, r, { defineProperty: n, setPrototypeOf: l, create: o, keys: s } = Object, i$1 = "", { round: c, max: a$1 } = Math, p = (e$1) => {
|
|
1877
|
+
let t$1 = /([a-f\d]{3,6})/i.exec(e$1)?.[1], r$1 = t$1?.length, n$1 = parseInt(6 ^ r$1 ? 3 ^ r$1 ? "0" : t$1[0] + t$1[0] + t$1[1] + t$1[1] + t$1[2] + t$1[2] : t$1, 16);
|
|
1878
1878
|
return [
|
|
1879
1879
|
n$1 >> 16 & 255,
|
|
1880
1880
|
n$1 >> 8 & 255,
|
|
1881
1881
|
255 & n$1
|
|
1882
1882
|
];
|
|
1883
|
-
}, u$2 = (e$1, t$
|
|
1884
|
-
let t$
|
|
1885
|
-
return 8 > e$1 ? 30 + e$1 : 16 > e$1 ? e$1 - 8 + 90 : (232 > e$1 ? (o$1 = (e$1 -= 16) % 36, t$
|
|
1883
|
+
}, 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) => {
|
|
1884
|
+
let t$1, r$1, n$1, l$1, o$1;
|
|
1885
|
+
return 8 > e$1 ? 30 + e$1 : 16 > e$1 ? e$1 - 8 + 90 : (232 > e$1 ? (o$1 = (e$1 -= 16) % 36, t$1 = (e$1 / 36 | 0) / 5, r$1 = (o$1 / 6 | 0) / 5, n$1 = o$1 % 6 / 5) : t$1 = r$1 = n$1 = (10 * (e$1 - 232) + 8) / 255, l$1 = 2 * a$1(t$1, r$1, n$1), l$1 ? 30 + (c(n$1) << 2 | c(r$1) << 1 | c(t$1)) + (2 ^ l$1 ? 0 : 60) : 30);
|
|
1886
1886
|
}, g = (() => {
|
|
1887
|
-
let r$1 = (e$1) => o$1.some((t$
|
|
1887
|
+
let r$1 = (e$1) => o$1.some((t$1) => e$1.test(t$1)), n$1 = globalThis, l$1 = n$1.process ?? {}, o$1 = l$1.argv ?? [], i$2 = l$1.env ?? {}, c$1 = -1;
|
|
1888
1888
|
try {
|
|
1889
1889
|
e = "," + s(i$2).join(",");
|
|
1890
1890
|
} catch (e$1) {
|
|
@@ -1897,31 +1897,31 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
|
|
|
1897
1897
|
2: 2,
|
|
1898
1898
|
3: 3
|
|
1899
1899
|
}[i$2[a$2]] ?? -1, u$3 = a$2 in i$2 && p$1 || r$1(/^--color=?(true|always)?$/);
|
|
1900
|
-
return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t
|
|
1900
|
+
return u$3 && (c$1 = p$1), ~c$1 || (c$1 = ((r$2, n$2, l$2) => (t = r$2.TERM, {
|
|
1901
1901
|
"24bit": 3,
|
|
1902
1902
|
truecolor: 3,
|
|
1903
1903
|
ansi256: 2,
|
|
1904
1904
|
ansi: 1
|
|
1905
|
-
}[r$2.COLORTERM] || (r$2.CI ? /,GITHUB/.test(e) ? 3 : 1 : n$2 && "dumb" !== t
|
|
1905
|
+
}[r$2.COLORTERM] || (r$2.CI ? /,GITHUB/.test(e) ? 3 : 1 : n$2 && "dumb" !== t ? l$2 ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i$2, !!i$2.PM2_HOME || i$2.NEXT_RUNTIME?.includes("edge") || !!l$1.stdout?.isTTY, "win32" === l$1.platform)), !p$1 || i$2.NO_COLOR || r$1(/^--(no-color|color=(false|never))$/) ? 0 : n$1.window?.chrome || u$3 && !c$1 ? 3 : c$1;
|
|
1906
1906
|
})(), f = {
|
|
1907
1907
|
open: i$1,
|
|
1908
1908
|
close: i$1
|
|
1909
|
-
}, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$
|
|
1909
|
+
}, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t$1, close: n$1 }) => {
|
|
1910
1910
|
let o$1 = (e$2, ...r$1) => {
|
|
1911
1911
|
if (!e$2) {
|
|
1912
|
-
if (t$
|
|
1912
|
+
if (t$1 && t$1 === n$1) return t$1;
|
|
1913
1913
|
if ((e$2 ?? i$1) === i$1) return i$1;
|
|
1914
1914
|
}
|
|
1915
1915
|
let l$1, s$2 = e$2.raw ? String.raw({ raw: e$2 }, ...r$1) : i$1 + e$2, c$2 = o$1.p, a$2 = c$2.o, p$1 = c$2.c;
|
|
1916
1916
|
if (s$2.includes("\x1B")) for (; c$2; c$2 = c$2.p) {
|
|
1917
|
-
let { open: e$3, close: t$
|
|
1918
|
-
if (r$2) for (; ~(l$1 = s$2.indexOf(t$
|
|
1917
|
+
let { open: e$3, close: t$2 } = c$2, r$2 = t$2.length, n$2 = i$1, o$2 = 0;
|
|
1918
|
+
if (r$2) for (; ~(l$1 = s$2.indexOf(t$2, o$2)); o$2 = l$1 + r$2) n$2 += s$2.slice(o$2, l$1) + e$3;
|
|
1919
1919
|
s$2 = n$2 + s$2.slice(o$2);
|
|
1920
1920
|
}
|
|
1921
1921
|
return a$2 + (s$2.includes("\n") ? s$2.replace(/(\r?\n)/g, p$1 + "$1" + a$2) : s$2) + p$1;
|
|
1922
|
-
}, s$1 = t$
|
|
1923
|
-
return e$1 && (s$1 = e$1.o + t$
|
|
1924
|
-
open: t$
|
|
1922
|
+
}, s$1 = t$1, c$1 = n$1;
|
|
1923
|
+
return e$1 && (s$1 = e$1.o + t$1, c$1 = n$1 + e$1.c), l(o$1, r), o$1.p = {
|
|
1924
|
+
open: t$1,
|
|
1925
1925
|
close: n$1,
|
|
1926
1926
|
o: s$1,
|
|
1927
1927
|
c: c$1,
|
|
@@ -1929,27 +1929,27 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
|
|
|
1929
1929
|
}, o$1.open = s$1, o$1.close = c$1, o$1;
|
|
1930
1930
|
};
|
|
1931
1931
|
const w = function(e$1 = g) {
|
|
1932
|
-
let t$
|
|
1932
|
+
let t$1 = {
|
|
1933
1933
|
Ansis: w,
|
|
1934
1934
|
level: e$1,
|
|
1935
1935
|
isSupported: () => s$1,
|
|
1936
1936
|
strip: (e$2) => e$2.replace(/[][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i$1),
|
|
1937
1937
|
extend(e$2) {
|
|
1938
|
-
for (let t$
|
|
1939
|
-
let r$1 = e$2[t$
|
|
1940
|
-
O[t$
|
|
1938
|
+
for (let t$2 in e$2) {
|
|
1939
|
+
let r$1 = e$2[t$2], l$1 = (typeof r$1)[0], o$1 = "s" === l$1 ? x(...p(r$1)) : r$1;
|
|
1940
|
+
O[t$2] = "f" === l$1 ? { get() {
|
|
1941
1941
|
return (...e$3) => m(this, r$1(...e$3));
|
|
1942
1942
|
} } : { get() {
|
|
1943
1943
|
let e$3 = m(this, o$1);
|
|
1944
|
-
return n(this, t$
|
|
1944
|
+
return n(this, t$2, { value: e$3 }), e$3;
|
|
1945
1945
|
} };
|
|
1946
1946
|
}
|
|
1947
|
-
return r = o({}, O), l(t$
|
|
1947
|
+
return r = o({}, O), l(t$1, r), t$1;
|
|
1948
1948
|
}
|
|
1949
|
-
}, s$1 = e$1 > 0, c$1 = (e$2, t$
|
|
1949
|
+
}, s$1 = e$1 > 0, c$1 = (e$2, t$2) => s$1 ? {
|
|
1950
1950
|
open: `[${e$2}m`,
|
|
1951
|
-
close: `[${t$
|
|
1952
|
-
} : f, a$2 = (e$2) => (t$
|
|
1951
|
+
close: `[${t$2}m`
|
|
1952
|
+
} : f, a$2 = (e$2) => (t$2) => e$2(...p(t$2)), y$1 = (e$2, t$2) => (r$1, n$1, l$1) => c$1(`${e$2}8;2;${r$1};${n$1};${l$1}`, t$2), R = (e$2, t$2) => (r$1, n$1, l$1) => c$1(((e$3, t$3, r$2) => d$1(u$2(e$3, t$3, r$2)))(r$1, n$1, l$1) + e$2, t$2), $ = (e$2) => (t$2, r$1, n$1) => e$2(u$2(t$2, r$1, n$1)), x = y$1(3, h), T = y$1(4, b), v = (e$2) => c$1("38;5;" + e$2, h), C = (e$2) => c$1("48;5;" + e$2, b);
|
|
1953
1953
|
2 === e$1 ? (x = $(v), T = $(C)) : 1 === e$1 && (x = R(0, h), T = R(10, b), v = (e$2) => c$1(d$1(e$2), h), C = (e$2) => c$1(d$1(e$2) + 10, b));
|
|
1954
1954
|
let E, M = {
|
|
1955
1955
|
fg: v,
|
|
@@ -1968,9 +1968,9 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
|
|
|
1968
1968
|
hidden: c$1(8, 28),
|
|
1969
1969
|
strikethrough: c$1(9, 29)
|
|
1970
1970
|
}, I = "Bright";
|
|
1971
|
-
return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$
|
|
1972
|
-
E = "bg" + e$2[0].toUpperCase() + e$2.slice(1), 8 > t$
|
|
1973
|
-
}), t$
|
|
1971
|
+
return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map((e$2, t$2) => {
|
|
1972
|
+
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);
|
|
1973
|
+
}), t$1.extend(M);
|
|
1974
1974
|
}, y = new w();
|
|
1975
1975
|
module.exports = y, y.default = y;
|
|
1976
1976
|
} });
|
|
@@ -2124,7 +2124,8 @@ const ResolveOptionsSchema = strictObject({
|
|
|
2124
2124
|
const TreeshakingOptionsSchema = union([boolean(), looseObject({
|
|
2125
2125
|
annotations: optional(boolean()),
|
|
2126
2126
|
manualPureFunctions: optional(array(string())),
|
|
2127
|
-
unknownGlobalSideEffects: optional(boolean())
|
|
2127
|
+
unknownGlobalSideEffects: optional(boolean()),
|
|
2128
|
+
commonjs: optional(boolean())
|
|
2128
2129
|
})]);
|
|
2129
2130
|
const OnLogSchema = pipe(function_(), args(tuple([
|
|
2130
2131
|
LogLevelSchema,
|
|
@@ -2389,41 +2390,9 @@ function getJsonSchema() {
|
|
|
2389
2390
|
return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
|
|
2390
2391
|
}
|
|
2391
2392
|
|
|
2392
|
-
//#endregion
|
|
2393
|
-
//#region src/constants/plugin-context.ts
|
|
2394
|
-
/**
|
|
2395
|
-
* If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
|
|
2396
|
-
* To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
|
|
2397
|
-
* will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
|
|
2398
|
-
* internally.
|
|
2399
|
-
*/
|
|
2400
|
-
const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
|
|
2401
|
-
|
|
2402
|
-
//#endregion
|
|
2403
|
-
//#region src/options/normalized-input-options.ts
|
|
2404
|
-
var NormalizedInputOptionsImpl = class {
|
|
2405
|
-
inner;
|
|
2406
|
-
constructor(inner, onLog) {
|
|
2407
|
-
this.onLog = onLog;
|
|
2408
|
-
this.inner = inner;
|
|
2409
|
-
}
|
|
2410
|
-
get shimMissingExports() {
|
|
2411
|
-
return this.inner.shimMissingExports;
|
|
2412
|
-
}
|
|
2413
|
-
get input() {
|
|
2414
|
-
return this.inner.input;
|
|
2415
|
-
}
|
|
2416
|
-
get cwd() {
|
|
2417
|
-
return this.inner.cwd ?? void 0;
|
|
2418
|
-
}
|
|
2419
|
-
get platform() {
|
|
2420
|
-
return this.inner.platform;
|
|
2421
|
-
}
|
|
2422
|
-
};
|
|
2423
|
-
|
|
2424
2393
|
//#endregion
|
|
2425
2394
|
//#region src/types/sourcemap.ts
|
|
2426
|
-
function bindingifySourcemap(map) {
|
|
2395
|
+
function bindingifySourcemap$1(map) {
|
|
2427
2396
|
if (map == null) return;
|
|
2428
2397
|
return { inner: typeof map === "string" ? map : {
|
|
2429
2398
|
file: map.file ?? void 0,
|
|
@@ -2539,8 +2508,8 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
|
|
|
2539
2508
|
//#endregion
|
|
2540
2509
|
//#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
|
|
2541
2510
|
function u$1(o$1, n$1, a$2) {
|
|
2542
|
-
let t$
|
|
2543
|
-
return a$2 === void 0 ? t$
|
|
2511
|
+
let t$1 = (r$1) => o$1(r$1, ...n$1);
|
|
2512
|
+
return a$2 === void 0 ? t$1 : Object.assign(t$1, {
|
|
2544
2513
|
lazy: a$2,
|
|
2545
2514
|
lazyArgs: n$1
|
|
2546
2515
|
});
|
|
@@ -2560,18 +2529,12 @@ function u(r$1, n$1, o$1) {
|
|
|
2560
2529
|
function d(...r$1) {
|
|
2561
2530
|
return u(i, r$1);
|
|
2562
2531
|
}
|
|
2563
|
-
var i = (r$1, t$
|
|
2532
|
+
var i = (r$1, t$1) => {
|
|
2564
2533
|
let a$2 = [[], []];
|
|
2565
|
-
for (let [o$1, e$1] of r$1.entries()) t$
|
|
2534
|
+
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);
|
|
2566
2535
|
return a$2;
|
|
2567
2536
|
};
|
|
2568
2537
|
|
|
2569
|
-
//#endregion
|
|
2570
|
-
//#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
|
|
2571
|
-
function t(...n$1) {
|
|
2572
|
-
return u(Object.keys, n$1);
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
2538
|
//#endregion
|
|
2576
2539
|
//#region src/plugin/bindingify-hook-filter.ts
|
|
2577
2540
|
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
@@ -2783,9 +2746,14 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
|
2783
2746
|
async resolve(source, importer, options) {
|
|
2784
2747
|
let receipt = void 0;
|
|
2785
2748
|
if (options != null) receipt = this.data.saveResolveOptions(options);
|
|
2749
|
+
const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
|
|
2750
|
+
if (key.startsWith("vite:")) (acc ??= {})[key] = value;
|
|
2751
|
+
return acc;
|
|
2752
|
+
}, void 0);
|
|
2786
2753
|
const res = await this.context.resolve(source, importer, {
|
|
2787
2754
|
custom: receipt,
|
|
2788
|
-
skipSelf: options?.skipSelf
|
|
2755
|
+
skipSelf: options?.skipSelf,
|
|
2756
|
+
vitePluginCustom
|
|
2789
2757
|
});
|
|
2790
2758
|
if (receipt != null) this.data.removeSavedResolveOptions(receipt);
|
|
2791
2759
|
if (res == null) return null;
|
|
@@ -2871,7 +2839,7 @@ function bindingifyBuildStart(args$1) {
|
|
|
2871
2839
|
const { handler, meta } = normalizeHook(hook);
|
|
2872
2840
|
return {
|
|
2873
2841
|
plugin: async (ctx, opts) => {
|
|
2874
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode),
|
|
2842
|
+
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));
|
|
2875
2843
|
},
|
|
2876
2844
|
meta: bindingifyPluginHookMeta(meta)
|
|
2877
2845
|
};
|
|
@@ -2894,12 +2862,10 @@ function bindingifyResolveId(args$1) {
|
|
|
2894
2862
|
return {
|
|
2895
2863
|
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
2896
2864
|
const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
2897
|
-
const
|
|
2865
|
+
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, {
|
|
2898
2866
|
...extraOptions,
|
|
2899
|
-
custom: contextResolveOptions?.custom
|
|
2900
|
-
|
|
2901
|
-
};
|
|
2902
|
-
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);
|
|
2867
|
+
custom: contextResolveOptions?.custom
|
|
2868
|
+
});
|
|
2903
2869
|
if (ret == null) return;
|
|
2904
2870
|
if (ret === false) return {
|
|
2905
2871
|
id: specifier,
|
|
@@ -2970,7 +2936,7 @@ function bindingifyTransform(args$1) {
|
|
|
2970
2936
|
});
|
|
2971
2937
|
return {
|
|
2972
2938
|
code: ret.code,
|
|
2973
|
-
map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
|
|
2939
|
+
map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
|
|
2974
2940
|
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
|
|
2975
2941
|
moduleType: ret.moduleType
|
|
2976
2942
|
};
|
|
@@ -2996,7 +2962,7 @@ function bindingifyLoad(args$1) {
|
|
|
2996
2962
|
let map = preProcessSourceMap(ret, id$1);
|
|
2997
2963
|
return {
|
|
2998
2964
|
code: ret.code,
|
|
2999
|
-
map: bindingifySourcemap(map),
|
|
2965
|
+
map: bindingifySourcemap$1(map),
|
|
3000
2966
|
moduleType: ret.moduleType,
|
|
3001
2967
|
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
|
|
3002
2968
|
};
|
|
@@ -3092,205 +3058,6 @@ function transformChunkModules(modules) {
|
|
|
3092
3058
|
return result;
|
|
3093
3059
|
}
|
|
3094
3060
|
|
|
3095
|
-
//#endregion
|
|
3096
|
-
//#region src/utils/bindingify-output-options.ts
|
|
3097
|
-
function bindingifyOutputOptions(outputOptions) {
|
|
3098
|
-
const { dir, format, exports, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks } = outputOptions;
|
|
3099
|
-
let { advancedChunks } = outputOptions;
|
|
3100
|
-
if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
|
|
3101
|
-
else if (manualChunks != null) advancedChunks = { groups: [{ name(id$1) {
|
|
3102
|
-
return manualChunks(id$1, {});
|
|
3103
|
-
} }] };
|
|
3104
|
-
return {
|
|
3105
|
-
dir,
|
|
3106
|
-
file: file == null ? void 0 : file,
|
|
3107
|
-
format: bindingifyFormat(format),
|
|
3108
|
-
exports,
|
|
3109
|
-
hashCharacters,
|
|
3110
|
-
sourcemap: bindingifySourcemap$1(sourcemap),
|
|
3111
|
-
sourcemapDebugIds,
|
|
3112
|
-
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
3113
|
-
sourcemapPathTransform,
|
|
3114
|
-
banner: bindingifyAddon(banner),
|
|
3115
|
-
footer: bindingifyAddon(footer),
|
|
3116
|
-
intro: bindingifyAddon(intro),
|
|
3117
|
-
outro: bindingifyAddon(outro),
|
|
3118
|
-
extend: outputOptions.extend,
|
|
3119
|
-
globals,
|
|
3120
|
-
esModule,
|
|
3121
|
-
name,
|
|
3122
|
-
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
3123
|
-
entryFileNames,
|
|
3124
|
-
chunkFileNames,
|
|
3125
|
-
cssEntryFileNames,
|
|
3126
|
-
cssChunkFileNames,
|
|
3127
|
-
plugins: [],
|
|
3128
|
-
minify: outputOptions.minify,
|
|
3129
|
-
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
3130
|
-
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
3131
|
-
advancedChunks,
|
|
3132
|
-
polyfillRequire: outputOptions.polyfillRequire,
|
|
3133
|
-
sanitizeFileName,
|
|
3134
|
-
preserveModules,
|
|
3135
|
-
virtualDirname,
|
|
3136
|
-
legalComments,
|
|
3137
|
-
preserveModulesRoot
|
|
3138
|
-
};
|
|
3139
|
-
}
|
|
3140
|
-
function bindingifyAddon(configAddon) {
|
|
3141
|
-
return async (chunk) => {
|
|
3142
|
-
if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
|
|
3143
|
-
return configAddon || "";
|
|
3144
|
-
};
|
|
3145
|
-
}
|
|
3146
|
-
function bindingifyFormat(format) {
|
|
3147
|
-
switch (format) {
|
|
3148
|
-
case void 0:
|
|
3149
|
-
case "es":
|
|
3150
|
-
case "esm":
|
|
3151
|
-
case "module": return "es";
|
|
3152
|
-
case "cjs":
|
|
3153
|
-
case "commonjs": return "cjs";
|
|
3154
|
-
case "iife": return "iife";
|
|
3155
|
-
case "umd": return "umd";
|
|
3156
|
-
default: unimplemented(`output.format: ${format}`);
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
function bindingifySourcemap$1(sourcemap) {
|
|
3160
|
-
switch (sourcemap) {
|
|
3161
|
-
case true: return "file";
|
|
3162
|
-
case "inline": return "inline";
|
|
3163
|
-
case false:
|
|
3164
|
-
case void 0: return void 0;
|
|
3165
|
-
case "hidden": return "hidden";
|
|
3166
|
-
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
3167
|
-
}
|
|
3168
|
-
}
|
|
3169
|
-
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
3170
|
-
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
3171
|
-
}
|
|
3172
|
-
function bindingifyAssetFilenames(assetFileNames) {
|
|
3173
|
-
if (typeof assetFileNames === "function") return (asset) => {
|
|
3174
|
-
return assetFileNames({
|
|
3175
|
-
names: asset.names,
|
|
3176
|
-
originalFileNames: asset.originalFileNames,
|
|
3177
|
-
source: transformAssetSource(asset.source),
|
|
3178
|
-
type: "asset"
|
|
3179
|
-
});
|
|
3180
|
-
};
|
|
3181
|
-
return assetFileNames;
|
|
3182
|
-
}
|
|
3183
|
-
|
|
3184
|
-
//#endregion
|
|
3185
|
-
//#region src/options/normalized-output-options.ts
|
|
3186
|
-
var NormalizedOutputOptionsImpl = class {
|
|
3187
|
-
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
3188
|
-
this.inner = inner;
|
|
3189
|
-
this.outputOptions = outputOptions;
|
|
3190
|
-
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3191
|
-
}
|
|
3192
|
-
get dir() {
|
|
3193
|
-
return this.inner.dir ?? void 0;
|
|
3194
|
-
}
|
|
3195
|
-
get entryFileNames() {
|
|
3196
|
-
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
3197
|
-
}
|
|
3198
|
-
get chunkFileNames() {
|
|
3199
|
-
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3200
|
-
}
|
|
3201
|
-
get assetFileNames() {
|
|
3202
|
-
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
3203
|
-
}
|
|
3204
|
-
get format() {
|
|
3205
|
-
return this.inner.format;
|
|
3206
|
-
}
|
|
3207
|
-
get exports() {
|
|
3208
|
-
return this.inner.exports;
|
|
3209
|
-
}
|
|
3210
|
-
get sourcemap() {
|
|
3211
|
-
return this.inner.sourcemap;
|
|
3212
|
-
}
|
|
3213
|
-
get cssEntryFileNames() {
|
|
3214
|
-
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
3215
|
-
}
|
|
3216
|
-
get cssChunkFileNames() {
|
|
3217
|
-
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
3218
|
-
}
|
|
3219
|
-
get shimMissingExports() {
|
|
3220
|
-
return this.inner.shimMissingExports;
|
|
3221
|
-
}
|
|
3222
|
-
get name() {
|
|
3223
|
-
return this.inner.name ?? void 0;
|
|
3224
|
-
}
|
|
3225
|
-
get file() {
|
|
3226
|
-
return this.inner.file ?? void 0;
|
|
3227
|
-
}
|
|
3228
|
-
get inlineDynamicImports() {
|
|
3229
|
-
return this.inner.inlineDynamicImports;
|
|
3230
|
-
}
|
|
3231
|
-
get externalLiveBindings() {
|
|
3232
|
-
return this.inner.externalLiveBindings;
|
|
3233
|
-
}
|
|
3234
|
-
get banner() {
|
|
3235
|
-
return normalizeAddon(this.outputOptions.banner);
|
|
3236
|
-
}
|
|
3237
|
-
get footer() {
|
|
3238
|
-
return normalizeAddon(this.outputOptions.footer);
|
|
3239
|
-
}
|
|
3240
|
-
get intro() {
|
|
3241
|
-
return normalizeAddon(this.outputOptions.intro);
|
|
3242
|
-
}
|
|
3243
|
-
get outro() {
|
|
3244
|
-
return normalizeAddon(this.outputOptions.outro);
|
|
3245
|
-
}
|
|
3246
|
-
get esModule() {
|
|
3247
|
-
return this.inner.esModule;
|
|
3248
|
-
}
|
|
3249
|
-
get extend() {
|
|
3250
|
-
return this.inner.extend;
|
|
3251
|
-
}
|
|
3252
|
-
get globals() {
|
|
3253
|
-
return this.inner.globals || this.outputOptions.globals;
|
|
3254
|
-
}
|
|
3255
|
-
get hashCharacters() {
|
|
3256
|
-
return this.inner.hashCharacters;
|
|
3257
|
-
}
|
|
3258
|
-
get sourcemapDebugIds() {
|
|
3259
|
-
return this.inner.sourcemapDebugIds;
|
|
3260
|
-
}
|
|
3261
|
-
get sourcemapIgnoreList() {
|
|
3262
|
-
return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
|
|
3263
|
-
}
|
|
3264
|
-
get sourcemapPathTransform() {
|
|
3265
|
-
return this.outputOptions.sourcemapPathTransform;
|
|
3266
|
-
}
|
|
3267
|
-
get minify() {
|
|
3268
|
-
return this.inner.minify;
|
|
3269
|
-
}
|
|
3270
|
-
get legalComments() {
|
|
3271
|
-
return this.inner.legalComments;
|
|
3272
|
-
}
|
|
3273
|
-
get polyfillRequire() {
|
|
3274
|
-
return this.inner.polyfillRequire;
|
|
3275
|
-
}
|
|
3276
|
-
get plugins() {
|
|
3277
|
-
return this.normalizedOutputPlugins;
|
|
3278
|
-
}
|
|
3279
|
-
get preserveModules() {
|
|
3280
|
-
return this.inner.preserveModules;
|
|
3281
|
-
}
|
|
3282
|
-
get preserveModulesRoot() {
|
|
3283
|
-
return this.inner.preserveModulesRoot;
|
|
3284
|
-
}
|
|
3285
|
-
get virtualDirname() {
|
|
3286
|
-
return this.inner.virtualDirname;
|
|
3287
|
-
}
|
|
3288
|
-
};
|
|
3289
|
-
function normalizeAddon(value) {
|
|
3290
|
-
if (typeof value === "function") return value;
|
|
3291
|
-
return () => value || "";
|
|
3292
|
-
}
|
|
3293
|
-
|
|
3294
3061
|
//#endregion
|
|
3295
3062
|
//#region src/utils/transform-to-rollup-output.ts
|
|
3296
3063
|
function transformToRollupSourceMap(map) {
|
|
@@ -3436,7 +3203,7 @@ function collectChangedBundle(changed, bundle) {
|
|
|
3436
3203
|
facadeModuleId: item.facadeModuleId || void 0,
|
|
3437
3204
|
isDynamicEntry: item.isDynamicEntry,
|
|
3438
3205
|
moduleIds: item.moduleIds,
|
|
3439
|
-
map: bindingifySourcemap(item.map),
|
|
3206
|
+
map: bindingifySourcemap$1(item.map),
|
|
3440
3207
|
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
3441
3208
|
preliminaryFilename: item.preliminaryFileName
|
|
3442
3209
|
});
|
|
@@ -3456,7 +3223,7 @@ function bindingifyRenderStart(args$1) {
|
|
|
3456
3223
|
const { handler, meta } = normalizeHook(hook);
|
|
3457
3224
|
return {
|
|
3458
3225
|
plugin: async (ctx, opts) => {
|
|
3459
|
-
handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode),
|
|
3226
|
+
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));
|
|
3460
3227
|
},
|
|
3461
3228
|
meta: bindingifyPluginHookMeta(meta)
|
|
3462
3229
|
};
|
|
@@ -3468,13 +3235,13 @@ function bindingifyRenderChunk(args$1) {
|
|
|
3468
3235
|
return {
|
|
3469
3236
|
plugin: async (ctx, code$1, chunk, opts, meta$1) => {
|
|
3470
3237
|
if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
3471
|
-
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),
|
|
3238
|
+
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());
|
|
3472
3239
|
if (ret == null) return;
|
|
3473
3240
|
if (typeof ret === "string") return { code: ret };
|
|
3474
3241
|
if (!ret.map) return { code: ret.code };
|
|
3475
3242
|
return {
|
|
3476
3243
|
code: ret.code,
|
|
3477
|
-
map: bindingifySourcemap(ret.map)
|
|
3244
|
+
map: bindingifySourcemap$1(ret.map)
|
|
3478
3245
|
};
|
|
3479
3246
|
},
|
|
3480
3247
|
meta: bindingifyPluginHookMeta(meta),
|
|
@@ -3515,7 +3282,7 @@ function bindingifyGenerateBundle(args$1) {
|
|
|
3515
3282
|
};
|
|
3516
3283
|
const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
|
|
3517
3284
|
const output = transformToOutputBundle(context, bundle, changed);
|
|
3518
|
-
await handler.call(context,
|
|
3285
|
+
await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
|
|
3519
3286
|
return collectChangedBundle(changed, output);
|
|
3520
3287
|
},
|
|
3521
3288
|
meta: bindingifyPluginHookMeta(meta)
|
|
@@ -3533,7 +3300,7 @@ function bindingifyWriteBundle(args$1) {
|
|
|
3533
3300
|
};
|
|
3534
3301
|
const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
|
|
3535
3302
|
const output = transformToOutputBundle(context, bundle, changed);
|
|
3536
|
-
await handler.call(context,
|
|
3303
|
+
await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
|
|
3537
3304
|
return collectChangedBundle(changed, output);
|
|
3538
3305
|
},
|
|
3539
3306
|
meta: bindingifyPluginHookMeta(meta)
|
|
@@ -3808,32 +3575,293 @@ function wrapHandlers(plugin) {
|
|
|
3808
3575
|
}
|
|
3809
3576
|
|
|
3810
3577
|
//#endregion
|
|
3811
|
-
//#region src/
|
|
3812
|
-
var
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
renderedChunkMeta = null;
|
|
3818
|
-
updateModuleOption(id$1, option) {
|
|
3819
|
-
const existing = this.moduleOptionMap.get(id$1);
|
|
3820
|
-
if (existing) {
|
|
3821
|
-
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
3822
|
-
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
3823
|
-
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
3824
|
-
} else {
|
|
3825
|
-
this.moduleOptionMap.set(id$1, option);
|
|
3826
|
-
return option;
|
|
3827
|
-
}
|
|
3828
|
-
return existing;
|
|
3578
|
+
//#region src/options/normalized-input-options.ts
|
|
3579
|
+
var NormalizedInputOptionsImpl = class {
|
|
3580
|
+
inner;
|
|
3581
|
+
constructor(inner, onLog) {
|
|
3582
|
+
this.onLog = onLog;
|
|
3583
|
+
this.inner = inner;
|
|
3829
3584
|
}
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3585
|
+
get shimMissingExports() {
|
|
3586
|
+
return this.inner.shimMissingExports;
|
|
3587
|
+
}
|
|
3588
|
+
get input() {
|
|
3589
|
+
return this.inner.input;
|
|
3590
|
+
}
|
|
3591
|
+
get cwd() {
|
|
3592
|
+
return this.inner.cwd ?? void 0;
|
|
3593
|
+
}
|
|
3594
|
+
get platform() {
|
|
3595
|
+
return this.inner.platform;
|
|
3596
|
+
}
|
|
3597
|
+
};
|
|
3598
|
+
|
|
3599
|
+
//#endregion
|
|
3600
|
+
//#region src/types/chunking-context.ts
|
|
3601
|
+
var ChunkingContextImpl = class {
|
|
3602
|
+
constructor(context) {
|
|
3603
|
+
this.context = context;
|
|
3604
|
+
}
|
|
3605
|
+
getModuleInfo(moduleId) {
|
|
3606
|
+
const bindingInfo = this.context.getModuleInfo(moduleId);
|
|
3607
|
+
if (bindingInfo) {
|
|
3608
|
+
const info = transformModuleInfo(bindingInfo, {
|
|
3609
|
+
moduleSideEffects: null,
|
|
3610
|
+
meta: {}
|
|
3611
|
+
});
|
|
3612
|
+
return info;
|
|
3613
|
+
}
|
|
3614
|
+
return null;
|
|
3615
|
+
}
|
|
3616
|
+
};
|
|
3617
|
+
|
|
3618
|
+
//#endregion
|
|
3619
|
+
//#region src/utils/bindingify-output-options.ts
|
|
3620
|
+
function bindingifyOutputOptions(outputOptions) {
|
|
3621
|
+
const { dir, format, exports, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks } = outputOptions;
|
|
3622
|
+
const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
|
|
3623
|
+
return {
|
|
3624
|
+
dir,
|
|
3625
|
+
file: file == null ? void 0 : file,
|
|
3626
|
+
format: bindingifyFormat(format),
|
|
3627
|
+
exports,
|
|
3628
|
+
hashCharacters,
|
|
3629
|
+
sourcemap: bindingifySourcemap(sourcemap),
|
|
3630
|
+
sourcemapDebugIds,
|
|
3631
|
+
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
3632
|
+
sourcemapPathTransform,
|
|
3633
|
+
banner: bindingifyAddon(banner),
|
|
3634
|
+
footer: bindingifyAddon(footer),
|
|
3635
|
+
intro: bindingifyAddon(intro),
|
|
3636
|
+
outro: bindingifyAddon(outro),
|
|
3637
|
+
extend: outputOptions.extend,
|
|
3638
|
+
globals,
|
|
3639
|
+
esModule,
|
|
3640
|
+
name,
|
|
3641
|
+
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
3642
|
+
entryFileNames,
|
|
3643
|
+
chunkFileNames,
|
|
3644
|
+
cssEntryFileNames,
|
|
3645
|
+
cssChunkFileNames,
|
|
3646
|
+
plugins: [],
|
|
3647
|
+
minify: outputOptions.minify,
|
|
3648
|
+
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
3649
|
+
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
3650
|
+
advancedChunks,
|
|
3651
|
+
polyfillRequire: outputOptions.polyfillRequire,
|
|
3652
|
+
sanitizeFileName,
|
|
3653
|
+
preserveModules,
|
|
3654
|
+
virtualDirname,
|
|
3655
|
+
legalComments,
|
|
3656
|
+
preserveModulesRoot
|
|
3657
|
+
};
|
|
3658
|
+
}
|
|
3659
|
+
function bindingifyAddon(configAddon) {
|
|
3660
|
+
return async (chunk) => {
|
|
3661
|
+
if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
|
|
3662
|
+
return configAddon || "";
|
|
3663
|
+
};
|
|
3664
|
+
}
|
|
3665
|
+
function bindingifyFormat(format) {
|
|
3666
|
+
switch (format) {
|
|
3667
|
+
case void 0:
|
|
3668
|
+
case "es":
|
|
3669
|
+
case "esm":
|
|
3670
|
+
case "module": return "es";
|
|
3671
|
+
case "cjs":
|
|
3672
|
+
case "commonjs": return "cjs";
|
|
3673
|
+
case "iife": return "iife";
|
|
3674
|
+
case "umd": return "umd";
|
|
3675
|
+
default: unimplemented(`output.format: ${format}`);
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
function bindingifySourcemap(sourcemap) {
|
|
3679
|
+
switch (sourcemap) {
|
|
3680
|
+
case true: return "file";
|
|
3681
|
+
case "inline": return "inline";
|
|
3682
|
+
case false:
|
|
3683
|
+
case void 0: return void 0;
|
|
3684
|
+
case "hidden": return "hidden";
|
|
3685
|
+
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
3689
|
+
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
3690
|
+
}
|
|
3691
|
+
function bindingifyAssetFilenames(assetFileNames) {
|
|
3692
|
+
if (typeof assetFileNames === "function") return (asset) => {
|
|
3693
|
+
return assetFileNames({
|
|
3694
|
+
names: asset.names,
|
|
3695
|
+
originalFileNames: asset.originalFileNames,
|
|
3696
|
+
source: transformAssetSource(asset.source),
|
|
3697
|
+
type: "asset"
|
|
3698
|
+
});
|
|
3699
|
+
};
|
|
3700
|
+
return assetFileNames;
|
|
3701
|
+
}
|
|
3702
|
+
function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
|
|
3703
|
+
if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
|
|
3704
|
+
else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
|
|
3705
|
+
return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
|
|
3706
|
+
} }] };
|
|
3707
|
+
if (advancedChunks == null) return void 0;
|
|
3708
|
+
const { groups,...restAdvancedChunks } = advancedChunks;
|
|
3709
|
+
return {
|
|
3710
|
+
...restAdvancedChunks,
|
|
3711
|
+
groups: groups?.map((group) => {
|
|
3712
|
+
const { name,...restGroup } = group;
|
|
3713
|
+
return {
|
|
3714
|
+
...restGroup,
|
|
3715
|
+
name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContextImpl(ctx)) : name
|
|
3716
|
+
};
|
|
3717
|
+
})
|
|
3718
|
+
};
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
//#endregion
|
|
3722
|
+
//#region src/options/normalized-output-options.ts
|
|
3723
|
+
var NormalizedOutputOptionsImpl = class {
|
|
3724
|
+
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
3725
|
+
this.inner = inner;
|
|
3726
|
+
this.outputOptions = outputOptions;
|
|
3727
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3728
|
+
}
|
|
3729
|
+
get dir() {
|
|
3730
|
+
return this.inner.dir ?? void 0;
|
|
3731
|
+
}
|
|
3732
|
+
get entryFileNames() {
|
|
3733
|
+
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
3734
|
+
}
|
|
3735
|
+
get chunkFileNames() {
|
|
3736
|
+
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3737
|
+
}
|
|
3738
|
+
get assetFileNames() {
|
|
3739
|
+
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
3740
|
+
}
|
|
3741
|
+
get format() {
|
|
3742
|
+
return this.inner.format;
|
|
3743
|
+
}
|
|
3744
|
+
get exports() {
|
|
3745
|
+
return this.inner.exports;
|
|
3746
|
+
}
|
|
3747
|
+
get sourcemap() {
|
|
3748
|
+
return this.inner.sourcemap;
|
|
3749
|
+
}
|
|
3750
|
+
get cssEntryFileNames() {
|
|
3751
|
+
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
3752
|
+
}
|
|
3753
|
+
get cssChunkFileNames() {
|
|
3754
|
+
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
3755
|
+
}
|
|
3756
|
+
get shimMissingExports() {
|
|
3757
|
+
return this.inner.shimMissingExports;
|
|
3758
|
+
}
|
|
3759
|
+
get name() {
|
|
3760
|
+
return this.inner.name ?? void 0;
|
|
3761
|
+
}
|
|
3762
|
+
get file() {
|
|
3763
|
+
return this.inner.file ?? void 0;
|
|
3764
|
+
}
|
|
3765
|
+
get inlineDynamicImports() {
|
|
3766
|
+
return this.inner.inlineDynamicImports;
|
|
3767
|
+
}
|
|
3768
|
+
get externalLiveBindings() {
|
|
3769
|
+
return this.inner.externalLiveBindings;
|
|
3770
|
+
}
|
|
3771
|
+
get banner() {
|
|
3772
|
+
return normalizeAddon(this.outputOptions.banner);
|
|
3773
|
+
}
|
|
3774
|
+
get footer() {
|
|
3775
|
+
return normalizeAddon(this.outputOptions.footer);
|
|
3776
|
+
}
|
|
3777
|
+
get intro() {
|
|
3778
|
+
return normalizeAddon(this.outputOptions.intro);
|
|
3779
|
+
}
|
|
3780
|
+
get outro() {
|
|
3781
|
+
return normalizeAddon(this.outputOptions.outro);
|
|
3782
|
+
}
|
|
3783
|
+
get esModule() {
|
|
3784
|
+
return this.inner.esModule;
|
|
3785
|
+
}
|
|
3786
|
+
get extend() {
|
|
3787
|
+
return this.inner.extend;
|
|
3788
|
+
}
|
|
3789
|
+
get globals() {
|
|
3790
|
+
return this.inner.globals || this.outputOptions.globals;
|
|
3791
|
+
}
|
|
3792
|
+
get hashCharacters() {
|
|
3793
|
+
return this.inner.hashCharacters;
|
|
3794
|
+
}
|
|
3795
|
+
get sourcemapDebugIds() {
|
|
3796
|
+
return this.inner.sourcemapDebugIds;
|
|
3797
|
+
}
|
|
3798
|
+
get sourcemapIgnoreList() {
|
|
3799
|
+
return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
|
|
3800
|
+
}
|
|
3801
|
+
get sourcemapPathTransform() {
|
|
3802
|
+
return this.outputOptions.sourcemapPathTransform;
|
|
3803
|
+
}
|
|
3804
|
+
get minify() {
|
|
3805
|
+
return this.inner.minify;
|
|
3806
|
+
}
|
|
3807
|
+
get legalComments() {
|
|
3808
|
+
return this.inner.legalComments;
|
|
3809
|
+
}
|
|
3810
|
+
get polyfillRequire() {
|
|
3811
|
+
return this.inner.polyfillRequire;
|
|
3812
|
+
}
|
|
3813
|
+
get plugins() {
|
|
3814
|
+
return this.normalizedOutputPlugins;
|
|
3815
|
+
}
|
|
3816
|
+
get preserveModules() {
|
|
3817
|
+
return this.inner.preserveModules;
|
|
3818
|
+
}
|
|
3819
|
+
get preserveModulesRoot() {
|
|
3820
|
+
return this.inner.preserveModulesRoot;
|
|
3821
|
+
}
|
|
3822
|
+
get virtualDirname() {
|
|
3823
|
+
return this.inner.virtualDirname;
|
|
3824
|
+
}
|
|
3825
|
+
};
|
|
3826
|
+
function normalizeAddon(value) {
|
|
3827
|
+
if (typeof value === "function") return value;
|
|
3828
|
+
return () => value || "";
|
|
3829
|
+
}
|
|
3830
|
+
|
|
3831
|
+
//#endregion
|
|
3832
|
+
//#region src/plugin/plugin-context-data.ts
|
|
3833
|
+
var PluginContextData = class {
|
|
3834
|
+
moduleOptionMap = /* @__PURE__ */ new Map();
|
|
3835
|
+
resolveOptionsMap = /* @__PURE__ */ new Map();
|
|
3836
|
+
loadModulePromiseMap = /* @__PURE__ */ new Map();
|
|
3837
|
+
loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
|
|
3838
|
+
renderedChunkMeta = null;
|
|
3839
|
+
normalizedInputOptions = null;
|
|
3840
|
+
normalizedOutputOptions = null;
|
|
3841
|
+
constructor(onLog, outputOptions, normalizedOutputPlugins) {
|
|
3842
|
+
this.onLog = onLog;
|
|
3843
|
+
this.outputOptions = outputOptions;
|
|
3844
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3845
|
+
}
|
|
3846
|
+
updateModuleOption(id$1, option) {
|
|
3847
|
+
const existing = this.moduleOptionMap.get(id$1);
|
|
3848
|
+
if (existing) {
|
|
3849
|
+
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
3850
|
+
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
3851
|
+
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
3852
|
+
} else {
|
|
3853
|
+
this.moduleOptionMap.set(id$1, option);
|
|
3854
|
+
return option;
|
|
3855
|
+
}
|
|
3856
|
+
return existing;
|
|
3857
|
+
}
|
|
3858
|
+
getModuleOption(id$1) {
|
|
3859
|
+
const option = this.moduleOptionMap.get(id$1);
|
|
3860
|
+
if (!option) {
|
|
3861
|
+
const raw = {
|
|
3862
|
+
moduleSideEffects: null,
|
|
3863
|
+
meta: {}
|
|
3864
|
+
};
|
|
3837
3865
|
this.moduleOptionMap.set(id$1, raw);
|
|
3838
3866
|
return raw;
|
|
3839
3867
|
}
|
|
@@ -3885,6 +3913,14 @@ var PluginContextData = class {
|
|
|
3885
3913
|
getRenderChunkMeta() {
|
|
3886
3914
|
return this.renderedChunkMeta;
|
|
3887
3915
|
}
|
|
3916
|
+
getInputOptions(opts) {
|
|
3917
|
+
this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
|
|
3918
|
+
return this.normalizedInputOptions;
|
|
3919
|
+
}
|
|
3920
|
+
getOutputOptions(opts) {
|
|
3921
|
+
this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
|
|
3922
|
+
return this.normalizedOutputOptions;
|
|
3923
|
+
}
|
|
3888
3924
|
markModuleLoaded(id$1, _success) {
|
|
3889
3925
|
const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
|
|
3890
3926
|
if (resolve) resolve();
|
|
@@ -3910,7 +3946,7 @@ function isReadonlyArray(input) {
|
|
|
3910
3946
|
//#endregion
|
|
3911
3947
|
//#region src/utils/bindingify-input-options.ts
|
|
3912
3948
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
3913
|
-
const pluginContextData = new PluginContextData();
|
|
3949
|
+
const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
|
|
3914
3950
|
const plugins = rawPlugins.map((plugin) => {
|
|
3915
3951
|
if ("_parallel" in plugin) return void 0;
|
|
3916
3952
|
if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
|
|
@@ -4085,7 +4121,8 @@ function bindingifyTreeshakeOptions(config) {
|
|
|
4085
4121
|
moduleSideEffects: true,
|
|
4086
4122
|
annotations: config.annotations,
|
|
4087
4123
|
manualPureFunctions: config.manualPureFunctions,
|
|
4088
|
-
unknownGlobalSideEffects: config.unknownGlobalSideEffects
|
|
4124
|
+
unknownGlobalSideEffects: config.unknownGlobalSideEffects,
|
|
4125
|
+
commonjs: config.commonjs
|
|
4089
4126
|
};
|
|
4090
4127
|
if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
|
|
4091
4128
|
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
@@ -4117,323 +4154,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
|
|
|
4117
4154
|
};
|
|
4118
4155
|
}
|
|
4119
4156
|
|
|
4120
|
-
//#endregion
|
|
4121
|
-
//#region src/utils/plugin/index.ts
|
|
4122
|
-
const isPluginHookName = function() {
|
|
4123
|
-
const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
|
|
4124
|
-
return function isPluginHookName$1(hookName) {
|
|
4125
|
-
return PLUGIN_HOOK_NAMES_SET.has(hookName);
|
|
4126
|
-
};
|
|
4127
|
-
}();
|
|
4128
|
-
|
|
4129
|
-
//#endregion
|
|
4130
|
-
//#region src/utils/compose-js-plugins.ts
|
|
4131
|
-
const unsupportedHookName = [
|
|
4132
|
-
"augmentChunkHash",
|
|
4133
|
-
"generateBundle",
|
|
4134
|
-
"moduleParsed",
|
|
4135
|
-
"onLog",
|
|
4136
|
-
"options",
|
|
4137
|
-
"outputOptions",
|
|
4138
|
-
"renderError",
|
|
4139
|
-
"renderStart",
|
|
4140
|
-
"resolveDynamicImport",
|
|
4141
|
-
"writeBundle"
|
|
4142
|
-
];
|
|
4143
|
-
const unsupportedHooks = new Set(unsupportedHookName);
|
|
4144
|
-
function isUnsupportedHooks(hookName) {
|
|
4145
|
-
return unsupportedHooks.has(hookName);
|
|
4146
|
-
}
|
|
4147
|
-
function createComposedPlugin(plugins) {
|
|
4148
|
-
const names = [];
|
|
4149
|
-
const batchedHooks = {};
|
|
4150
|
-
plugins.forEach((plugin, index) => {
|
|
4151
|
-
const pluginName = plugin.name || `Anonymous(index: ${index})`;
|
|
4152
|
-
names.push(pluginName);
|
|
4153
|
-
t(plugin).forEach((pluginProp) => {
|
|
4154
|
-
if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
|
|
4155
|
-
if (!isPluginHookName(pluginProp)) return;
|
|
4156
|
-
switch (pluginProp) {
|
|
4157
|
-
case "buildStart": {
|
|
4158
|
-
const handlers = batchedHooks.buildStart ?? [];
|
|
4159
|
-
batchedHooks.buildStart = handlers;
|
|
4160
|
-
if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
|
|
4161
|
-
break;
|
|
4162
|
-
}
|
|
4163
|
-
case "load": {
|
|
4164
|
-
const handlers = batchedHooks.load ?? [];
|
|
4165
|
-
batchedHooks.load = handlers;
|
|
4166
|
-
if (plugin.load) handlers.push([plugin.load, plugin]);
|
|
4167
|
-
break;
|
|
4168
|
-
}
|
|
4169
|
-
case "transform": {
|
|
4170
|
-
const handlers = batchedHooks.transform ?? [];
|
|
4171
|
-
batchedHooks.transform = handlers;
|
|
4172
|
-
if (plugin.transform) handlers.push([plugin.transform, plugin]);
|
|
4173
|
-
break;
|
|
4174
|
-
}
|
|
4175
|
-
case "resolveId": {
|
|
4176
|
-
const handlers = batchedHooks.resolveId ?? [];
|
|
4177
|
-
batchedHooks.resolveId = handlers;
|
|
4178
|
-
if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
|
|
4179
|
-
break;
|
|
4180
|
-
}
|
|
4181
|
-
case "buildEnd": {
|
|
4182
|
-
const handlers = batchedHooks.buildEnd ?? [];
|
|
4183
|
-
batchedHooks.buildEnd = handlers;
|
|
4184
|
-
if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
|
|
4185
|
-
break;
|
|
4186
|
-
}
|
|
4187
|
-
case "renderChunk": {
|
|
4188
|
-
const handlers = batchedHooks.renderChunk ?? [];
|
|
4189
|
-
batchedHooks.renderChunk = handlers;
|
|
4190
|
-
if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
|
|
4191
|
-
break;
|
|
4192
|
-
}
|
|
4193
|
-
case "banner":
|
|
4194
|
-
case "footer":
|
|
4195
|
-
case "intro":
|
|
4196
|
-
case "outro": {
|
|
4197
|
-
const hook = plugin[pluginProp];
|
|
4198
|
-
if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
|
|
4199
|
-
break;
|
|
4200
|
-
}
|
|
4201
|
-
case "closeBundle": {
|
|
4202
|
-
const handlers = batchedHooks.closeBundle ?? [];
|
|
4203
|
-
batchedHooks.closeBundle = handlers;
|
|
4204
|
-
if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
|
|
4205
|
-
break;
|
|
4206
|
-
}
|
|
4207
|
-
case "watchChange": {
|
|
4208
|
-
const handlers = batchedHooks.watchChange ?? [];
|
|
4209
|
-
batchedHooks.watchChange = handlers;
|
|
4210
|
-
if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
|
|
4211
|
-
break;
|
|
4212
|
-
}
|
|
4213
|
-
case "closeWatcher": {
|
|
4214
|
-
const handlers = batchedHooks.closeWatcher ?? [];
|
|
4215
|
-
batchedHooks.closeWatcher = handlers;
|
|
4216
|
-
if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
|
|
4217
|
-
break;
|
|
4218
|
-
}
|
|
4219
|
-
default: {}
|
|
4220
|
-
}
|
|
4221
|
-
});
|
|
4222
|
-
});
|
|
4223
|
-
const composed = { name: `Composed(${names.join(", ")})` };
|
|
4224
|
-
const createFixedPluginResolveFnMap = /* @__PURE__ */ new Map();
|
|
4225
|
-
function applyFixedPluginResolveFn(ctx, plugin) {
|
|
4226
|
-
const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
|
|
4227
|
-
if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
|
|
4228
|
-
return ctx;
|
|
4229
|
-
}
|
|
4230
|
-
if (batchedHooks.resolveId) {
|
|
4231
|
-
const batchedHandlers = batchedHooks.resolveId;
|
|
4232
|
-
const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
|
|
4233
|
-
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
4234
|
-
const [_handler, plugin] = batchedHandlers[handlerIdx];
|
|
4235
|
-
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
4236
|
-
const createFixedPluginResolveFn = (ctx, resolve) => {
|
|
4237
|
-
return (source, importer, rawContextResolveOptions) => {
|
|
4238
|
-
const contextResolveOptions = rawContextResolveOptions ?? {};
|
|
4239
|
-
if (contextResolveOptions.skipSelf) {
|
|
4240
|
-
contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
|
|
4241
|
-
contextResolveOptions.skipSelf = false;
|
|
4242
|
-
}
|
|
4243
|
-
return resolve(source, importer, contextResolveOptions);
|
|
4244
|
-
};
|
|
4245
|
-
};
|
|
4246
|
-
createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
|
|
4247
|
-
}
|
|
4248
|
-
composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
|
|
4249
|
-
const hookResolveIdOptions = rawHookResolveIdOptions;
|
|
4250
|
-
const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
|
|
4251
|
-
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
4252
|
-
const [handler, plugin] = batchedHandlers[handlerIdx];
|
|
4253
|
-
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
4254
|
-
if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
|
|
4255
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4256
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
|
|
4257
|
-
if (!isNullish(result)) return result;
|
|
4258
|
-
}
|
|
4259
|
-
};
|
|
4260
|
-
}
|
|
4261
|
-
t(batchedHooks).forEach((hookName) => {
|
|
4262
|
-
switch (hookName) {
|
|
4263
|
-
case "resolveId": break;
|
|
4264
|
-
case "buildStart": {
|
|
4265
|
-
if (batchedHooks.buildStart) {
|
|
4266
|
-
const batchedHandlers = batchedHooks.buildStart;
|
|
4267
|
-
composed.buildStart = async function(options) {
|
|
4268
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4269
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4270
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
|
|
4271
|
-
}));
|
|
4272
|
-
};
|
|
4273
|
-
}
|
|
4274
|
-
break;
|
|
4275
|
-
}
|
|
4276
|
-
case "load": {
|
|
4277
|
-
if (batchedHooks.load) {
|
|
4278
|
-
const batchedHandlers = batchedHooks.load;
|
|
4279
|
-
composed.load = async function(id$1) {
|
|
4280
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4281
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4282
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
|
|
4283
|
-
if (!isNullish(result)) return result;
|
|
4284
|
-
}
|
|
4285
|
-
};
|
|
4286
|
-
}
|
|
4287
|
-
break;
|
|
4288
|
-
}
|
|
4289
|
-
case "transform": {
|
|
4290
|
-
if (batchedHooks.transform) {
|
|
4291
|
-
const batchedHandlers = batchedHooks.transform;
|
|
4292
|
-
composed.transform = async function(initialCode, id$1, moduleType$1) {
|
|
4293
|
-
let code$1 = initialCode;
|
|
4294
|
-
let moduleSideEffects = void 0;
|
|
4295
|
-
function updateOutput(newCode, newModuleSideEffects) {
|
|
4296
|
-
code$1 = newCode;
|
|
4297
|
-
moduleSideEffects = newModuleSideEffects ?? void 0;
|
|
4298
|
-
}
|
|
4299
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4300
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4301
|
-
this.getCombinedSourcemap = () => {
|
|
4302
|
-
throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
|
|
4303
|
-
};
|
|
4304
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
|
|
4305
|
-
if (!isNullish(result)) {
|
|
4306
|
-
if (typeof result === "string") updateOutput(result);
|
|
4307
|
-
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
4308
|
-
}
|
|
4309
|
-
}
|
|
4310
|
-
return {
|
|
4311
|
-
code: code$1,
|
|
4312
|
-
moduleSideEffects
|
|
4313
|
-
};
|
|
4314
|
-
};
|
|
4315
|
-
}
|
|
4316
|
-
break;
|
|
4317
|
-
}
|
|
4318
|
-
case "buildEnd": {
|
|
4319
|
-
if (batchedHooks.buildEnd) {
|
|
4320
|
-
const batchedHandlers = batchedHooks.buildEnd;
|
|
4321
|
-
composed.buildEnd = async function(err) {
|
|
4322
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4323
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4324
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
|
|
4325
|
-
}));
|
|
4326
|
-
};
|
|
4327
|
-
}
|
|
4328
|
-
break;
|
|
4329
|
-
}
|
|
4330
|
-
case "renderChunk": {
|
|
4331
|
-
if (batchedHooks.renderChunk) {
|
|
4332
|
-
const batchedHandlers = batchedHooks.renderChunk;
|
|
4333
|
-
composed.renderChunk = async function(code$1, chunk, options, meta) {
|
|
4334
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4335
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4336
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
|
|
4337
|
-
if (!isNullish(result)) return result;
|
|
4338
|
-
}
|
|
4339
|
-
};
|
|
4340
|
-
}
|
|
4341
|
-
break;
|
|
4342
|
-
}
|
|
4343
|
-
case "banner":
|
|
4344
|
-
case "footer":
|
|
4345
|
-
case "intro":
|
|
4346
|
-
case "outro": {
|
|
4347
|
-
const hooks = batchedHooks[hookName];
|
|
4348
|
-
if (hooks?.length) composed[hookName] = async function(chunk) {
|
|
4349
|
-
const ret = [];
|
|
4350
|
-
for (const [hook, plugin] of hooks) {
|
|
4351
|
-
const { handler } = normalizeHook(hook);
|
|
4352
|
-
ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
|
|
4353
|
-
}
|
|
4354
|
-
return ret.join("\n");
|
|
4355
|
-
};
|
|
4356
|
-
break;
|
|
4357
|
-
}
|
|
4358
|
-
case "closeBundle": {
|
|
4359
|
-
if (batchedHooks.closeBundle) {
|
|
4360
|
-
const batchedHandlers = batchedHooks.closeBundle;
|
|
4361
|
-
composed.closeBundle = async function() {
|
|
4362
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4363
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4364
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
4365
|
-
}));
|
|
4366
|
-
};
|
|
4367
|
-
}
|
|
4368
|
-
break;
|
|
4369
|
-
}
|
|
4370
|
-
case "watchChange": {
|
|
4371
|
-
if (batchedHooks.watchChange) {
|
|
4372
|
-
const batchedHandlers = batchedHooks.watchChange;
|
|
4373
|
-
composed.watchChange = async function(id$1, event) {
|
|
4374
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4375
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4376
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
|
|
4377
|
-
}));
|
|
4378
|
-
};
|
|
4379
|
-
}
|
|
4380
|
-
break;
|
|
4381
|
-
}
|
|
4382
|
-
case "closeWatcher": {
|
|
4383
|
-
if (batchedHooks.closeWatcher) {
|
|
4384
|
-
const batchedHandlers = batchedHooks.closeWatcher;
|
|
4385
|
-
composed.closeWatcher = async function() {
|
|
4386
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4387
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4388
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
4389
|
-
}));
|
|
4390
|
-
};
|
|
4391
|
-
}
|
|
4392
|
-
break;
|
|
4393
|
-
}
|
|
4394
|
-
default: {}
|
|
4395
|
-
}
|
|
4396
|
-
});
|
|
4397
|
-
return composed;
|
|
4398
|
-
}
|
|
4399
|
-
function isComposablePlugin(plugin) {
|
|
4400
|
-
if (plugin instanceof BuiltinPlugin) return false;
|
|
4401
|
-
if ("_parallel" in plugin) return false;
|
|
4402
|
-
const hasNotComposablePattern = t(plugin).some((hookName) => {
|
|
4403
|
-
if (!isPluginHookName(hookName)) return false;
|
|
4404
|
-
const OK_TO_COMPOSE = false;
|
|
4405
|
-
if (isUnsupportedHooks(hookName)) return true;
|
|
4406
|
-
if (plugin[hookName]) {
|
|
4407
|
-
const { meta } = normalizeHook(plugin[hookName]);
|
|
4408
|
-
if (meta.order === "pre" || meta.order === "post") return true;
|
|
4409
|
-
}
|
|
4410
|
-
return OK_TO_COMPOSE;
|
|
4411
|
-
});
|
|
4412
|
-
if (hasNotComposablePattern) return false;
|
|
4413
|
-
return true;
|
|
4414
|
-
}
|
|
4415
|
-
function composeJsPlugins(plugins) {
|
|
4416
|
-
const newPlugins = [];
|
|
4417
|
-
const toBeComposed = [];
|
|
4418
|
-
plugins.forEach((plugin) => {
|
|
4419
|
-
if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
|
|
4420
|
-
else {
|
|
4421
|
-
if (toBeComposed.length > 0) {
|
|
4422
|
-
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
4423
|
-
else newPlugins.push(toBeComposed[0]);
|
|
4424
|
-
toBeComposed.length = 0;
|
|
4425
|
-
}
|
|
4426
|
-
newPlugins.push(plugin);
|
|
4427
|
-
}
|
|
4428
|
-
});
|
|
4429
|
-
if (toBeComposed.length > 0) {
|
|
4430
|
-
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
4431
|
-
else newPlugins.push(toBeComposed[0]);
|
|
4432
|
-
toBeComposed.length = 0;
|
|
4433
|
-
}
|
|
4434
|
-
return newPlugins;
|
|
4435
|
-
}
|
|
4436
|
-
|
|
4437
4157
|
//#endregion
|
|
4438
4158
|
//#region src/utils/initialize-parallel-plugins.ts
|
|
4439
4159
|
async function initializeParallelPlugins(plugins) {
|
|
@@ -4510,7 +4230,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
|
|
|
4510
4230
|
...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
|
|
4511
4231
|
...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
|
|
4512
4232
|
];
|
|
4513
|
-
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
4514
4233
|
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
4515
4234
|
try {
|
|
4516
4235
|
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
@@ -4780,4 +4499,4 @@ function defineConfig(config) {
|
|
|
4780
4499
|
const VERSION = version;
|
|
4781
4500
|
|
|
4782
4501
|
//#endregion
|
|
4783
|
-
export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, __commonJS, __toESM, ansis_default, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin,
|
|
4502
|
+
export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, __commonJS, __toESM, ansis_default, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, createBundlerImpl, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };
|