rolldown 1.0.0-beta.22 → 1.0.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.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.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/shared/{binding-B8kHDLfO.d.mts → binding-CMKStSph.d.cts} +4 -14
- package/dist/shared/{binding-CbR_BHh9.d.cts → binding-DB58iXP8.d.mts} +4 -14
- package/dist/shared/{define-config-Czc3unFy.d.mts → define-config-BRkYSF9E.d.cts} +12 -22
- package/dist/shared/{define-config-DZVEpUTF.d.cts → define-config-CyRbZDRR.d.mts} +12 -22
- package/dist/shared/{load-config-gtAGhZYG.mjs → load-config-CTdjFUJH.mjs} +1 -1
- package/dist/shared/{load-config-DPnW1OC0.cjs → load-config-n-iiDvYj.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/{src-9_Ra3A9D.cjs → src-D6QrbVqq.cjs} +327 -654
- package/dist/shared/{src-CJvC869N.mjs → src-DgdMNl-3.mjs} +427 -748
- package/package.json +16 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
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-DmWy-n6o.mjs";
|
|
2
|
-
import { arraify,
|
|
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,7 +8,7 @@ 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.23";
|
|
12
12
|
var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
@@ -51,8 +51,8 @@ function reporterPlugin(config) {
|
|
|
51
51
|
function manifestPlugin(config) {
|
|
52
52
|
return new BuiltinPlugin("builtin:manifest", config);
|
|
53
53
|
}
|
|
54
|
-
function wasmHelperPlugin() {
|
|
55
|
-
return new BuiltinPlugin("builtin:wasm-helper");
|
|
54
|
+
function wasmHelperPlugin(config) {
|
|
55
|
+
return new BuiltinPlugin("builtin:wasm-helper", config);
|
|
56
56
|
}
|
|
57
57
|
function wasmFallbackPlugin() {
|
|
58
58
|
const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
|
|
@@ -2254,41 +2254,9 @@ function getJsonSchema() {
|
|
|
2254
2254
|
return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
|
|
2255
2255
|
}
|
|
2256
2256
|
|
|
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
2257
|
//#endregion
|
|
2290
2258
|
//#region src/types/sourcemap.ts
|
|
2291
|
-
function bindingifySourcemap(map) {
|
|
2259
|
+
function bindingifySourcemap$1(map) {
|
|
2292
2260
|
if (map == null) return;
|
|
2293
2261
|
return { inner: typeof map === "string" ? map : {
|
|
2294
2262
|
file: map.file ?? void 0,
|
|
@@ -2404,8 +2372,8 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
|
2404
2372
|
//#endregion
|
|
2405
2373
|
//#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
|
|
2406
2374
|
function u$1(o, n, a) {
|
|
2407
|
-
let t
|
|
2408
|
-
return a === void 0 ? t
|
|
2375
|
+
let t = (r) => o(r, ...n);
|
|
2376
|
+
return a === void 0 ? t : Object.assign(t, {
|
|
2409
2377
|
lazy: a,
|
|
2410
2378
|
lazyArgs: n
|
|
2411
2379
|
});
|
|
@@ -2425,18 +2393,12 @@ function u(r, n, o) {
|
|
|
2425
2393
|
function d(...r) {
|
|
2426
2394
|
return u(i, r);
|
|
2427
2395
|
}
|
|
2428
|
-
var i = (r, t
|
|
2396
|
+
var i = (r, t) => {
|
|
2429
2397
|
let a = [[], []];
|
|
2430
|
-
for (let [o, e] of r.entries()) t
|
|
2398
|
+
for (let [o, e] of r.entries()) t(e, o, r) ? a[0].push(e) : a[1].push(e);
|
|
2431
2399
|
return a;
|
|
2432
2400
|
};
|
|
2433
2401
|
|
|
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
2402
|
//#endregion
|
|
2441
2403
|
//#region src/plugin/bindingify-hook-filter.ts
|
|
2442
2404
|
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
@@ -2741,7 +2703,7 @@ function bindingifyBuildStart(args$1) {
|
|
|
2741
2703
|
const { handler, meta } = normalizeHook(hook);
|
|
2742
2704
|
return {
|
|
2743
2705
|
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),
|
|
2706
|
+
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
2707
|
},
|
|
2746
2708
|
meta: bindingifyPluginHookMeta(meta)
|
|
2747
2709
|
};
|
|
@@ -2764,12 +2726,10 @@ function bindingifyResolveId(args$1) {
|
|
|
2764
2726
|
return {
|
|
2765
2727
|
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
2766
2728
|
const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
2767
|
-
const
|
|
2729
|
+
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
2730
|
...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);
|
|
2731
|
+
custom: contextResolveOptions?.custom
|
|
2732
|
+
});
|
|
2773
2733
|
if (ret == null) return;
|
|
2774
2734
|
if (ret === false) return {
|
|
2775
2735
|
id: specifier,
|
|
@@ -2840,7 +2800,7 @@ function bindingifyTransform(args$1) {
|
|
|
2840
2800
|
});
|
|
2841
2801
|
return {
|
|
2842
2802
|
code: ret.code,
|
|
2843
|
-
map: bindingifySourcemap(normalizeTransformHookSourcemap(id, code, ret.map)),
|
|
2803
|
+
map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id, code, ret.map)),
|
|
2844
2804
|
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
|
|
2845
2805
|
moduleType: ret.moduleType
|
|
2846
2806
|
};
|
|
@@ -2866,7 +2826,7 @@ function bindingifyLoad(args$1) {
|
|
|
2866
2826
|
let map = preProcessSourceMap(ret, id);
|
|
2867
2827
|
return {
|
|
2868
2828
|
code: ret.code,
|
|
2869
|
-
map: bindingifySourcemap(map),
|
|
2829
|
+
map: bindingifySourcemap$1(map),
|
|
2870
2830
|
moduleType: ret.moduleType,
|
|
2871
2831
|
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
|
|
2872
2832
|
};
|
|
@@ -2897,25 +2857,6 @@ function bindingifyModuleParsed(args$1) {
|
|
|
2897
2857
|
};
|
|
2898
2858
|
}
|
|
2899
2859
|
|
|
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
2860
|
//#endregion
|
|
2920
2861
|
//#region src/utils/transform-rendered-module.ts
|
|
2921
2862
|
function transformToRenderedModule(bindingRenderedModule) {
|
|
@@ -2982,338 +2923,125 @@ function transformChunkModules(modules) {
|
|
|
2982
2923
|
}
|
|
2983
2924
|
|
|
2984
2925
|
//#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
|
|
2926
|
+
//#region src/utils/transform-to-rollup-output.ts
|
|
2927
|
+
function transformToRollupSourceMap(map) {
|
|
2928
|
+
const parsed = JSON.parse(map);
|
|
2929
|
+
const obj = {
|
|
2930
|
+
...parsed,
|
|
2931
|
+
toString() {
|
|
2932
|
+
return JSON.stringify(obj);
|
|
2933
|
+
},
|
|
2934
|
+
toUrl() {
|
|
2935
|
+
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
2936
|
+
}
|
|
3023
2937
|
};
|
|
2938
|
+
return obj;
|
|
3024
2939
|
}
|
|
3025
|
-
function
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
2940
|
+
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
2941
|
+
const chunk = {
|
|
2942
|
+
type: "chunk",
|
|
2943
|
+
get code() {
|
|
2944
|
+
return bindingChunk.code;
|
|
2945
|
+
},
|
|
2946
|
+
fileName: bindingChunk.fileName,
|
|
2947
|
+
name: bindingChunk.name,
|
|
2948
|
+
get modules() {
|
|
2949
|
+
return transformChunkModules(bindingChunk.modules);
|
|
2950
|
+
},
|
|
2951
|
+
get imports() {
|
|
2952
|
+
return bindingChunk.imports;
|
|
2953
|
+
},
|
|
2954
|
+
get dynamicImports() {
|
|
2955
|
+
return bindingChunk.dynamicImports;
|
|
2956
|
+
},
|
|
2957
|
+
exports: bindingChunk.exports,
|
|
2958
|
+
isEntry: bindingChunk.isEntry,
|
|
2959
|
+
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
2960
|
+
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
2961
|
+
get moduleIds() {
|
|
2962
|
+
return bindingChunk.moduleIds;
|
|
2963
|
+
},
|
|
2964
|
+
get map() {
|
|
2965
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
2966
|
+
},
|
|
2967
|
+
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
2968
|
+
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
3029
2969
|
};
|
|
2970
|
+
const cache = {};
|
|
2971
|
+
return new Proxy(chunk, {
|
|
2972
|
+
get(target, p) {
|
|
2973
|
+
if (p in cache) return cache[p];
|
|
2974
|
+
const value = target[p];
|
|
2975
|
+
cache[p] = value;
|
|
2976
|
+
return value;
|
|
2977
|
+
},
|
|
2978
|
+
set(target, p, newValue) {
|
|
2979
|
+
cache[p] = newValue;
|
|
2980
|
+
changed?.updated.add(bindingChunk.fileName);
|
|
2981
|
+
return true;
|
|
2982
|
+
},
|
|
2983
|
+
has(target, p) {
|
|
2984
|
+
if (p in cache) return true;
|
|
2985
|
+
return p in target;
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
3030
2988
|
}
|
|
3031
|
-
function
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
2989
|
+
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
2990
|
+
const asset = {
|
|
2991
|
+
type: "asset",
|
|
2992
|
+
fileName: bindingAsset.fileName,
|
|
2993
|
+
originalFileName: bindingAsset.originalFileName || null,
|
|
2994
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
2995
|
+
get source() {
|
|
2996
|
+
return transformAssetSource(bindingAsset.source);
|
|
2997
|
+
},
|
|
2998
|
+
name: bindingAsset.name ?? void 0,
|
|
2999
|
+
names: bindingAsset.names
|
|
3000
|
+
};
|
|
3001
|
+
const cache = {};
|
|
3002
|
+
return new Proxy(asset, {
|
|
3003
|
+
get(target, p) {
|
|
3004
|
+
if (p in cache) return cache[p];
|
|
3005
|
+
const value = target[p];
|
|
3006
|
+
cache[p] = value;
|
|
3007
|
+
return value;
|
|
3008
|
+
},
|
|
3009
|
+
set(target, p, newValue) {
|
|
3010
|
+
cache[p] = newValue;
|
|
3011
|
+
changed?.updated.add(bindingAsset.fileName);
|
|
3012
|
+
return true;
|
|
3013
|
+
}
|
|
3014
|
+
});
|
|
3053
3015
|
}
|
|
3054
|
-
function
|
|
3055
|
-
|
|
3016
|
+
function transformToRollupOutput(output, changed) {
|
|
3017
|
+
handleOutputErrors(output);
|
|
3018
|
+
const { chunks, assets } = output;
|
|
3019
|
+
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
3056
3020
|
}
|
|
3057
|
-
function
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
names: asset.names,
|
|
3061
|
-
originalFileNames: asset.originalFileNames,
|
|
3062
|
-
source: transformAssetSource(asset.source),
|
|
3063
|
-
type: "asset"
|
|
3064
|
-
});
|
|
3065
|
-
};
|
|
3066
|
-
return assetFileNames;
|
|
3021
|
+
function handleOutputErrors(output) {
|
|
3022
|
+
const rawErrors = output.errors;
|
|
3023
|
+
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
3067
3024
|
}
|
|
3068
|
-
function
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
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
|
-
});
|
|
3025
|
+
function transformToOutputBundle(context, output, changed) {
|
|
3026
|
+
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
3027
|
+
return new Proxy(bundle, {
|
|
3028
|
+
set(_target, _p, _newValue, _receiver) {
|
|
3029
|
+
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
3030
|
+
Error.stackTraceLimit = 2;
|
|
3031
|
+
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.";
|
|
3032
|
+
const stack = new Error(message).stack ?? message;
|
|
3033
|
+
Error.stackTraceLimit = originalStackTraceLimit;
|
|
3034
|
+
context.warn({
|
|
3035
|
+
message: stack,
|
|
3036
|
+
code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
|
|
3037
|
+
});
|
|
3038
|
+
return true;
|
|
3039
|
+
},
|
|
3040
|
+
deleteProperty(target, property) {
|
|
3041
|
+
if (typeof property === "string") changed.deleted.add(property);
|
|
3042
|
+
return true;
|
|
3043
|
+
}
|
|
3044
|
+
});
|
|
3317
3045
|
}
|
|
3318
3046
|
function collectChangedBundle(changed, bundle) {
|
|
3319
3047
|
const assets = [];
|
|
@@ -3339,7 +3067,7 @@ function collectChangedBundle(changed, bundle) {
|
|
|
3339
3067
|
facadeModuleId: item.facadeModuleId || void 0,
|
|
3340
3068
|
isDynamicEntry: item.isDynamicEntry,
|
|
3341
3069
|
moduleIds: item.moduleIds,
|
|
3342
|
-
map: bindingifySourcemap(item.map),
|
|
3070
|
+
map: bindingifySourcemap$1(item.map),
|
|
3343
3071
|
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
3344
3072
|
preliminaryFilename: item.preliminaryFileName
|
|
3345
3073
|
});
|
|
@@ -3359,7 +3087,7 @@ function bindingifyRenderStart(args$1) {
|
|
|
3359
3087
|
const { handler, meta } = normalizeHook(hook);
|
|
3360
3088
|
return {
|
|
3361
3089
|
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),
|
|
3090
|
+
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
3091
|
},
|
|
3364
3092
|
meta: bindingifyPluginHookMeta(meta)
|
|
3365
3093
|
};
|
|
@@ -3371,13 +3099,13 @@ function bindingifyRenderChunk(args$1) {
|
|
|
3371
3099
|
return {
|
|
3372
3100
|
plugin: async (ctx, code, chunk, opts, meta$1) => {
|
|
3373
3101
|
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),
|
|
3102
|
+
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
3103
|
if (ret == null) return;
|
|
3376
3104
|
if (typeof ret === "string") return { code: ret };
|
|
3377
3105
|
if (!ret.map) return { code: ret.code };
|
|
3378
3106
|
return {
|
|
3379
3107
|
code: ret.code,
|
|
3380
|
-
map: bindingifySourcemap(ret.map)
|
|
3108
|
+
map: bindingifySourcemap$1(ret.map)
|
|
3381
3109
|
};
|
|
3382
3110
|
},
|
|
3383
3111
|
meta: bindingifyPluginHookMeta(meta),
|
|
@@ -3418,7 +3146,7 @@ function bindingifyGenerateBundle(args$1) {
|
|
|
3418
3146
|
};
|
|
3419
3147
|
const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
|
|
3420
3148
|
const output = transformToOutputBundle(context, bundle, changed);
|
|
3421
|
-
await handler.call(context,
|
|
3149
|
+
await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output, isWrite);
|
|
3422
3150
|
return collectChangedBundle(changed, output);
|
|
3423
3151
|
},
|
|
3424
3152
|
meta: bindingifyPluginHookMeta(meta)
|
|
@@ -3436,7 +3164,7 @@ function bindingifyWriteBundle(args$1) {
|
|
|
3436
3164
|
};
|
|
3437
3165
|
const context = new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode);
|
|
3438
3166
|
const output = transformToOutputBundle(context, bundle, changed);
|
|
3439
|
-
await handler.call(context,
|
|
3167
|
+
await handler.call(context, args$1.pluginContextData.getOutputOptions(opts), output);
|
|
3440
3168
|
return collectChangedBundle(changed, output);
|
|
3441
3169
|
},
|
|
3442
3170
|
meta: bindingifyPluginHookMeta(meta)
|
|
@@ -3711,30 +3439,291 @@ function wrapHandlers(plugin) {
|
|
|
3711
3439
|
}
|
|
3712
3440
|
|
|
3713
3441
|
//#endregion
|
|
3714
|
-
//#region src/
|
|
3715
|
-
var
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
renderedChunkMeta = null;
|
|
3721
|
-
updateModuleOption(id, option) {
|
|
3722
|
-
const existing = this.moduleOptionMap.get(id);
|
|
3723
|
-
if (existing) {
|
|
3724
|
-
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
3725
|
-
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
3726
|
-
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
3727
|
-
} else {
|
|
3728
|
-
this.moduleOptionMap.set(id, option);
|
|
3729
|
-
return option;
|
|
3730
|
-
}
|
|
3731
|
-
return existing;
|
|
3442
|
+
//#region src/options/normalized-input-options.ts
|
|
3443
|
+
var NormalizedInputOptionsImpl = class {
|
|
3444
|
+
inner;
|
|
3445
|
+
constructor(inner, onLog) {
|
|
3446
|
+
this.onLog = onLog;
|
|
3447
|
+
this.inner = inner;
|
|
3732
3448
|
}
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3449
|
+
get shimMissingExports() {
|
|
3450
|
+
return this.inner.shimMissingExports;
|
|
3451
|
+
}
|
|
3452
|
+
get input() {
|
|
3453
|
+
return this.inner.input;
|
|
3454
|
+
}
|
|
3455
|
+
get cwd() {
|
|
3456
|
+
return this.inner.cwd ?? void 0;
|
|
3457
|
+
}
|
|
3458
|
+
get platform() {
|
|
3459
|
+
return this.inner.platform;
|
|
3460
|
+
}
|
|
3461
|
+
};
|
|
3462
|
+
|
|
3463
|
+
//#endregion
|
|
3464
|
+
//#region src/types/chunking-context.ts
|
|
3465
|
+
var ChunkingContextImpl = class {
|
|
3466
|
+
constructor(context) {
|
|
3467
|
+
this.context = context;
|
|
3468
|
+
}
|
|
3469
|
+
getModuleInfo(moduleId) {
|
|
3470
|
+
const bindingInfo = this.context.getModuleInfo(moduleId);
|
|
3471
|
+
if (bindingInfo) {
|
|
3472
|
+
const info = transformModuleInfo(bindingInfo, {
|
|
3473
|
+
moduleSideEffects: null,
|
|
3474
|
+
meta: {}
|
|
3475
|
+
});
|
|
3476
|
+
return info;
|
|
3477
|
+
}
|
|
3478
|
+
return null;
|
|
3479
|
+
}
|
|
3480
|
+
};
|
|
3481
|
+
|
|
3482
|
+
//#endregion
|
|
3483
|
+
//#region src/utils/bindingify-output-options.ts
|
|
3484
|
+
function bindingifyOutputOptions(outputOptions) {
|
|
3485
|
+
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;
|
|
3486
|
+
const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
|
|
3487
|
+
return {
|
|
3488
|
+
dir,
|
|
3489
|
+
file: file == null ? void 0 : file,
|
|
3490
|
+
format: bindingifyFormat(format),
|
|
3491
|
+
exports,
|
|
3492
|
+
hashCharacters,
|
|
3493
|
+
sourcemap: bindingifySourcemap(sourcemap),
|
|
3494
|
+
sourcemapDebugIds,
|
|
3495
|
+
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
3496
|
+
sourcemapPathTransform,
|
|
3497
|
+
banner: bindingifyAddon(banner),
|
|
3498
|
+
footer: bindingifyAddon(footer),
|
|
3499
|
+
intro: bindingifyAddon(intro),
|
|
3500
|
+
outro: bindingifyAddon(outro),
|
|
3501
|
+
extend: outputOptions.extend,
|
|
3502
|
+
globals,
|
|
3503
|
+
esModule,
|
|
3504
|
+
name,
|
|
3505
|
+
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
3506
|
+
entryFileNames,
|
|
3507
|
+
chunkFileNames,
|
|
3508
|
+
cssEntryFileNames,
|
|
3509
|
+
cssChunkFileNames,
|
|
3510
|
+
plugins: [],
|
|
3511
|
+
minify: outputOptions.minify,
|
|
3512
|
+
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
3513
|
+
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
3514
|
+
advancedChunks,
|
|
3515
|
+
polyfillRequire: outputOptions.polyfillRequire,
|
|
3516
|
+
sanitizeFileName,
|
|
3517
|
+
preserveModules,
|
|
3518
|
+
virtualDirname,
|
|
3519
|
+
legalComments,
|
|
3520
|
+
preserveModulesRoot
|
|
3521
|
+
};
|
|
3522
|
+
}
|
|
3523
|
+
function bindingifyAddon(configAddon) {
|
|
3524
|
+
return async (chunk) => {
|
|
3525
|
+
if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
|
|
3526
|
+
return configAddon || "";
|
|
3527
|
+
};
|
|
3528
|
+
}
|
|
3529
|
+
function bindingifyFormat(format) {
|
|
3530
|
+
switch (format) {
|
|
3531
|
+
case void 0:
|
|
3532
|
+
case "es":
|
|
3533
|
+
case "esm":
|
|
3534
|
+
case "module": return "es";
|
|
3535
|
+
case "cjs":
|
|
3536
|
+
case "commonjs": return "cjs";
|
|
3537
|
+
case "iife": return "iife";
|
|
3538
|
+
case "umd": return "umd";
|
|
3539
|
+
default: unimplemented(`output.format: ${format}`);
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
function bindingifySourcemap(sourcemap) {
|
|
3543
|
+
switch (sourcemap) {
|
|
3544
|
+
case true: return "file";
|
|
3545
|
+
case "inline": return "inline";
|
|
3546
|
+
case false:
|
|
3547
|
+
case void 0: return void 0;
|
|
3548
|
+
case "hidden": return "hidden";
|
|
3549
|
+
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
3553
|
+
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
3554
|
+
}
|
|
3555
|
+
function bindingifyAssetFilenames(assetFileNames) {
|
|
3556
|
+
if (typeof assetFileNames === "function") return (asset) => {
|
|
3557
|
+
return assetFileNames({
|
|
3558
|
+
names: asset.names,
|
|
3559
|
+
originalFileNames: asset.originalFileNames,
|
|
3560
|
+
source: transformAssetSource(asset.source),
|
|
3561
|
+
type: "asset"
|
|
3562
|
+
});
|
|
3563
|
+
};
|
|
3564
|
+
return assetFileNames;
|
|
3565
|
+
}
|
|
3566
|
+
function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
|
|
3567
|
+
if (manualChunks != null && advancedChunks != null) console.warn("`manualChunks` option is ignored due to `advancedChunks` option is specified.");
|
|
3568
|
+
else if (manualChunks != null) advancedChunks = { groups: [{ name(moduleId, ctx) {
|
|
3569
|
+
return manualChunks(moduleId, { getModuleInfo: (id) => ctx.getModuleInfo(id) });
|
|
3570
|
+
} }] };
|
|
3571
|
+
if (advancedChunks == null) return void 0;
|
|
3572
|
+
const { groups,...restAdvancedChunks } = advancedChunks;
|
|
3573
|
+
return {
|
|
3574
|
+
...restAdvancedChunks,
|
|
3575
|
+
groups: groups?.map((group) => {
|
|
3576
|
+
const { name,...restGroup } = group;
|
|
3577
|
+
return {
|
|
3578
|
+
...restGroup,
|
|
3579
|
+
name: typeof name === "function" ? (id, ctx) => name(id, new ChunkingContextImpl(ctx)) : name
|
|
3580
|
+
};
|
|
3581
|
+
})
|
|
3582
|
+
};
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
//#endregion
|
|
3586
|
+
//#region src/options/normalized-output-options.ts
|
|
3587
|
+
var NormalizedOutputOptionsImpl = class {
|
|
3588
|
+
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
3589
|
+
this.inner = inner;
|
|
3590
|
+
this.outputOptions = outputOptions;
|
|
3591
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3592
|
+
}
|
|
3593
|
+
get dir() {
|
|
3594
|
+
return this.inner.dir ?? void 0;
|
|
3595
|
+
}
|
|
3596
|
+
get entryFileNames() {
|
|
3597
|
+
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
3598
|
+
}
|
|
3599
|
+
get chunkFileNames() {
|
|
3600
|
+
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3601
|
+
}
|
|
3602
|
+
get assetFileNames() {
|
|
3603
|
+
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
3604
|
+
}
|
|
3605
|
+
get format() {
|
|
3606
|
+
return this.inner.format;
|
|
3607
|
+
}
|
|
3608
|
+
get exports() {
|
|
3609
|
+
return this.inner.exports;
|
|
3610
|
+
}
|
|
3611
|
+
get sourcemap() {
|
|
3612
|
+
return this.inner.sourcemap;
|
|
3613
|
+
}
|
|
3614
|
+
get cssEntryFileNames() {
|
|
3615
|
+
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
3616
|
+
}
|
|
3617
|
+
get cssChunkFileNames() {
|
|
3618
|
+
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
3619
|
+
}
|
|
3620
|
+
get shimMissingExports() {
|
|
3621
|
+
return this.inner.shimMissingExports;
|
|
3622
|
+
}
|
|
3623
|
+
get name() {
|
|
3624
|
+
return this.inner.name ?? void 0;
|
|
3625
|
+
}
|
|
3626
|
+
get file() {
|
|
3627
|
+
return this.inner.file ?? void 0;
|
|
3628
|
+
}
|
|
3629
|
+
get inlineDynamicImports() {
|
|
3630
|
+
return this.inner.inlineDynamicImports;
|
|
3631
|
+
}
|
|
3632
|
+
get externalLiveBindings() {
|
|
3633
|
+
return this.inner.externalLiveBindings;
|
|
3634
|
+
}
|
|
3635
|
+
get banner() {
|
|
3636
|
+
return normalizeAddon(this.outputOptions.banner);
|
|
3637
|
+
}
|
|
3638
|
+
get footer() {
|
|
3639
|
+
return normalizeAddon(this.outputOptions.footer);
|
|
3640
|
+
}
|
|
3641
|
+
get intro() {
|
|
3642
|
+
return normalizeAddon(this.outputOptions.intro);
|
|
3643
|
+
}
|
|
3644
|
+
get outro() {
|
|
3645
|
+
return normalizeAddon(this.outputOptions.outro);
|
|
3646
|
+
}
|
|
3647
|
+
get esModule() {
|
|
3648
|
+
return this.inner.esModule;
|
|
3649
|
+
}
|
|
3650
|
+
get extend() {
|
|
3651
|
+
return this.inner.extend;
|
|
3652
|
+
}
|
|
3653
|
+
get globals() {
|
|
3654
|
+
return this.inner.globals || this.outputOptions.globals;
|
|
3655
|
+
}
|
|
3656
|
+
get hashCharacters() {
|
|
3657
|
+
return this.inner.hashCharacters;
|
|
3658
|
+
}
|
|
3659
|
+
get sourcemapDebugIds() {
|
|
3660
|
+
return this.inner.sourcemapDebugIds;
|
|
3661
|
+
}
|
|
3662
|
+
get sourcemapIgnoreList() {
|
|
3663
|
+
return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
|
|
3664
|
+
}
|
|
3665
|
+
get sourcemapPathTransform() {
|
|
3666
|
+
return this.outputOptions.sourcemapPathTransform;
|
|
3667
|
+
}
|
|
3668
|
+
get minify() {
|
|
3669
|
+
return this.inner.minify;
|
|
3670
|
+
}
|
|
3671
|
+
get legalComments() {
|
|
3672
|
+
return this.inner.legalComments;
|
|
3673
|
+
}
|
|
3674
|
+
get polyfillRequire() {
|
|
3675
|
+
return this.inner.polyfillRequire;
|
|
3676
|
+
}
|
|
3677
|
+
get plugins() {
|
|
3678
|
+
return this.normalizedOutputPlugins;
|
|
3679
|
+
}
|
|
3680
|
+
get preserveModules() {
|
|
3681
|
+
return this.inner.preserveModules;
|
|
3682
|
+
}
|
|
3683
|
+
get preserveModulesRoot() {
|
|
3684
|
+
return this.inner.preserveModulesRoot;
|
|
3685
|
+
}
|
|
3686
|
+
get virtualDirname() {
|
|
3687
|
+
return this.inner.virtualDirname;
|
|
3688
|
+
}
|
|
3689
|
+
};
|
|
3690
|
+
function normalizeAddon(value) {
|
|
3691
|
+
if (typeof value === "function") return value;
|
|
3692
|
+
return () => value || "";
|
|
3693
|
+
}
|
|
3694
|
+
|
|
3695
|
+
//#endregion
|
|
3696
|
+
//#region src/plugin/plugin-context-data.ts
|
|
3697
|
+
var PluginContextData = class {
|
|
3698
|
+
moduleOptionMap = /* @__PURE__ */ new Map();
|
|
3699
|
+
resolveOptionsMap = /* @__PURE__ */ new Map();
|
|
3700
|
+
loadModulePromiseMap = /* @__PURE__ */ new Map();
|
|
3701
|
+
loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
|
|
3702
|
+
renderedChunkMeta = null;
|
|
3703
|
+
normalizedInputOptions = null;
|
|
3704
|
+
normalizedOutputOptions = null;
|
|
3705
|
+
constructor(onLog, outputOptions, normalizedOutputPlugins) {
|
|
3706
|
+
this.onLog = onLog;
|
|
3707
|
+
this.outputOptions = outputOptions;
|
|
3708
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3709
|
+
}
|
|
3710
|
+
updateModuleOption(id, option) {
|
|
3711
|
+
const existing = this.moduleOptionMap.get(id);
|
|
3712
|
+
if (existing) {
|
|
3713
|
+
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
3714
|
+
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
3715
|
+
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
3716
|
+
} else {
|
|
3717
|
+
this.moduleOptionMap.set(id, option);
|
|
3718
|
+
return option;
|
|
3719
|
+
}
|
|
3720
|
+
return existing;
|
|
3721
|
+
}
|
|
3722
|
+
getModuleOption(id) {
|
|
3723
|
+
const option = this.moduleOptionMap.get(id);
|
|
3724
|
+
if (!option) {
|
|
3725
|
+
const raw = {
|
|
3726
|
+
moduleSideEffects: null,
|
|
3738
3727
|
meta: {}
|
|
3739
3728
|
};
|
|
3740
3729
|
this.moduleOptionMap.set(id, raw);
|
|
@@ -3788,6 +3777,14 @@ var PluginContextData = class {
|
|
|
3788
3777
|
getRenderChunkMeta() {
|
|
3789
3778
|
return this.renderedChunkMeta;
|
|
3790
3779
|
}
|
|
3780
|
+
getInputOptions(opts) {
|
|
3781
|
+
this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
|
|
3782
|
+
return this.normalizedInputOptions;
|
|
3783
|
+
}
|
|
3784
|
+
getOutputOptions(opts) {
|
|
3785
|
+
this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
|
|
3786
|
+
return this.normalizedOutputOptions;
|
|
3787
|
+
}
|
|
3791
3788
|
markModuleLoaded(id, _success) {
|
|
3792
3789
|
const resolve = this.loadModulePromiseResolveFnMap.get(id);
|
|
3793
3790
|
if (resolve) resolve();
|
|
@@ -3813,7 +3810,7 @@ function isReadonlyArray(input) {
|
|
|
3813
3810
|
//#endregion
|
|
3814
3811
|
//#region src/utils/bindingify-input-options.ts
|
|
3815
3812
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
3816
|
-
const pluginContextData = new PluginContextData();
|
|
3813
|
+
const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
|
|
3817
3814
|
const plugins = rawPlugins.map((plugin) => {
|
|
3818
3815
|
if ("_parallel" in plugin) return void 0;
|
|
3819
3816
|
if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
|
|
@@ -4021,323 +4018,6 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
|
|
|
4021
4018
|
};
|
|
4022
4019
|
}
|
|
4023
4020
|
|
|
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
4021
|
//#endregion
|
|
4342
4022
|
//#region src/utils/initialize-parallel-plugins.ts
|
|
4343
4023
|
async function initializeParallelPlugins(plugins) {
|
|
@@ -4414,7 +4094,6 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
|
|
|
4414
4094
|
...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
|
|
4415
4095
|
...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
|
|
4416
4096
|
];
|
|
4417
|
-
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
4418
4097
|
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
4419
4098
|
try {
|
|
4420
4099
|
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
@@ -4684,4 +4363,4 @@ function defineConfig(config) {
|
|
|
4684
4363
|
const VERSION = version;
|
|
4685
4364
|
|
|
4686
4365
|
//#endregion
|
|
4687
|
-
export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin,
|
|
4366
|
+
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 };
|