rolldown 1.0.0-beta.22 → 1.0.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +8 -8
- package/dist/cli.mjs +8 -8
- package/dist/config.cjs +4 -4
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +4 -4
- package/dist/experimental-index.cjs +3 -4
- package/dist/experimental-index.d.cts +3 -6
- package/dist/experimental-index.d.mts +3 -6
- package/dist/experimental-index.mjs +4 -4
- package/dist/experimental-runtime-types.d.ts +1 -2
- 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.cjs +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/parallel-plugin-worker.cjs +4 -4
- package/dist/parallel-plugin-worker.mjs +4 -4
- package/dist/parallel-plugin.d.cts +2 -2
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.cjs +1 -1
- package/dist/parse-ast-index.d.cts +1 -1
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/shared/{binding-B8kHDLfO.d.mts → binding-DG3bbtXG.d.cts} +4 -22
- package/dist/shared/{binding-CbR_BHh9.d.cts → binding-cECB-Ts3.d.mts} +4 -22
- package/dist/shared/{define-config-Czc3unFy.d.mts → define-config-BnlWQIlM.d.cts} +21 -23
- package/dist/shared/{define-config-DZVEpUTF.d.cts → define-config-DLGGYzTV.d.mts} +21 -23
- package/dist/shared/{load-config-gtAGhZYG.mjs → load-config-CciutN6Q.mjs} +1 -1
- package/dist/shared/{load-config-DPnW1OC0.cjs → load-config-xHhudbSQ.cjs} +1 -1
- package/dist/shared/{misc-BN0nse6C.mjs → misc-CQeo-AFx.mjs} +1 -4
- package/dist/shared/{misc-BKp5iIef.cjs → misc-DksvspN4.cjs} +0 -9
- package/dist/shared/{parse-ast-index-DDMiEgyY.cjs → parse-ast-index-BzYd1T7N.cjs} +15 -3
- package/dist/shared/{parse-ast-index-DmWy-n6o.mjs → parse-ast-index-D-D8UIRn.mjs} +10 -4
- package/dist/shared/{src-CJvC869N.mjs → src-CVZ9JbCC.mjs} +472 -766
- package/dist/shared/{src-9_Ra3A9D.cjs → src-DJtUlfyl.cjs} +455 -755
- package/package.json +19 -20
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, shutdownAsyncRuntime, startAsyncRuntime } from "./parse-ast-index-
|
|
2
|
-
import { arraify,
|
|
1
|
+
import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, augmentCodeLocation, error, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, shutdownAsyncRuntime, startAsyncRuntime } from "./parse-ast-index-D-D8UIRn.mjs";
|
|
2
|
+
import { arraify, noop, unimplemented, unreachable, unsupported } from "./misc-CQeo-AFx.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import colors from "ansis";
|
|
@@ -8,9 +8,20 @@ import os from "node:os";
|
|
|
8
8
|
import { Worker } from "node:worker_threads";
|
|
9
9
|
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version = "1.0.0-beta.
|
|
11
|
+
var version = "1.0.0-beta.24";
|
|
12
12
|
var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
13
13
|
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/utils/normalize-string-or-regex.ts
|
|
16
|
+
function normalizedStringOrRegex(pattern) {
|
|
17
|
+
if (!pattern) return void 0;
|
|
18
|
+
if (!isReadonlyArray(pattern)) return [pattern];
|
|
19
|
+
return pattern;
|
|
20
|
+
}
|
|
21
|
+
function isReadonlyArray(input) {
|
|
22
|
+
return Array.isArray(input);
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
//#endregion
|
|
15
26
|
//#region src/builtin-plugin/utils.ts
|
|
16
27
|
function makeBuiltinPluginCallable(plugin) {
|
|
@@ -40,6 +51,10 @@ function modulePreloadPolyfillPlugin(config) {
|
|
|
40
51
|
return new BuiltinPlugin("builtin:module-preload-polyfill", config);
|
|
41
52
|
}
|
|
42
53
|
function dynamicImportVarsPlugin(config) {
|
|
54
|
+
if (config) {
|
|
55
|
+
config.include = normalizedStringOrRegex(config.include);
|
|
56
|
+
config.exclude = normalizedStringOrRegex(config.exclude);
|
|
57
|
+
}
|
|
43
58
|
return new BuiltinPlugin("builtin:dynamic-import-vars", config);
|
|
44
59
|
}
|
|
45
60
|
function importGlobPlugin(config) {
|
|
@@ -51,8 +66,8 @@ function reporterPlugin(config) {
|
|
|
51
66
|
function manifestPlugin(config) {
|
|
52
67
|
return new BuiltinPlugin("builtin:manifest", config);
|
|
53
68
|
}
|
|
54
|
-
function wasmHelperPlugin() {
|
|
55
|
-
return new BuiltinPlugin("builtin:wasm-helper");
|
|
69
|
+
function wasmHelperPlugin(config) {
|
|
70
|
+
return new BuiltinPlugin("builtin:wasm-helper", config);
|
|
56
71
|
}
|
|
57
72
|
function wasmFallbackPlugin() {
|
|
58
73
|
const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
|
|
@@ -1991,6 +2006,7 @@ const TreeshakingOptionsSchema = union([boolean(), looseObject({
|
|
|
1991
2006
|
unknownGlobalSideEffects: optional(boolean()),
|
|
1992
2007
|
commonjs: optional(boolean())
|
|
1993
2008
|
})]);
|
|
2009
|
+
const OptimizationOptionsSchema = strictObject({ inlineConst: pipe(optional(boolean()), description("Enable crossmodule constant inlining")) });
|
|
1994
2010
|
const OnLogSchema = pipe(function_(), args(tuple([
|
|
1995
2011
|
LogLevelSchema,
|
|
1996
2012
|
RollupLogSchema,
|
|
@@ -2016,6 +2032,7 @@ const InputOptionsSchema = strictObject({
|
|
|
2016
2032
|
])), description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
|
|
2017
2033
|
shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
|
|
2018
2034
|
treeshake: optional(TreeshakingOptionsSchema),
|
|
2035
|
+
optimization: optional(OptimizationOptionsSchema),
|
|
2019
2036
|
logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
|
|
2020
2037
|
onLog: optional(OnLogSchema),
|
|
2021
2038
|
onwarn: optional(OnwarnSchema),
|
|
@@ -2254,41 +2271,9 @@ function getJsonSchema() {
|
|
|
2254
2271
|
return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
|
|
2255
2272
|
}
|
|
2256
2273
|
|
|
2257
|
-
//#endregion
|
|
2258
|
-
//#region src/constants/plugin-context.ts
|
|
2259
|
-
/**
|
|
2260
|
-
* If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
|
|
2261
|
-
* To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
|
|
2262
|
-
* will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
|
|
2263
|
-
* internally.
|
|
2264
|
-
*/
|
|
2265
|
-
const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
|
|
2266
|
-
|
|
2267
|
-
//#endregion
|
|
2268
|
-
//#region src/options/normalized-input-options.ts
|
|
2269
|
-
var NormalizedInputOptionsImpl = class {
|
|
2270
|
-
inner;
|
|
2271
|
-
constructor(inner, onLog) {
|
|
2272
|
-
this.onLog = onLog;
|
|
2273
|
-
this.inner = inner;
|
|
2274
|
-
}
|
|
2275
|
-
get shimMissingExports() {
|
|
2276
|
-
return this.inner.shimMissingExports;
|
|
2277
|
-
}
|
|
2278
|
-
get input() {
|
|
2279
|
-
return this.inner.input;
|
|
2280
|
-
}
|
|
2281
|
-
get cwd() {
|
|
2282
|
-
return this.inner.cwd ?? void 0;
|
|
2283
|
-
}
|
|
2284
|
-
get platform() {
|
|
2285
|
-
return this.inner.platform;
|
|
2286
|
-
}
|
|
2287
|
-
};
|
|
2288
|
-
|
|
2289
2274
|
//#endregion
|
|
2290
2275
|
//#region src/types/sourcemap.ts
|
|
2291
|
-
function bindingifySourcemap(map) {
|
|
2276
|
+
function bindingifySourcemap$1(map) {
|
|
2292
2277
|
if (map == null) return;
|
|
2293
2278
|
return { inner: typeof map === "string" ? map : {
|
|
2294
2279
|
file: map.file ?? void 0,
|
|
@@ -2404,8 +2389,8 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
|
2404
2389
|
//#endregion
|
|
2405
2390
|
//#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
|
|
2406
2391
|
function u$1(o, n, a) {
|
|
2407
|
-
let t
|
|
2408
|
-
return a === void 0 ? t
|
|
2392
|
+
let t = (r) => o(r, ...n);
|
|
2393
|
+
return a === void 0 ? t : Object.assign(t, {
|
|
2409
2394
|
lazy: a,
|
|
2410
2395
|
lazyArgs: n
|
|
2411
2396
|
});
|
|
@@ -2425,18 +2410,12 @@ function u(r, n, o) {
|
|
|
2425
2410
|
function d(...r) {
|
|
2426
2411
|
return u(i, r);
|
|
2427
2412
|
}
|
|
2428
|
-
var i = (r, t
|
|
2413
|
+
var i = (r, t) => {
|
|
2429
2414
|
let a = [[], []];
|
|
2430
|
-
for (let [o, e] of r.entries()) t
|
|
2415
|
+
for (let [o, e] of r.entries()) t(e, o, r) ? a[0].push(e) : a[1].push(e);
|
|
2431
2416
|
return a;
|
|
2432
2417
|
};
|
|
2433
2418
|
|
|
2434
|
-
//#endregion
|
|
2435
|
-
//#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
|
|
2436
|
-
function t(...n) {
|
|
2437
|
-
return u(Object.keys, n);
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
2419
|
//#endregion
|
|
2441
2420
|
//#region src/plugin/bindingify-hook-filter.ts
|
|
2442
2421
|
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
@@ -2741,7 +2720,7 @@ function bindingifyBuildStart(args$1) {
|
|
|
2741
2720
|
const { handler, meta } = normalizeHook(hook);
|
|
2742
2721
|
return {
|
|
2743
2722
|
plugin: async (ctx, opts) => {
|
|
2744
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode),
|
|
2723
|
+
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));
|
|
2745
2724
|
},
|
|
2746
2725
|
meta: bindingifyPluginHookMeta(meta)
|
|
2747
2726
|
};
|
|
@@ -2764,12 +2743,10 @@ function bindingifyResolveId(args$1) {
|
|
|
2764
2743
|
return {
|
|
2765
2744
|
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
2766
2745
|
const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
2767
|
-
const
|
|
2746
|
+
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, {
|
|
2768
2747
|
...extraOptions,
|
|
2769
|
-
custom: contextResolveOptions?.custom
|
|
2770
|
-
|
|
2771
|
-
};
|
|
2772
|
-
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);
|
|
2748
|
+
custom: contextResolveOptions?.custom
|
|
2749
|
+
});
|
|
2773
2750
|
if (ret == null) return;
|
|
2774
2751
|
if (ret === false) return {
|
|
2775
2752
|
id: specifier,
|
|
@@ -2840,7 +2817,7 @@ function bindingifyTransform(args$1) {
|
|
|
2840
2817
|
});
|
|
2841
2818
|
return {
|
|
2842
2819
|
code: ret.code,
|
|
2843
|
-
map: bindingifySourcemap(normalizeTransformHookSourcemap(id, code, ret.map)),
|
|
2820
|
+
map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id, code, ret.map)),
|
|
2844
2821
|
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
|
|
2845
2822
|
moduleType: ret.moduleType
|
|
2846
2823
|
};
|
|
@@ -2866,7 +2843,7 @@ function bindingifyLoad(args$1) {
|
|
|
2866
2843
|
let map = preProcessSourceMap(ret, id);
|
|
2867
2844
|
return {
|
|
2868
2845
|
code: ret.code,
|
|
2869
|
-
map: bindingifySourcemap(map),
|
|
2846
|
+
map: bindingifySourcemap$1(map),
|
|
2870
2847
|
moduleType: ret.moduleType,
|
|
2871
2848
|
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
|
|
2872
2849
|
};
|
|
@@ -2897,25 +2874,6 @@ function bindingifyModuleParsed(args$1) {
|
|
|
2897
2874
|
};
|
|
2898
2875
|
}
|
|
2899
2876
|
|
|
2900
|
-
//#endregion
|
|
2901
|
-
//#region src/types/chunking-context.ts
|
|
2902
|
-
var ChunkingContext = class {
|
|
2903
|
-
constructor(context) {
|
|
2904
|
-
this.context = context;
|
|
2905
|
-
}
|
|
2906
|
-
getModuleInfo(moduleId) {
|
|
2907
|
-
const bindingInfo = this.context.getModuleInfo(moduleId);
|
|
2908
|
-
if (bindingInfo) {
|
|
2909
|
-
const info = transformModuleInfo(bindingInfo, {
|
|
2910
|
-
moduleSideEffects: null,
|
|
2911
|
-
meta: {}
|
|
2912
|
-
});
|
|
2913
|
-
return info;
|
|
2914
|
-
}
|
|
2915
|
-
return null;
|
|
2916
|
-
}
|
|
2917
|
-
};
|
|
2918
|
-
|
|
2919
2877
|
//#endregion
|
|
2920
2878
|
//#region src/utils/transform-rendered-module.ts
|
|
2921
2879
|
function transformToRenderedModule(bindingRenderedModule) {
|
|
@@ -2982,338 +2940,125 @@ function transformChunkModules(modules) {
|
|
|
2982
2940
|
}
|
|
2983
2941
|
|
|
2984
2942
|
//#endregion
|
|
2985
|
-
//#region src/utils/
|
|
2986
|
-
function
|
|
2987
|
-
const
|
|
2988
|
-
const
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
sourcemapDebugIds,
|
|
2997
|
-
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
2998
|
-
sourcemapPathTransform,
|
|
2999
|
-
banner: bindingifyAddon(banner),
|
|
3000
|
-
footer: bindingifyAddon(footer),
|
|
3001
|
-
intro: bindingifyAddon(intro),
|
|
3002
|
-
outro: bindingifyAddon(outro),
|
|
3003
|
-
extend: outputOptions.extend,
|
|
3004
|
-
globals,
|
|
3005
|
-
esModule,
|
|
3006
|
-
name,
|
|
3007
|
-
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
3008
|
-
entryFileNames,
|
|
3009
|
-
chunkFileNames,
|
|
3010
|
-
cssEntryFileNames,
|
|
3011
|
-
cssChunkFileNames,
|
|
3012
|
-
plugins: [],
|
|
3013
|
-
minify: outputOptions.minify,
|
|
3014
|
-
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
3015
|
-
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
3016
|
-
advancedChunks,
|
|
3017
|
-
polyfillRequire: outputOptions.polyfillRequire,
|
|
3018
|
-
sanitizeFileName,
|
|
3019
|
-
preserveModules,
|
|
3020
|
-
virtualDirname,
|
|
3021
|
-
legalComments,
|
|
3022
|
-
preserveModulesRoot
|
|
2943
|
+
//#region src/utils/transform-to-rollup-output.ts
|
|
2944
|
+
function transformToRollupSourceMap(map) {
|
|
2945
|
+
const parsed = JSON.parse(map);
|
|
2946
|
+
const obj = {
|
|
2947
|
+
...parsed,
|
|
2948
|
+
toString() {
|
|
2949
|
+
return JSON.stringify(obj);
|
|
2950
|
+
},
|
|
2951
|
+
toUrl() {
|
|
2952
|
+
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
2953
|
+
}
|
|
3023
2954
|
};
|
|
2955
|
+
return obj;
|
|
3024
2956
|
}
|
|
3025
|
-
function
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
2957
|
+
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
2958
|
+
const chunk = {
|
|
2959
|
+
type: "chunk",
|
|
2960
|
+
get code() {
|
|
2961
|
+
return bindingChunk.code;
|
|
2962
|
+
},
|
|
2963
|
+
fileName: bindingChunk.fileName,
|
|
2964
|
+
name: bindingChunk.name,
|
|
2965
|
+
get modules() {
|
|
2966
|
+
return transformChunkModules(bindingChunk.modules);
|
|
2967
|
+
},
|
|
2968
|
+
get imports() {
|
|
2969
|
+
return bindingChunk.imports;
|
|
2970
|
+
},
|
|
2971
|
+
get dynamicImports() {
|
|
2972
|
+
return bindingChunk.dynamicImports;
|
|
2973
|
+
},
|
|
2974
|
+
exports: bindingChunk.exports,
|
|
2975
|
+
isEntry: bindingChunk.isEntry,
|
|
2976
|
+
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
2977
|
+
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
2978
|
+
get moduleIds() {
|
|
2979
|
+
return bindingChunk.moduleIds;
|
|
2980
|
+
},
|
|
2981
|
+
get map() {
|
|
2982
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
2983
|
+
},
|
|
2984
|
+
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
2985
|
+
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
3029
2986
|
};
|
|
2987
|
+
const cache = {};
|
|
2988
|
+
return new Proxy(chunk, {
|
|
2989
|
+
get(target, p) {
|
|
2990
|
+
if (p in cache) return cache[p];
|
|
2991
|
+
const value = target[p];
|
|
2992
|
+
cache[p] = value;
|
|
2993
|
+
return value;
|
|
2994
|
+
},
|
|
2995
|
+
set(target, p, newValue) {
|
|
2996
|
+
cache[p] = newValue;
|
|
2997
|
+
changed?.updated.add(bindingChunk.fileName);
|
|
2998
|
+
return true;
|
|
2999
|
+
},
|
|
3000
|
+
has(target, p) {
|
|
3001
|
+
if (p in cache) return true;
|
|
3002
|
+
return p in target;
|
|
3003
|
+
}
|
|
3004
|
+
});
|
|
3030
3005
|
}
|
|
3031
|
-
function
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
}
|
|
3006
|
+
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
3007
|
+
const asset = {
|
|
3008
|
+
type: "asset",
|
|
3009
|
+
fileName: bindingAsset.fileName,
|
|
3010
|
+
originalFileName: bindingAsset.originalFileName || null,
|
|
3011
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
3012
|
+
get source() {
|
|
3013
|
+
return transformAssetSource(bindingAsset.source);
|
|
3014
|
+
},
|
|
3015
|
+
name: bindingAsset.name ?? void 0,
|
|
3016
|
+
names: bindingAsset.names
|
|
3017
|
+
};
|
|
3018
|
+
const cache = {};
|
|
3019
|
+
return new Proxy(asset, {
|
|
3020
|
+
get(target, p) {
|
|
3021
|
+
if (p in cache) return cache[p];
|
|
3022
|
+
const value = target[p];
|
|
3023
|
+
cache[p] = value;
|
|
3024
|
+
return value;
|
|
3025
|
+
},
|
|
3026
|
+
set(target, p, newValue) {
|
|
3027
|
+
cache[p] = newValue;
|
|
3028
|
+
changed?.updated.add(bindingAsset.fileName);
|
|
3029
|
+
return true;
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
3043
3032
|
}
|
|
3044
|
-
function
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
case false:
|
|
3049
|
-
case void 0: return void 0;
|
|
3050
|
-
case "hidden": return "hidden";
|
|
3051
|
-
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
3052
|
-
}
|
|
3033
|
+
function transformToRollupOutput(output, changed) {
|
|
3034
|
+
handleOutputErrors(output);
|
|
3035
|
+
const { chunks, assets } = output;
|
|
3036
|
+
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
3053
3037
|
}
|
|
3054
|
-
function
|
|
3055
|
-
|
|
3038
|
+
function handleOutputErrors(output) {
|
|
3039
|
+
const rawErrors = output.errors;
|
|
3040
|
+
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
3056
3041
|
}
|
|
3057
|
-
function
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
groups: groups?.map((group) => {
|
|
3078
|
-
const { name,...restGroup } = group;
|
|
3079
|
-
return {
|
|
3080
|
-
...restGroup,
|
|
3081
|
-
name: typeof name === "function" ? (id, ctx) => name(id, new ChunkingContext(ctx)) : name
|
|
3082
|
-
};
|
|
3083
|
-
})
|
|
3084
|
-
};
|
|
3085
|
-
}
|
|
3086
|
-
|
|
3087
|
-
//#endregion
|
|
3088
|
-
//#region src/options/normalized-output-options.ts
|
|
3089
|
-
var NormalizedOutputOptionsImpl = class {
|
|
3090
|
-
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
3091
|
-
this.inner = inner;
|
|
3092
|
-
this.outputOptions = outputOptions;
|
|
3093
|
-
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3094
|
-
}
|
|
3095
|
-
get dir() {
|
|
3096
|
-
return this.inner.dir ?? void 0;
|
|
3097
|
-
}
|
|
3098
|
-
get entryFileNames() {
|
|
3099
|
-
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
3100
|
-
}
|
|
3101
|
-
get chunkFileNames() {
|
|
3102
|
-
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3103
|
-
}
|
|
3104
|
-
get assetFileNames() {
|
|
3105
|
-
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
3106
|
-
}
|
|
3107
|
-
get format() {
|
|
3108
|
-
return this.inner.format;
|
|
3109
|
-
}
|
|
3110
|
-
get exports() {
|
|
3111
|
-
return this.inner.exports;
|
|
3112
|
-
}
|
|
3113
|
-
get sourcemap() {
|
|
3114
|
-
return this.inner.sourcemap;
|
|
3115
|
-
}
|
|
3116
|
-
get cssEntryFileNames() {
|
|
3117
|
-
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
3118
|
-
}
|
|
3119
|
-
get cssChunkFileNames() {
|
|
3120
|
-
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
3121
|
-
}
|
|
3122
|
-
get shimMissingExports() {
|
|
3123
|
-
return this.inner.shimMissingExports;
|
|
3124
|
-
}
|
|
3125
|
-
get name() {
|
|
3126
|
-
return this.inner.name ?? void 0;
|
|
3127
|
-
}
|
|
3128
|
-
get file() {
|
|
3129
|
-
return this.inner.file ?? void 0;
|
|
3130
|
-
}
|
|
3131
|
-
get inlineDynamicImports() {
|
|
3132
|
-
return this.inner.inlineDynamicImports;
|
|
3133
|
-
}
|
|
3134
|
-
get externalLiveBindings() {
|
|
3135
|
-
return this.inner.externalLiveBindings;
|
|
3136
|
-
}
|
|
3137
|
-
get banner() {
|
|
3138
|
-
return normalizeAddon(this.outputOptions.banner);
|
|
3139
|
-
}
|
|
3140
|
-
get footer() {
|
|
3141
|
-
return normalizeAddon(this.outputOptions.footer);
|
|
3142
|
-
}
|
|
3143
|
-
get intro() {
|
|
3144
|
-
return normalizeAddon(this.outputOptions.intro);
|
|
3145
|
-
}
|
|
3146
|
-
get outro() {
|
|
3147
|
-
return normalizeAddon(this.outputOptions.outro);
|
|
3148
|
-
}
|
|
3149
|
-
get esModule() {
|
|
3150
|
-
return this.inner.esModule;
|
|
3151
|
-
}
|
|
3152
|
-
get extend() {
|
|
3153
|
-
return this.inner.extend;
|
|
3154
|
-
}
|
|
3155
|
-
get globals() {
|
|
3156
|
-
return this.inner.globals || this.outputOptions.globals;
|
|
3157
|
-
}
|
|
3158
|
-
get hashCharacters() {
|
|
3159
|
-
return this.inner.hashCharacters;
|
|
3160
|
-
}
|
|
3161
|
-
get sourcemapDebugIds() {
|
|
3162
|
-
return this.inner.sourcemapDebugIds;
|
|
3163
|
-
}
|
|
3164
|
-
get sourcemapIgnoreList() {
|
|
3165
|
-
return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
|
|
3166
|
-
}
|
|
3167
|
-
get sourcemapPathTransform() {
|
|
3168
|
-
return this.outputOptions.sourcemapPathTransform;
|
|
3169
|
-
}
|
|
3170
|
-
get minify() {
|
|
3171
|
-
return this.inner.minify;
|
|
3172
|
-
}
|
|
3173
|
-
get legalComments() {
|
|
3174
|
-
return this.inner.legalComments;
|
|
3175
|
-
}
|
|
3176
|
-
get polyfillRequire() {
|
|
3177
|
-
return this.inner.polyfillRequire;
|
|
3178
|
-
}
|
|
3179
|
-
get plugins() {
|
|
3180
|
-
return this.normalizedOutputPlugins;
|
|
3181
|
-
}
|
|
3182
|
-
get preserveModules() {
|
|
3183
|
-
return this.inner.preserveModules;
|
|
3184
|
-
}
|
|
3185
|
-
get preserveModulesRoot() {
|
|
3186
|
-
return this.inner.preserveModulesRoot;
|
|
3187
|
-
}
|
|
3188
|
-
get virtualDirname() {
|
|
3189
|
-
return this.inner.virtualDirname;
|
|
3190
|
-
}
|
|
3191
|
-
};
|
|
3192
|
-
function normalizeAddon(value) {
|
|
3193
|
-
if (typeof value === "function") return value;
|
|
3194
|
-
return () => value || "";
|
|
3195
|
-
}
|
|
3196
|
-
|
|
3197
|
-
//#endregion
|
|
3198
|
-
//#region src/utils/transform-to-rollup-output.ts
|
|
3199
|
-
function transformToRollupSourceMap(map) {
|
|
3200
|
-
const parsed = JSON.parse(map);
|
|
3201
|
-
const obj = {
|
|
3202
|
-
...parsed,
|
|
3203
|
-
toString() {
|
|
3204
|
-
return JSON.stringify(obj);
|
|
3205
|
-
},
|
|
3206
|
-
toUrl() {
|
|
3207
|
-
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
3208
|
-
}
|
|
3209
|
-
};
|
|
3210
|
-
return obj;
|
|
3211
|
-
}
|
|
3212
|
-
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
3213
|
-
const chunk = {
|
|
3214
|
-
type: "chunk",
|
|
3215
|
-
get code() {
|
|
3216
|
-
return bindingChunk.code;
|
|
3217
|
-
},
|
|
3218
|
-
fileName: bindingChunk.fileName,
|
|
3219
|
-
name: bindingChunk.name,
|
|
3220
|
-
get modules() {
|
|
3221
|
-
return transformChunkModules(bindingChunk.modules);
|
|
3222
|
-
},
|
|
3223
|
-
get imports() {
|
|
3224
|
-
return bindingChunk.imports;
|
|
3225
|
-
},
|
|
3226
|
-
get dynamicImports() {
|
|
3227
|
-
return bindingChunk.dynamicImports;
|
|
3228
|
-
},
|
|
3229
|
-
exports: bindingChunk.exports,
|
|
3230
|
-
isEntry: bindingChunk.isEntry,
|
|
3231
|
-
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
3232
|
-
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
3233
|
-
get moduleIds() {
|
|
3234
|
-
return bindingChunk.moduleIds;
|
|
3235
|
-
},
|
|
3236
|
-
get map() {
|
|
3237
|
-
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
3238
|
-
},
|
|
3239
|
-
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
3240
|
-
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
3241
|
-
};
|
|
3242
|
-
const cache = {};
|
|
3243
|
-
return new Proxy(chunk, {
|
|
3244
|
-
get(target, p) {
|
|
3245
|
-
if (p in cache) return cache[p];
|
|
3246
|
-
const value = target[p];
|
|
3247
|
-
cache[p] = value;
|
|
3248
|
-
return value;
|
|
3249
|
-
},
|
|
3250
|
-
set(target, p, newValue) {
|
|
3251
|
-
cache[p] = newValue;
|
|
3252
|
-
changed?.updated.add(bindingChunk.fileName);
|
|
3253
|
-
return true;
|
|
3254
|
-
},
|
|
3255
|
-
has(target, p) {
|
|
3256
|
-
if (p in cache) return true;
|
|
3257
|
-
return p in target;
|
|
3258
|
-
}
|
|
3259
|
-
});
|
|
3260
|
-
}
|
|
3261
|
-
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
3262
|
-
const asset = {
|
|
3263
|
-
type: "asset",
|
|
3264
|
-
fileName: bindingAsset.fileName,
|
|
3265
|
-
originalFileName: bindingAsset.originalFileName || null,
|
|
3266
|
-
originalFileNames: bindingAsset.originalFileNames,
|
|
3267
|
-
get source() {
|
|
3268
|
-
return transformAssetSource(bindingAsset.source);
|
|
3269
|
-
},
|
|
3270
|
-
name: bindingAsset.name ?? void 0,
|
|
3271
|
-
names: bindingAsset.names
|
|
3272
|
-
};
|
|
3273
|
-
const cache = {};
|
|
3274
|
-
return new Proxy(asset, {
|
|
3275
|
-
get(target, p) {
|
|
3276
|
-
if (p in cache) return cache[p];
|
|
3277
|
-
const value = target[p];
|
|
3278
|
-
cache[p] = value;
|
|
3279
|
-
return value;
|
|
3280
|
-
},
|
|
3281
|
-
set(target, p, newValue) {
|
|
3282
|
-
cache[p] = newValue;
|
|
3283
|
-
changed?.updated.add(bindingAsset.fileName);
|
|
3284
|
-
return true;
|
|
3285
|
-
}
|
|
3286
|
-
});
|
|
3287
|
-
}
|
|
3288
|
-
function transformToRollupOutput(output, changed) {
|
|
3289
|
-
handleOutputErrors(output);
|
|
3290
|
-
const { chunks, assets } = output;
|
|
3291
|
-
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
3292
|
-
}
|
|
3293
|
-
function handleOutputErrors(output) {
|
|
3294
|
-
const rawErrors = output.errors;
|
|
3295
|
-
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
3296
|
-
}
|
|
3297
|
-
function transformToOutputBundle(context, output, changed) {
|
|
3298
|
-
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
3299
|
-
return new Proxy(bundle, {
|
|
3300
|
-
set(_target, _p, _newValue, _receiver) {
|
|
3301
|
-
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
3302
|
-
Error.stackTraceLimit = 2;
|
|
3303
|
-
const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
|
|
3304
|
-
const stack = new Error(message).stack ?? message;
|
|
3305
|
-
Error.stackTraceLimit = originalStackTraceLimit;
|
|
3306
|
-
context.warn({
|
|
3307
|
-
message: stack,
|
|
3308
|
-
code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
|
|
3309
|
-
});
|
|
3310
|
-
return true;
|
|
3311
|
-
},
|
|
3312
|
-
deleteProperty(target, property) {
|
|
3313
|
-
if (typeof property === "string") changed.deleted.add(property);
|
|
3314
|
-
return true;
|
|
3315
|
-
}
|
|
3316
|
-
});
|
|
3042
|
+
function transformToOutputBundle(context, output, changed) {
|
|
3043
|
+
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
3044
|
+
return new Proxy(bundle, {
|
|
3045
|
+
set(_target, _p, _newValue, _receiver) {
|
|
3046
|
+
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
3047
|
+
Error.stackTraceLimit = 2;
|
|
3048
|
+
const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
|
|
3049
|
+
const stack = new Error(message).stack ?? message;
|
|
3050
|
+
Error.stackTraceLimit = originalStackTraceLimit;
|
|
3051
|
+
context.warn({
|
|
3052
|
+
message: stack,
|
|
3053
|
+
code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
|
|
3054
|
+
});
|
|
3055
|
+
return true;
|
|
3056
|
+
},
|
|
3057
|
+
deleteProperty(target, property) {
|
|
3058
|
+
if (typeof property === "string") changed.deleted.add(property);
|
|
3059
|
+
return true;
|
|
3060
|
+
}
|
|
3061
|
+
});
|
|
3317
3062
|
}
|
|
3318
3063
|
function collectChangedBundle(changed, bundle) {
|
|
3319
3064
|
const assets = [];
|
|
@@ -3339,7 +3084,7 @@ function collectChangedBundle(changed, bundle) {
|
|
|
3339
3084
|
facadeModuleId: item.facadeModuleId || void 0,
|
|
3340
3085
|
isDynamicEntry: item.isDynamicEntry,
|
|
3341
3086
|
moduleIds: item.moduleIds,
|
|
3342
|
-
map: bindingifySourcemap(item.map),
|
|
3087
|
+
map: bindingifySourcemap$1(item.map),
|
|
3343
3088
|
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
3344
3089
|
preliminaryFilename: item.preliminaryFileName
|
|
3345
3090
|
});
|
|
@@ -3359,7 +3104,7 @@ function bindingifyRenderStart(args$1) {
|
|
|
3359
3104
|
const { handler, meta } = normalizeHook(hook);
|
|
3360
3105
|
return {
|
|
3361
3106
|
plugin: async (ctx, opts) => {
|
|
3362
|
-
handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode),
|
|
3107
|
+
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));
|
|
3363
3108
|
},
|
|
3364
3109
|
meta: bindingifyPluginHookMeta(meta)
|
|
3365
3110
|
};
|
|
@@ -3371,13 +3116,13 @@ function bindingifyRenderChunk(args$1) {
|
|
|
3371
3116
|
return {
|
|
3372
3117
|
plugin: async (ctx, code, chunk, opts, meta$1) => {
|
|
3373
3118
|
if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
3374
|
-
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, transformRenderedChunk(chunk),
|
|
3119
|
+
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, transformRenderedChunk(chunk), args$1.pluginContextData.getOutputOptions(opts), args$1.pluginContextData.getRenderChunkMeta());
|
|
3375
3120
|
if (ret == null) return;
|
|
3376
3121
|
if (typeof ret === "string") return { code: ret };
|
|
3377
3122
|
if (!ret.map) return { code: ret.code };
|
|
3378
3123
|
return {
|
|
3379
3124
|
code: ret.code,
|
|
3380
|
-
map: bindingifySourcemap(ret.map)
|
|
3125
|
+
map: bindingifySourcemap$1(ret.map)
|
|
3381
3126
|
};
|
|
3382
3127
|
},
|
|
3383
3128
|
meta: bindingifyPluginHookMeta(meta),
|
|
@@ -3418,7 +3163,7 @@ function bindingifyGenerateBundle(args$1) {
|
|
|
3418
3163
|
};
|
|
3419
3164
|
const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
|
|
3420
3165
|
const output = transformToOutputBundle(context, bundle, changed);
|
|
3421
|
-
await handler.call(context,
|
|
3166
|
+
await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
|
|
3422
3167
|
return collectChangedBundle(changed, output);
|
|
3423
3168
|
},
|
|
3424
3169
|
meta: bindingifyPluginHookMeta(meta)
|
|
@@ -3436,7 +3181,7 @@ function bindingifyWriteBundle(args$1) {
|
|
|
3436
3181
|
};
|
|
3437
3182
|
const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
|
|
3438
3183
|
const output = transformToOutputBundle(context, bundle, changed);
|
|
3439
|
-
await handler.call(context,
|
|
3184
|
+
await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
|
|
3440
3185
|
return collectChangedBundle(changed, output);
|
|
3441
3186
|
},
|
|
3442
3187
|
meta: bindingifyPluginHookMeta(meta)
|
|
@@ -3711,23 +3456,284 @@ function wrapHandlers(plugin) {
|
|
|
3711
3456
|
}
|
|
3712
3457
|
|
|
3713
3458
|
//#endregion
|
|
3714
|
-
//#region src/
|
|
3715
|
-
var
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3459
|
+
//#region src/options/normalized-input-options.ts
|
|
3460
|
+
var NormalizedInputOptionsImpl = class {
|
|
3461
|
+
inner;
|
|
3462
|
+
constructor(inner, onLog) {
|
|
3463
|
+
this.onLog = onLog;
|
|
3464
|
+
this.inner = inner;
|
|
3465
|
+
}
|
|
3466
|
+
get shimMissingExports() {
|
|
3467
|
+
return this.inner.shimMissingExports;
|
|
3468
|
+
}
|
|
3469
|
+
get input() {
|
|
3470
|
+
return this.inner.input;
|
|
3471
|
+
}
|
|
3472
|
+
get cwd() {
|
|
3473
|
+
return this.inner.cwd ?? void 0;
|
|
3474
|
+
}
|
|
3475
|
+
get platform() {
|
|
3476
|
+
return this.inner.platform;
|
|
3477
|
+
}
|
|
3478
|
+
};
|
|
3479
|
+
|
|
3480
|
+
//#endregion
|
|
3481
|
+
//#region src/types/chunking-context.ts
|
|
3482
|
+
var ChunkingContextImpl = class {
|
|
3483
|
+
constructor(context) {
|
|
3484
|
+
this.context = context;
|
|
3485
|
+
}
|
|
3486
|
+
getModuleInfo(moduleId) {
|
|
3487
|
+
const bindingInfo = this.context.getModuleInfo(moduleId);
|
|
3488
|
+
if (bindingInfo) {
|
|
3489
|
+
const info = transformModuleInfo(bindingInfo, {
|
|
3490
|
+
moduleSideEffects: null,
|
|
3491
|
+
meta: {}
|
|
3492
|
+
});
|
|
3493
|
+
return info;
|
|
3494
|
+
}
|
|
3495
|
+
return null;
|
|
3496
|
+
}
|
|
3497
|
+
};
|
|
3498
|
+
|
|
3499
|
+
//#endregion
|
|
3500
|
+
//#region src/utils/bindingify-output-options.ts
|
|
3501
|
+
function bindingifyOutputOptions(outputOptions) {
|
|
3502
|
+
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;
|
|
3503
|
+
const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
|
|
3504
|
+
return {
|
|
3505
|
+
dir,
|
|
3506
|
+
file: file == null ? void 0 : file,
|
|
3507
|
+
format: bindingifyFormat(format),
|
|
3508
|
+
exports,
|
|
3509
|
+
hashCharacters,
|
|
3510
|
+
sourcemap: bindingifySourcemap(sourcemap),
|
|
3511
|
+
sourcemapDebugIds,
|
|
3512
|
+
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
3513
|
+
sourcemapPathTransform,
|
|
3514
|
+
banner: bindingifyAddon(banner),
|
|
3515
|
+
footer: bindingifyAddon(footer),
|
|
3516
|
+
intro: bindingifyAddon(intro),
|
|
3517
|
+
outro: bindingifyAddon(outro),
|
|
3518
|
+
extend: outputOptions.extend,
|
|
3519
|
+
globals,
|
|
3520
|
+
esModule,
|
|
3521
|
+
name,
|
|
3522
|
+
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
3523
|
+
entryFileNames,
|
|
3524
|
+
chunkFileNames,
|
|
3525
|
+
cssEntryFileNames,
|
|
3526
|
+
cssChunkFileNames,
|
|
3527
|
+
plugins: [],
|
|
3528
|
+
minify: outputOptions.minify,
|
|
3529
|
+
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
3530
|
+
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
3531
|
+
advancedChunks,
|
|
3532
|
+
polyfillRequire: outputOptions.polyfillRequire,
|
|
3533
|
+
sanitizeFileName,
|
|
3534
|
+
preserveModules,
|
|
3535
|
+
virtualDirname,
|
|
3536
|
+
legalComments,
|
|
3537
|
+
preserveModulesRoot
|
|
3538
|
+
};
|
|
3539
|
+
}
|
|
3540
|
+
function bindingifyAddon(configAddon) {
|
|
3541
|
+
return async (chunk) => {
|
|
3542
|
+
if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
|
|
3543
|
+
return configAddon || "";
|
|
3544
|
+
};
|
|
3545
|
+
}
|
|
3546
|
+
function bindingifyFormat(format) {
|
|
3547
|
+
switch (format) {
|
|
3548
|
+
case void 0:
|
|
3549
|
+
case "es":
|
|
3550
|
+
case "esm":
|
|
3551
|
+
case "module": return "es";
|
|
3552
|
+
case "cjs":
|
|
3553
|
+
case "commonjs": return "cjs";
|
|
3554
|
+
case "iife": return "iife";
|
|
3555
|
+
case "umd": return "umd";
|
|
3556
|
+
default: unimplemented(`output.format: ${format}`);
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
function bindingifySourcemap(sourcemap) {
|
|
3560
|
+
switch (sourcemap) {
|
|
3561
|
+
case true: return "file";
|
|
3562
|
+
case "inline": return "inline";
|
|
3563
|
+
case false:
|
|
3564
|
+
case void 0: return void 0;
|
|
3565
|
+
case "hidden": return "hidden";
|
|
3566
|
+
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
3570
|
+
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
3571
|
+
}
|
|
3572
|
+
function bindingifyAssetFilenames(assetFileNames) {
|
|
3573
|
+
if (typeof assetFileNames === "function") return (asset) => {
|
|
3574
|
+
return assetFileNames({
|
|
3575
|
+
names: asset.names,
|
|
3576
|
+
originalFileNames: asset.originalFileNames,
|
|
3577
|
+
source: transformAssetSource(asset.source),
|
|
3578
|
+
type: "asset"
|
|
3579
|
+
});
|
|
3580
|
+
};
|
|
3581
|
+
return assetFileNames;
|
|
3582
|
+
}
|
|
3583
|
+
function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
|
|
3584
|
+
if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
|
|
3585
|
+
else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
|
|
3586
|
+
return manualChunks(moduleId, { getModuleInfo: (id) => ctx.getModuleInfo(id) });
|
|
3587
|
+
} }] };
|
|
3588
|
+
if (advancedChunks == null) return void 0;
|
|
3589
|
+
const { groups,...restAdvancedChunks } = advancedChunks;
|
|
3590
|
+
return {
|
|
3591
|
+
...restAdvancedChunks,
|
|
3592
|
+
groups: groups?.map((group) => {
|
|
3593
|
+
const { name,...restGroup } = group;
|
|
3594
|
+
return {
|
|
3595
|
+
...restGroup,
|
|
3596
|
+
name: typeof name === "function" ? (id, ctx) => name(id, new ChunkingContextImpl(ctx)) : name
|
|
3597
|
+
};
|
|
3598
|
+
})
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3602
|
+
//#endregion
|
|
3603
|
+
//#region src/options/normalized-output-options.ts
|
|
3604
|
+
var NormalizedOutputOptionsImpl = class {
|
|
3605
|
+
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
3606
|
+
this.inner = inner;
|
|
3607
|
+
this.outputOptions = outputOptions;
|
|
3608
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3609
|
+
}
|
|
3610
|
+
get dir() {
|
|
3611
|
+
return this.inner.dir ?? void 0;
|
|
3612
|
+
}
|
|
3613
|
+
get entryFileNames() {
|
|
3614
|
+
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
3615
|
+
}
|
|
3616
|
+
get chunkFileNames() {
|
|
3617
|
+
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3618
|
+
}
|
|
3619
|
+
get assetFileNames() {
|
|
3620
|
+
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
3621
|
+
}
|
|
3622
|
+
get format() {
|
|
3623
|
+
return this.inner.format;
|
|
3624
|
+
}
|
|
3625
|
+
get exports() {
|
|
3626
|
+
return this.inner.exports;
|
|
3627
|
+
}
|
|
3628
|
+
get sourcemap() {
|
|
3629
|
+
return this.inner.sourcemap;
|
|
3630
|
+
}
|
|
3631
|
+
get cssEntryFileNames() {
|
|
3632
|
+
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
3633
|
+
}
|
|
3634
|
+
get cssChunkFileNames() {
|
|
3635
|
+
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
3636
|
+
}
|
|
3637
|
+
get shimMissingExports() {
|
|
3638
|
+
return this.inner.shimMissingExports;
|
|
3639
|
+
}
|
|
3640
|
+
get name() {
|
|
3641
|
+
return this.inner.name ?? void 0;
|
|
3642
|
+
}
|
|
3643
|
+
get file() {
|
|
3644
|
+
return this.inner.file ?? void 0;
|
|
3645
|
+
}
|
|
3646
|
+
get inlineDynamicImports() {
|
|
3647
|
+
return this.inner.inlineDynamicImports;
|
|
3648
|
+
}
|
|
3649
|
+
get externalLiveBindings() {
|
|
3650
|
+
return this.inner.externalLiveBindings;
|
|
3651
|
+
}
|
|
3652
|
+
get banner() {
|
|
3653
|
+
return normalizeAddon(this.outputOptions.banner);
|
|
3654
|
+
}
|
|
3655
|
+
get footer() {
|
|
3656
|
+
return normalizeAddon(this.outputOptions.footer);
|
|
3657
|
+
}
|
|
3658
|
+
get intro() {
|
|
3659
|
+
return normalizeAddon(this.outputOptions.intro);
|
|
3660
|
+
}
|
|
3661
|
+
get outro() {
|
|
3662
|
+
return normalizeAddon(this.outputOptions.outro);
|
|
3663
|
+
}
|
|
3664
|
+
get esModule() {
|
|
3665
|
+
return this.inner.esModule;
|
|
3666
|
+
}
|
|
3667
|
+
get extend() {
|
|
3668
|
+
return this.inner.extend;
|
|
3669
|
+
}
|
|
3670
|
+
get globals() {
|
|
3671
|
+
return this.inner.globals || this.outputOptions.globals;
|
|
3672
|
+
}
|
|
3673
|
+
get hashCharacters() {
|
|
3674
|
+
return this.inner.hashCharacters;
|
|
3675
|
+
}
|
|
3676
|
+
get sourcemapDebugIds() {
|
|
3677
|
+
return this.inner.sourcemapDebugIds;
|
|
3678
|
+
}
|
|
3679
|
+
get sourcemapIgnoreList() {
|
|
3680
|
+
return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
|
|
3681
|
+
}
|
|
3682
|
+
get sourcemapPathTransform() {
|
|
3683
|
+
return this.outputOptions.sourcemapPathTransform;
|
|
3684
|
+
}
|
|
3685
|
+
get minify() {
|
|
3686
|
+
return this.inner.minify;
|
|
3687
|
+
}
|
|
3688
|
+
get legalComments() {
|
|
3689
|
+
return this.inner.legalComments;
|
|
3690
|
+
}
|
|
3691
|
+
get polyfillRequire() {
|
|
3692
|
+
return this.inner.polyfillRequire;
|
|
3693
|
+
}
|
|
3694
|
+
get plugins() {
|
|
3695
|
+
return this.normalizedOutputPlugins;
|
|
3696
|
+
}
|
|
3697
|
+
get preserveModules() {
|
|
3698
|
+
return this.inner.preserveModules;
|
|
3699
|
+
}
|
|
3700
|
+
get preserveModulesRoot() {
|
|
3701
|
+
return this.inner.preserveModulesRoot;
|
|
3702
|
+
}
|
|
3703
|
+
get virtualDirname() {
|
|
3704
|
+
return this.inner.virtualDirname;
|
|
3705
|
+
}
|
|
3706
|
+
};
|
|
3707
|
+
function normalizeAddon(value) {
|
|
3708
|
+
if (typeof value === "function") return value;
|
|
3709
|
+
return () => value || "";
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
//#endregion
|
|
3713
|
+
//#region src/plugin/plugin-context-data.ts
|
|
3714
|
+
var PluginContextData = class {
|
|
3715
|
+
moduleOptionMap = /* @__PURE__ */ new Map();
|
|
3716
|
+
resolveOptionsMap = /* @__PURE__ */ new Map();
|
|
3717
|
+
loadModulePromiseMap = /* @__PURE__ */ new Map();
|
|
3718
|
+
loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
|
|
3719
|
+
renderedChunkMeta = null;
|
|
3720
|
+
normalizedInputOptions = null;
|
|
3721
|
+
normalizedOutputOptions = null;
|
|
3722
|
+
constructor(onLog, outputOptions, normalizedOutputPlugins) {
|
|
3723
|
+
this.onLog = onLog;
|
|
3724
|
+
this.outputOptions = outputOptions;
|
|
3725
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3726
|
+
}
|
|
3727
|
+
updateModuleOption(id, option) {
|
|
3728
|
+
const existing = this.moduleOptionMap.get(id);
|
|
3729
|
+
if (existing) {
|
|
3730
|
+
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
3731
|
+
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
3732
|
+
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
3733
|
+
} else {
|
|
3734
|
+
this.moduleOptionMap.set(id, option);
|
|
3735
|
+
return option;
|
|
3736
|
+
}
|
|
3731
3737
|
return existing;
|
|
3732
3738
|
}
|
|
3733
3739
|
getModuleOption(id) {
|
|
@@ -3788,6 +3794,14 @@ var PluginContextData = class {
|
|
|
3788
3794
|
getRenderChunkMeta() {
|
|
3789
3795
|
return this.renderedChunkMeta;
|
|
3790
3796
|
}
|
|
3797
|
+
getInputOptions(opts) {
|
|
3798
|
+
this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
|
|
3799
|
+
return this.normalizedInputOptions;
|
|
3800
|
+
}
|
|
3801
|
+
getOutputOptions(opts) {
|
|
3802
|
+
this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
|
|
3803
|
+
return this.normalizedOutputOptions;
|
|
3804
|
+
}
|
|
3791
3805
|
markModuleLoaded(id, _success) {
|
|
3792
3806
|
const resolve = this.loadModulePromiseResolveFnMap.get(id);
|
|
3793
3807
|
if (resolve) resolve();
|
|
@@ -3799,28 +3813,16 @@ var PluginContextData = class {
|
|
|
3799
3813
|
}
|
|
3800
3814
|
};
|
|
3801
3815
|
|
|
3802
|
-
//#endregion
|
|
3803
|
-
//#region src/utils/normalize-string-or-regex.ts
|
|
3804
|
-
function normalizedStringOrRegex(pattern) {
|
|
3805
|
-
if (!pattern) return void 0;
|
|
3806
|
-
if (!isReadonlyArray(pattern)) return [pattern];
|
|
3807
|
-
return pattern;
|
|
3808
|
-
}
|
|
3809
|
-
function isReadonlyArray(input) {
|
|
3810
|
-
return Array.isArray(input);
|
|
3811
|
-
}
|
|
3812
|
-
|
|
3813
3816
|
//#endregion
|
|
3814
3817
|
//#region src/utils/bindingify-input-options.ts
|
|
3815
3818
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
3816
|
-
const pluginContextData = new PluginContextData();
|
|
3819
|
+
const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
|
|
3817
3820
|
const plugins = rawPlugins.map((plugin) => {
|
|
3818
3821
|
if ("_parallel" in plugin) return void 0;
|
|
3819
3822
|
if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
|
|
3820
3823
|
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
3821
3824
|
});
|
|
3822
|
-
const { jsx,
|
|
3823
|
-
const transform = inputOptions.transform || jsxTransform;
|
|
3825
|
+
const { jsx, transform } = bindingifyJsx(onLog, inputOptions.jsx, inputOptions.transform);
|
|
3824
3826
|
return {
|
|
3825
3827
|
input: bindingifyInput(inputOptions.input),
|
|
3826
3828
|
plugins,
|
|
@@ -3864,7 +3866,8 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
|
|
|
3864
3866
|
debug: inputOptions.debug,
|
|
3865
3867
|
invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
|
|
3866
3868
|
markModuleLoaded: pluginContextData.markModuleLoaded.bind(pluginContextData),
|
|
3867
|
-
preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures)
|
|
3869
|
+
preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
|
|
3870
|
+
optimization: inputOptions.optimization
|
|
3868
3871
|
};
|
|
3869
3872
|
}
|
|
3870
3873
|
function bindingifyHmr(hmr) {
|
|
@@ -3954,24 +3957,45 @@ function bindingifyInput(input) {
|
|
|
3954
3957
|
};
|
|
3955
3958
|
});
|
|
3956
3959
|
}
|
|
3957
|
-
function bindingifyJsx(input) {
|
|
3960
|
+
function bindingifyJsx(onLog, input, transform) {
|
|
3961
|
+
if (transform?.jsx) {
|
|
3962
|
+
if (input !== void 0) onLog(LOG_LEVEL_WARN, logDuplicateJsxConfig());
|
|
3963
|
+
return { transform };
|
|
3964
|
+
}
|
|
3958
3965
|
if (typeof input === "object") {
|
|
3959
|
-
if (input.mode === "preserve") return {
|
|
3966
|
+
if (input.mode === "preserve") return {
|
|
3967
|
+
jsx: BindingJsx.Preserve,
|
|
3968
|
+
transform
|
|
3969
|
+
};
|
|
3960
3970
|
const mode = input.mode ?? "automatic";
|
|
3961
|
-
|
|
3971
|
+
transform ??= {};
|
|
3972
|
+
transform.jsx = {
|
|
3962
3973
|
runtime: mode,
|
|
3963
3974
|
pragma: input.factory,
|
|
3964
3975
|
pragmaFrag: input.fragment,
|
|
3965
3976
|
importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0
|
|
3966
|
-
}
|
|
3977
|
+
};
|
|
3978
|
+
return { transform };
|
|
3967
3979
|
}
|
|
3980
|
+
let jsx;
|
|
3968
3981
|
switch (input) {
|
|
3969
|
-
case false:
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
case "
|
|
3973
|
-
|
|
3982
|
+
case false:
|
|
3983
|
+
jsx = BindingJsx.Disable;
|
|
3984
|
+
break;
|
|
3985
|
+
case "react":
|
|
3986
|
+
jsx = BindingJsx.React;
|
|
3987
|
+
break;
|
|
3988
|
+
case "react-jsx":
|
|
3989
|
+
jsx = BindingJsx.ReactJsx;
|
|
3990
|
+
break;
|
|
3991
|
+
case "preserve":
|
|
3992
|
+
jsx = BindingJsx.Preserve;
|
|
3993
|
+
break;
|
|
3974
3994
|
}
|
|
3995
|
+
return {
|
|
3996
|
+
jsx,
|
|
3997
|
+
transform
|
|
3998
|
+
};
|
|
3975
3999
|
}
|
|
3976
4000
|
function bindingifyWatch(watch$1) {
|
|
3977
4001
|
if (watch$1) return {
|
|
@@ -4021,323 +4045,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
|
|
|
4021
4045
|
};
|
|
4022
4046
|
}
|
|
4023
4047
|
|
|
4024
|
-
//#endregion
|
|
4025
|
-
//#region src/utils/plugin/index.ts
|
|
4026
|
-
const isPluginHookName = function() {
|
|
4027
|
-
const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
|
|
4028
|
-
return function isPluginHookName$1(hookName) {
|
|
4029
|
-
return PLUGIN_HOOK_NAMES_SET.has(hookName);
|
|
4030
|
-
};
|
|
4031
|
-
}();
|
|
4032
|
-
|
|
4033
|
-
//#endregion
|
|
4034
|
-
//#region src/utils/compose-js-plugins.ts
|
|
4035
|
-
const unsupportedHookName = [
|
|
4036
|
-
"augmentChunkHash",
|
|
4037
|
-
"generateBundle",
|
|
4038
|
-
"moduleParsed",
|
|
4039
|
-
"onLog",
|
|
4040
|
-
"options",
|
|
4041
|
-
"outputOptions",
|
|
4042
|
-
"renderError",
|
|
4043
|
-
"renderStart",
|
|
4044
|
-
"resolveDynamicImport",
|
|
4045
|
-
"writeBundle"
|
|
4046
|
-
];
|
|
4047
|
-
const unsupportedHooks = new Set(unsupportedHookName);
|
|
4048
|
-
function isUnsupportedHooks(hookName) {
|
|
4049
|
-
return unsupportedHooks.has(hookName);
|
|
4050
|
-
}
|
|
4051
|
-
function createComposedPlugin(plugins) {
|
|
4052
|
-
const names = [];
|
|
4053
|
-
const batchedHooks = {};
|
|
4054
|
-
plugins.forEach((plugin, index) => {
|
|
4055
|
-
const pluginName = plugin.name || `Anonymous(index: ${index})`;
|
|
4056
|
-
names.push(pluginName);
|
|
4057
|
-
t(plugin).forEach((pluginProp) => {
|
|
4058
|
-
if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
|
|
4059
|
-
if (!isPluginHookName(pluginProp)) return;
|
|
4060
|
-
switch (pluginProp) {
|
|
4061
|
-
case "buildStart": {
|
|
4062
|
-
const handlers = batchedHooks.buildStart ?? [];
|
|
4063
|
-
batchedHooks.buildStart = handlers;
|
|
4064
|
-
if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
|
|
4065
|
-
break;
|
|
4066
|
-
}
|
|
4067
|
-
case "load": {
|
|
4068
|
-
const handlers = batchedHooks.load ?? [];
|
|
4069
|
-
batchedHooks.load = handlers;
|
|
4070
|
-
if (plugin.load) handlers.push([plugin.load, plugin]);
|
|
4071
|
-
break;
|
|
4072
|
-
}
|
|
4073
|
-
case "transform": {
|
|
4074
|
-
const handlers = batchedHooks.transform ?? [];
|
|
4075
|
-
batchedHooks.transform = handlers;
|
|
4076
|
-
if (plugin.transform) handlers.push([plugin.transform, plugin]);
|
|
4077
|
-
break;
|
|
4078
|
-
}
|
|
4079
|
-
case "resolveId": {
|
|
4080
|
-
const handlers = batchedHooks.resolveId ?? [];
|
|
4081
|
-
batchedHooks.resolveId = handlers;
|
|
4082
|
-
if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
|
|
4083
|
-
break;
|
|
4084
|
-
}
|
|
4085
|
-
case "buildEnd": {
|
|
4086
|
-
const handlers = batchedHooks.buildEnd ?? [];
|
|
4087
|
-
batchedHooks.buildEnd = handlers;
|
|
4088
|
-
if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
|
|
4089
|
-
break;
|
|
4090
|
-
}
|
|
4091
|
-
case "renderChunk": {
|
|
4092
|
-
const handlers = batchedHooks.renderChunk ?? [];
|
|
4093
|
-
batchedHooks.renderChunk = handlers;
|
|
4094
|
-
if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
|
|
4095
|
-
break;
|
|
4096
|
-
}
|
|
4097
|
-
case "banner":
|
|
4098
|
-
case "footer":
|
|
4099
|
-
case "intro":
|
|
4100
|
-
case "outro": {
|
|
4101
|
-
const hook = plugin[pluginProp];
|
|
4102
|
-
if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
|
|
4103
|
-
break;
|
|
4104
|
-
}
|
|
4105
|
-
case "closeBundle": {
|
|
4106
|
-
const handlers = batchedHooks.closeBundle ?? [];
|
|
4107
|
-
batchedHooks.closeBundle = handlers;
|
|
4108
|
-
if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
|
|
4109
|
-
break;
|
|
4110
|
-
}
|
|
4111
|
-
case "watchChange": {
|
|
4112
|
-
const handlers = batchedHooks.watchChange ?? [];
|
|
4113
|
-
batchedHooks.watchChange = handlers;
|
|
4114
|
-
if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
|
|
4115
|
-
break;
|
|
4116
|
-
}
|
|
4117
|
-
case "closeWatcher": {
|
|
4118
|
-
const handlers = batchedHooks.closeWatcher ?? [];
|
|
4119
|
-
batchedHooks.closeWatcher = handlers;
|
|
4120
|
-
if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
|
|
4121
|
-
break;
|
|
4122
|
-
}
|
|
4123
|
-
default: {}
|
|
4124
|
-
}
|
|
4125
|
-
});
|
|
4126
|
-
});
|
|
4127
|
-
const composed = { name: `Composed(${names.join(", ")})` };
|
|
4128
|
-
const createFixedPluginResolveFnMap = /* @__PURE__ */ new Map();
|
|
4129
|
-
function applyFixedPluginResolveFn(ctx, plugin) {
|
|
4130
|
-
const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
|
|
4131
|
-
if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
|
|
4132
|
-
return ctx;
|
|
4133
|
-
}
|
|
4134
|
-
if (batchedHooks.resolveId) {
|
|
4135
|
-
const batchedHandlers = batchedHooks.resolveId;
|
|
4136
|
-
const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
|
|
4137
|
-
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
4138
|
-
const [_handler, plugin] = batchedHandlers[handlerIdx];
|
|
4139
|
-
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
4140
|
-
const createFixedPluginResolveFn = (ctx, resolve) => {
|
|
4141
|
-
return (source, importer, rawContextResolveOptions) => {
|
|
4142
|
-
const contextResolveOptions = rawContextResolveOptions ?? {};
|
|
4143
|
-
if (contextResolveOptions.skipSelf) {
|
|
4144
|
-
contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
|
|
4145
|
-
contextResolveOptions.skipSelf = false;
|
|
4146
|
-
}
|
|
4147
|
-
return resolve(source, importer, contextResolveOptions);
|
|
4148
|
-
};
|
|
4149
|
-
};
|
|
4150
|
-
createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
|
|
4151
|
-
}
|
|
4152
|
-
composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
|
|
4153
|
-
const hookResolveIdOptions = rawHookResolveIdOptions;
|
|
4154
|
-
const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
|
|
4155
|
-
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
4156
|
-
const [handler, plugin] = batchedHandlers[handlerIdx];
|
|
4157
|
-
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
4158
|
-
if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
|
|
4159
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4160
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
|
|
4161
|
-
if (!isNullish(result)) return result;
|
|
4162
|
-
}
|
|
4163
|
-
};
|
|
4164
|
-
}
|
|
4165
|
-
t(batchedHooks).forEach((hookName) => {
|
|
4166
|
-
switch (hookName) {
|
|
4167
|
-
case "resolveId": break;
|
|
4168
|
-
case "buildStart": {
|
|
4169
|
-
if (batchedHooks.buildStart) {
|
|
4170
|
-
const batchedHandlers = batchedHooks.buildStart;
|
|
4171
|
-
composed.buildStart = async function(options) {
|
|
4172
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4173
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4174
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
|
|
4175
|
-
}));
|
|
4176
|
-
};
|
|
4177
|
-
}
|
|
4178
|
-
break;
|
|
4179
|
-
}
|
|
4180
|
-
case "load": {
|
|
4181
|
-
if (batchedHooks.load) {
|
|
4182
|
-
const batchedHandlers = batchedHooks.load;
|
|
4183
|
-
composed.load = async function(id) {
|
|
4184
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4185
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4186
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id);
|
|
4187
|
-
if (!isNullish(result)) return result;
|
|
4188
|
-
}
|
|
4189
|
-
};
|
|
4190
|
-
}
|
|
4191
|
-
break;
|
|
4192
|
-
}
|
|
4193
|
-
case "transform": {
|
|
4194
|
-
if (batchedHooks.transform) {
|
|
4195
|
-
const batchedHandlers = batchedHooks.transform;
|
|
4196
|
-
composed.transform = async function(initialCode, id, moduleType) {
|
|
4197
|
-
let code = initialCode;
|
|
4198
|
-
let moduleSideEffects = void 0;
|
|
4199
|
-
function updateOutput(newCode, newModuleSideEffects) {
|
|
4200
|
-
code = newCode;
|
|
4201
|
-
moduleSideEffects = newModuleSideEffects ?? void 0;
|
|
4202
|
-
}
|
|
4203
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4204
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4205
|
-
this.getCombinedSourcemap = () => {
|
|
4206
|
-
throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
|
|
4207
|
-
};
|
|
4208
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
|
|
4209
|
-
if (!isNullish(result)) {
|
|
4210
|
-
if (typeof result === "string") updateOutput(result);
|
|
4211
|
-
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
4212
|
-
}
|
|
4213
|
-
}
|
|
4214
|
-
return {
|
|
4215
|
-
code,
|
|
4216
|
-
moduleSideEffects
|
|
4217
|
-
};
|
|
4218
|
-
};
|
|
4219
|
-
}
|
|
4220
|
-
break;
|
|
4221
|
-
}
|
|
4222
|
-
case "buildEnd": {
|
|
4223
|
-
if (batchedHooks.buildEnd) {
|
|
4224
|
-
const batchedHandlers = batchedHooks.buildEnd;
|
|
4225
|
-
composed.buildEnd = async function(err) {
|
|
4226
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4227
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4228
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
|
|
4229
|
-
}));
|
|
4230
|
-
};
|
|
4231
|
-
}
|
|
4232
|
-
break;
|
|
4233
|
-
}
|
|
4234
|
-
case "renderChunk": {
|
|
4235
|
-
if (batchedHooks.renderChunk) {
|
|
4236
|
-
const batchedHandlers = batchedHooks.renderChunk;
|
|
4237
|
-
composed.renderChunk = async function(code, chunk, options, meta) {
|
|
4238
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4239
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4240
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, chunk, options, meta);
|
|
4241
|
-
if (!isNullish(result)) return result;
|
|
4242
|
-
}
|
|
4243
|
-
};
|
|
4244
|
-
}
|
|
4245
|
-
break;
|
|
4246
|
-
}
|
|
4247
|
-
case "banner":
|
|
4248
|
-
case "footer":
|
|
4249
|
-
case "intro":
|
|
4250
|
-
case "outro": {
|
|
4251
|
-
const hooks = batchedHooks[hookName];
|
|
4252
|
-
if (hooks?.length) composed[hookName] = async function(chunk) {
|
|
4253
|
-
const ret = [];
|
|
4254
|
-
for (const [hook, plugin] of hooks) {
|
|
4255
|
-
const { handler } = normalizeHook(hook);
|
|
4256
|
-
ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
|
|
4257
|
-
}
|
|
4258
|
-
return ret.join("\n");
|
|
4259
|
-
};
|
|
4260
|
-
break;
|
|
4261
|
-
}
|
|
4262
|
-
case "closeBundle": {
|
|
4263
|
-
if (batchedHooks.closeBundle) {
|
|
4264
|
-
const batchedHandlers = batchedHooks.closeBundle;
|
|
4265
|
-
composed.closeBundle = async function() {
|
|
4266
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4267
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4268
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
4269
|
-
}));
|
|
4270
|
-
};
|
|
4271
|
-
}
|
|
4272
|
-
break;
|
|
4273
|
-
}
|
|
4274
|
-
case "watchChange": {
|
|
4275
|
-
if (batchedHooks.watchChange) {
|
|
4276
|
-
const batchedHandlers = batchedHooks.watchChange;
|
|
4277
|
-
composed.watchChange = async function(id, event) {
|
|
4278
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4279
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4280
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id, event);
|
|
4281
|
-
}));
|
|
4282
|
-
};
|
|
4283
|
-
}
|
|
4284
|
-
break;
|
|
4285
|
-
}
|
|
4286
|
-
case "closeWatcher": {
|
|
4287
|
-
if (batchedHooks.closeWatcher) {
|
|
4288
|
-
const batchedHandlers = batchedHooks.closeWatcher;
|
|
4289
|
-
composed.closeWatcher = async function() {
|
|
4290
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4291
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4292
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
4293
|
-
}));
|
|
4294
|
-
};
|
|
4295
|
-
}
|
|
4296
|
-
break;
|
|
4297
|
-
}
|
|
4298
|
-
default: {}
|
|
4299
|
-
}
|
|
4300
|
-
});
|
|
4301
|
-
return composed;
|
|
4302
|
-
}
|
|
4303
|
-
function isComposablePlugin(plugin) {
|
|
4304
|
-
if (plugin instanceof BuiltinPlugin) return false;
|
|
4305
|
-
if ("_parallel" in plugin) return false;
|
|
4306
|
-
const hasNotComposablePattern = t(plugin).some((hookName) => {
|
|
4307
|
-
if (!isPluginHookName(hookName)) return false;
|
|
4308
|
-
const OK_TO_COMPOSE = false;
|
|
4309
|
-
if (isUnsupportedHooks(hookName)) return true;
|
|
4310
|
-
if (plugin[hookName]) {
|
|
4311
|
-
const { meta } = normalizeHook(plugin[hookName]);
|
|
4312
|
-
if (meta.order === "pre" || meta.order === "post") return true;
|
|
4313
|
-
}
|
|
4314
|
-
return OK_TO_COMPOSE;
|
|
4315
|
-
});
|
|
4316
|
-
if (hasNotComposablePattern) return false;
|
|
4317
|
-
return true;
|
|
4318
|
-
}
|
|
4319
|
-
function composeJsPlugins(plugins) {
|
|
4320
|
-
const newPlugins = [];
|
|
4321
|
-
const toBeComposed = [];
|
|
4322
|
-
plugins.forEach((plugin) => {
|
|
4323
|
-
if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
|
|
4324
|
-
else {
|
|
4325
|
-
if (toBeComposed.length > 0) {
|
|
4326
|
-
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
4327
|
-
else newPlugins.push(toBeComposed[0]);
|
|
4328
|
-
toBeComposed.length = 0;
|
|
4329
|
-
}
|
|
4330
|
-
newPlugins.push(plugin);
|
|
4331
|
-
}
|
|
4332
|
-
});
|
|
4333
|
-
if (toBeComposed.length > 0) {
|
|
4334
|
-
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
4335
|
-
else newPlugins.push(toBeComposed[0]);
|
|
4336
|
-
toBeComposed.length = 0;
|
|
4337
|
-
}
|
|
4338
|
-
return newPlugins;
|
|
4339
|
-
}
|
|
4340
|
-
|
|
4341
4048
|
//#endregion
|
|
4342
4049
|
//#region src/utils/initialize-parallel-plugins.ts
|
|
4343
4050
|
async function initializeParallelPlugins(plugins) {
|
|
@@ -4414,7 +4121,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
|
|
|
4414
4121
|
...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
|
|
4415
4122
|
...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
|
|
4416
4123
|
];
|
|
4417
|
-
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
4418
4124
|
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
4419
4125
|
try {
|
|
4420
4126
|
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
@@ -4684,4 +4390,4 @@ function defineConfig(config) {
|
|
|
4684
4390
|
const VERSION = version;
|
|
4685
4391
|
|
|
4686
4392
|
//#endregion
|
|
4687
|
-
export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin,
|
|
4393
|
+
export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, 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 };
|