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