@rolldown/browser 1.1.1 → 1.1.3
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.mjs +25 -14
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +2 -2
- package/dist/{constructors-B3MtwuwE.js → constructors-CnlRXsZI.js} +1 -4
- package/dist/{error-Azs8e8cN.js → error-DOcnYe1L.js} +1 -1
- package/dist/experimental-index.browser.mjs +17 -12
- package/dist/experimental-index.d.mts +16 -6
- package/dist/experimental-index.mjs +17 -12
- package/dist/filter-index.d.mts +1 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/parallel-plugin-worker.mjs +1 -1
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/plugins-index.browser.mjs +1 -1
- package/dist/plugins-index.d.mts +3 -3
- package/dist/plugins-index.mjs +1 -1
- package/dist/{resolve-tsconfig-Cmw0SAxd.js → resolve-tsconfig-B_KTldgL.js} +1 -1
- package/dist/rolldown-binding.wasi-browser.js +1 -0
- package/dist/rolldown-binding.wasi.cjs +1 -0
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/{rolldown-build-C9wAyTYG.js → rolldown-build-AEs_8s-I.js} +1481 -1514
- package/dist/shared/{binding-BPMI4t0-.d.mts → binding-DyMVbTi5.d.mts} +65 -142
- package/dist/shared/{bindingify-input-options-EBZ5IFF2.mjs → bindingify-input-options-C6gxQEeC.mjs} +1325 -1326
- package/dist/shared/{constructors-YQsI-lJq.mjs → constructors-CAjrhG6p.mjs} +1 -4
- package/dist/shared/{constructors-DAokZVCk.d.mts → constructors-CDyv7p8V.d.mts} +3 -4
- package/dist/shared/{define-config-Nwe1joYW.d.mts → define-config-Tz8fY30o.d.mts} +2 -2
- package/dist/shared/{load-config-2QjEcEu4.mjs → load-config-C6ynET_w.mjs} +1 -1
- package/dist/shared/{parse-DNkPrz4w.mjs → parse-DzXgx0D0.mjs} +1 -1
- package/dist/shared/{prompt-DYnaB1Nb.mjs → prompt-B1Yc1NPt.mjs} +5 -5
- package/dist/shared/{rolldown-build-BgBj9qUV.mjs → rolldown-build-CVwFjky2.mjs} +21 -53
- package/dist/shared/{rolldown-Bqp7kINm.mjs → rolldown-ro17jDL2.mjs} +1 -1
- package/dist/shared/{transform-DulXg6tQ.d.mts → transform-DudVZDD5.d.mts} +1 -1
- package/dist/shared/{utils-Bp1VejKQ.d.mts → utils-DLIXIK5m.d.mts} +1 -1
- package/dist/shared/{watch-C6WxUyjE.mjs → watch-DyYqAbie.mjs} +2 -2
- package/dist/utils-index.browser.mjs +6 -6
- package/dist/utils-index.d.mts +3 -3
- package/dist/utils-index.mjs +5 -5
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as logCycleLoading, f as logNoFileSystemInBrowser, g as getCodeFrame, h as locate, i as bindingifyManifestPlugin, l as logInputHookInOutputPlugin, m as logPluginError, n as BuiltinPlugin, o as augmentCodeLocation, p as logParseError, r as bindingifyBuiltInPlugin, s as error, t as normalizedStringOrRegex, u as logInvalidLogPosition } from "./normalize-string-or-regex-A9UIvc9j.js";
|
|
2
|
-
import { i as unwrapBindingResult, o as parseSync$1, s as bindingifySourcemap$1, t as aggregateBindingErrorsIntoJsError } from "./error-
|
|
2
|
+
import { i as unwrapBindingResult, o as parseSync$1, s as bindingifySourcemap$1, t as aggregateBindingErrorsIntoJsError } from "./error-DOcnYe1L.js";
|
|
3
3
|
import { BindingAttachDebugInfo, BindingBundler, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
|
|
4
4
|
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
5
5
|
let _lazyMatch = () => {
|
|
@@ -454,7 +454,7 @@ const win32 = /* @__PURE__ */ mix(";");
|
|
|
454
454
|
*
|
|
455
455
|
* @category Plugin APIs
|
|
456
456
|
*/
|
|
457
|
-
const VERSION = "1.1.
|
|
457
|
+
const VERSION = "1.1.3";
|
|
458
458
|
//#endregion
|
|
459
459
|
//#region src/constants/index.ts
|
|
460
460
|
/**
|
|
@@ -1914,43 +1914,7 @@ const TransformOptionsSchema = /* @__PURE__ */ object({
|
|
|
1914
1914
|
plugins: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ object({
|
|
1915
1915
|
styledComponents: /* @__PURE__ */ optional(/* @__PURE__ */ any()),
|
|
1916
1916
|
taggedTemplateEscape: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
|
|
1917
|
-
})), /* @__PURE__ */ description("Third-party plugins to use"))
|
|
1918
|
-
reactCompiler: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ object({
|
|
1919
|
-
compilationMode: /* @__PURE__ */ optional(/* @__PURE__ */ union([
|
|
1920
|
-
/* @__PURE__ */ literal("infer"),
|
|
1921
|
-
/* @__PURE__ */ literal("syntax"),
|
|
1922
|
-
/* @__PURE__ */ literal("annotation"),
|
|
1923
|
-
/* @__PURE__ */ literal("all")
|
|
1924
|
-
])),
|
|
1925
|
-
panicThreshold: /* @__PURE__ */ optional(/* @__PURE__ */ union([
|
|
1926
|
-
/* @__PURE__ */ literal("none"),
|
|
1927
|
-
/* @__PURE__ */ literal("critical_errors"),
|
|
1928
|
-
/* @__PURE__ */ literal("all_errors")
|
|
1929
|
-
])),
|
|
1930
|
-
target: /* @__PURE__ */ optional(/* @__PURE__ */ union([
|
|
1931
|
-
/* @__PURE__ */ literal("17"),
|
|
1932
|
-
/* @__PURE__ */ literal("18"),
|
|
1933
|
-
/* @__PURE__ */ literal("19")
|
|
1934
|
-
])),
|
|
1935
|
-
noEmit: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1936
|
-
outputMode: /* @__PURE__ */ optional(/* @__PURE__ */ union([
|
|
1937
|
-
/* @__PURE__ */ literal("client"),
|
|
1938
|
-
/* @__PURE__ */ literal("ssr"),
|
|
1939
|
-
/* @__PURE__ */ literal("lint")
|
|
1940
|
-
])),
|
|
1941
|
-
ignoreUseNoForget: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1942
|
-
flowSuppressions: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1943
|
-
enableReanimated: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1944
|
-
isDev: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1945
|
-
filename: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
1946
|
-
eslintSuppressionRules: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
|
|
1947
|
-
customOptOutDirectives: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
|
|
1948
|
-
gating: /* @__PURE__ */ optional(/* @__PURE__ */ object({
|
|
1949
|
-
source: /* @__PURE__ */ string(),
|
|
1950
|
-
importSpecifierName: /* @__PURE__ */ string()
|
|
1951
|
-
})),
|
|
1952
|
-
dynamicGating: /* @__PURE__ */ optional(/* @__PURE__ */ object({ source: /* @__PURE__ */ string() }))
|
|
1953
|
-
})]))
|
|
1917
|
+
})), /* @__PURE__ */ description("Third-party plugins to use"))
|
|
1954
1918
|
});
|
|
1955
1919
|
const WatcherFileWatcherOptionsSchema = /* @__PURE__ */ strictObject({
|
|
1956
1920
|
usePolling: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use polling-based file watching instead of native OS events")),
|
|
@@ -2477,7 +2441,7 @@ function bindingAssetSource(source) {
|
|
|
2477
2441
|
return { inner: source };
|
|
2478
2442
|
}
|
|
2479
2443
|
//#endregion
|
|
2480
|
-
//#region \0@oxc-project+runtime@0.
|
|
2444
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
2481
2445
|
function __decorate(decorators, target, key, desc) {
|
|
2482
2446
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2483
2447
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2846,1541 +2810,1541 @@ var RolldownOutputImpl = class extends PlainObjectLike {
|
|
|
2846
2810
|
};
|
|
2847
2811
|
__decorate([lazyProp], RolldownOutputImpl.prototype, "output", null);
|
|
2848
2812
|
//#endregion
|
|
2849
|
-
//#region src/
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
const nativePrepend = BindingMagicString.prototype.prepend;
|
|
2860
|
-
const nativeAppendLeft = BindingMagicString.prototype.appendLeft;
|
|
2861
|
-
const nativeAppendRight = BindingMagicString.prototype.appendRight;
|
|
2862
|
-
const nativePrependLeft = BindingMagicString.prototype.prependLeft;
|
|
2863
|
-
const nativePrependRight = BindingMagicString.prototype.prependRight;
|
|
2864
|
-
const nativeOverwrite = BindingMagicString.prototype.overwrite;
|
|
2865
|
-
const nativeUpdate = BindingMagicString.prototype.update;
|
|
2866
|
-
BindingMagicString.prototype.append = function(content) {
|
|
2867
|
-
assertString(content, "outro content must be a string");
|
|
2868
|
-
return nativeAppend.call(this, content);
|
|
2869
|
-
};
|
|
2870
|
-
BindingMagicString.prototype.prepend = function(content) {
|
|
2871
|
-
assertString(content, "outro content must be a string");
|
|
2872
|
-
return nativePrepend.call(this, content);
|
|
2873
|
-
};
|
|
2874
|
-
BindingMagicString.prototype.appendLeft = function(index, content) {
|
|
2875
|
-
assertString(content, "inserted content must be a string");
|
|
2876
|
-
return nativeAppendLeft.call(this, index, content);
|
|
2877
|
-
};
|
|
2878
|
-
BindingMagicString.prototype.appendRight = function(index, content) {
|
|
2879
|
-
assertString(content, "inserted content must be a string");
|
|
2880
|
-
return nativeAppendRight.call(this, index, content);
|
|
2881
|
-
};
|
|
2882
|
-
BindingMagicString.prototype.prependLeft = function(index, content) {
|
|
2883
|
-
assertString(content, "inserted content must be a string");
|
|
2884
|
-
return nativePrependLeft.call(this, index, content);
|
|
2885
|
-
};
|
|
2886
|
-
BindingMagicString.prototype.prependRight = function(index, content) {
|
|
2887
|
-
assertString(content, "inserted content must be a string");
|
|
2888
|
-
return nativePrependRight.call(this, index, content);
|
|
2889
|
-
};
|
|
2890
|
-
BindingMagicString.prototype.overwrite = function(start, end, content, options) {
|
|
2891
|
-
assertString(content, "replacement content must be a string");
|
|
2892
|
-
return nativeOverwrite.call(this, start, end, content, options);
|
|
2893
|
-
};
|
|
2894
|
-
BindingMagicString.prototype.update = function(start, end, content, options) {
|
|
2895
|
-
assertString(content, "replacement content must be a string");
|
|
2896
|
-
return nativeUpdate.call(this, start, end, content, options);
|
|
2897
|
-
};
|
|
2898
|
-
const nativeReplace = BindingMagicString.prototype.replace;
|
|
2899
|
-
const nativeReplaceAll = BindingMagicString.prototype.replaceAll;
|
|
2900
|
-
BindingMagicString.prototype.replace = function(searchValue, replacement) {
|
|
2901
|
-
if (typeof searchValue === "string") return nativeReplace.call(this, searchValue, replacement);
|
|
2902
|
-
if (searchValue.global) searchValue.lastIndex = 0;
|
|
2903
|
-
const lastMatchEnd = this.replaceRegex(searchValue, replacement);
|
|
2904
|
-
if (searchValue.global) searchValue.lastIndex = 0;
|
|
2905
|
-
else if (searchValue.sticky) searchValue.lastIndex = lastMatchEnd === -1 ? 0 : lastMatchEnd;
|
|
2906
|
-
return this;
|
|
2907
|
-
};
|
|
2908
|
-
BindingMagicString.prototype.replaceAll = function(searchValue, replacement) {
|
|
2909
|
-
if (typeof searchValue === "string") return nativeReplaceAll.call(this, searchValue, replacement);
|
|
2910
|
-
if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
|
|
2911
|
-
searchValue.lastIndex = 0;
|
|
2912
|
-
this.replaceRegex(searchValue, replacement);
|
|
2913
|
-
searchValue.lastIndex = 0;
|
|
2914
|
-
return this;
|
|
2915
|
-
};
|
|
2916
|
-
/**
|
|
2917
|
-
* A native MagicString implementation powered by Rust.
|
|
2918
|
-
*
|
|
2919
|
-
* @experimental
|
|
2920
|
-
*/
|
|
2921
|
-
const RolldownMagicString = BindingMagicString;
|
|
2922
|
-
//#endregion
|
|
2923
|
-
//#region src/parse-ast-index.ts
|
|
2924
|
-
function wrap(result, filename, sourceText) {
|
|
2925
|
-
if (result.errors.length > 0) return normalizeParseError(filename, sourceText, result.errors);
|
|
2926
|
-
return result.program;
|
|
2927
|
-
}
|
|
2928
|
-
function normalizeParseError(filename, sourceText, errors) {
|
|
2929
|
-
let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
2930
|
-
const pos = errors[0]?.labels?.[0]?.start;
|
|
2931
|
-
for (let i = 0; i < errors.length; i++) {
|
|
2932
|
-
if (i >= 5) {
|
|
2933
|
-
message += "\n...";
|
|
2934
|
-
break;
|
|
2935
|
-
}
|
|
2936
|
-
const e = errors[i];
|
|
2937
|
-
message += e.message + "\n" + e.labels.map((label) => {
|
|
2938
|
-
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
2939
|
-
if (!location) return;
|
|
2940
|
-
return getCodeFrame(sourceText, location.line, location.column);
|
|
2941
|
-
}).filter(Boolean).join("\n");
|
|
2813
|
+
//#region src/options/normalized-input-options.ts
|
|
2814
|
+
var NormalizedInputOptionsImpl = class extends PlainObjectLike {
|
|
2815
|
+
onLog;
|
|
2816
|
+
inputPlugins;
|
|
2817
|
+
inner;
|
|
2818
|
+
constructor(inner, onLog, inputPlugins) {
|
|
2819
|
+
super();
|
|
2820
|
+
this.onLog = onLog;
|
|
2821
|
+
this.inputPlugins = inputPlugins;
|
|
2822
|
+
this.inner = inner;
|
|
2942
2823
|
}
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
return error(log);
|
|
2946
|
-
}
|
|
2947
|
-
const defaultParserOptions = {
|
|
2948
|
-
lang: "js",
|
|
2949
|
-
preserveParens: false
|
|
2950
|
-
};
|
|
2951
|
-
/**
|
|
2952
|
-
* Parse code synchronously and return the AST.
|
|
2953
|
-
*
|
|
2954
|
-
* This function is similar to Rollup's `parseAst` function.
|
|
2955
|
-
* Prefer using {@linkcode parseSync} instead of this function as it has more information in the return value.
|
|
2956
|
-
*
|
|
2957
|
-
* @category Utilities
|
|
2958
|
-
*/
|
|
2959
|
-
function parseAst(sourceText, options, filename) {
|
|
2960
|
-
return wrap(parseSync$1(filename ?? "file.js", sourceText, {
|
|
2961
|
-
...defaultParserOptions,
|
|
2962
|
-
...options
|
|
2963
|
-
}), filename, sourceText);
|
|
2964
|
-
}
|
|
2965
|
-
//#endregion
|
|
2966
|
-
//#region src/utils/transform-module-info.ts
|
|
2967
|
-
function transformModuleInfo(info, option) {
|
|
2968
|
-
return {
|
|
2969
|
-
get ast() {
|
|
2970
|
-
return unsupported("ModuleInfo#ast");
|
|
2971
|
-
},
|
|
2972
|
-
get code() {
|
|
2973
|
-
return info.code;
|
|
2974
|
-
},
|
|
2975
|
-
id: info.id,
|
|
2976
|
-
importers: info.importers,
|
|
2977
|
-
dynamicImporters: info.dynamicImporters,
|
|
2978
|
-
importedIds: info.importedIds,
|
|
2979
|
-
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
2980
|
-
exports: info.exports,
|
|
2981
|
-
isEntry: info.isEntry,
|
|
2982
|
-
inputFormat: info.inputFormat,
|
|
2983
|
-
...option
|
|
2984
|
-
};
|
|
2985
|
-
}
|
|
2986
|
-
//#endregion
|
|
2987
|
-
//#region src/utils/transform-sourcemap.ts
|
|
2988
|
-
function isEmptySourcemapFiled(array) {
|
|
2989
|
-
if (!array) return true;
|
|
2990
|
-
if (array.length === 0 || !array[0]) return true;
|
|
2991
|
-
return false;
|
|
2992
|
-
}
|
|
2993
|
-
function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
2994
|
-
if (!rawMap) return;
|
|
2995
|
-
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
2996
|
-
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
2997
|
-
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
|
|
2998
|
-
return map;
|
|
2999
|
-
}
|
|
3000
|
-
//#endregion
|
|
3001
|
-
//#region ../../node_modules/.pnpm/@rolldown+pluginutils@1.0.1/node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs
|
|
3002
|
-
var And = class {
|
|
3003
|
-
kind;
|
|
3004
|
-
args;
|
|
3005
|
-
constructor(...args) {
|
|
3006
|
-
if (args.length === 0) throw new Error("`And` expects at least one operand");
|
|
3007
|
-
this.args = args;
|
|
3008
|
-
this.kind = "and";
|
|
2824
|
+
get shimMissingExports() {
|
|
2825
|
+
return this.inner.shimMissingExports;
|
|
3009
2826
|
}
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
kind;
|
|
3013
|
-
args;
|
|
3014
|
-
constructor(...args) {
|
|
3015
|
-
if (args.length === 0) throw new Error("`Or` expects at least one operand");
|
|
3016
|
-
this.args = args;
|
|
3017
|
-
this.kind = "or";
|
|
2827
|
+
get input() {
|
|
2828
|
+
return this.inner.input;
|
|
3018
2829
|
}
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
kind;
|
|
3022
|
-
pattern;
|
|
3023
|
-
params;
|
|
3024
|
-
constructor(pattern, params) {
|
|
3025
|
-
this.pattern = pattern;
|
|
3026
|
-
this.kind = "id";
|
|
3027
|
-
this.params = params ?? { cleanUrl: false };
|
|
2830
|
+
get cwd() {
|
|
2831
|
+
return this.inner.cwd;
|
|
3028
2832
|
}
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
kind;
|
|
3032
|
-
pattern;
|
|
3033
|
-
constructor(pattern) {
|
|
3034
|
-
this.pattern = pattern;
|
|
3035
|
-
this.kind = "moduleType";
|
|
2833
|
+
get platform() {
|
|
2834
|
+
return this.inner.platform;
|
|
3036
2835
|
}
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
kind;
|
|
3040
|
-
pattern;
|
|
3041
|
-
constructor(expr) {
|
|
3042
|
-
this.pattern = expr;
|
|
3043
|
-
this.kind = "code";
|
|
2836
|
+
get context() {
|
|
2837
|
+
return this.inner.context;
|
|
3044
2838
|
}
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
kind;
|
|
3048
|
-
expr;
|
|
3049
|
-
constructor(expr) {
|
|
3050
|
-
this.expr = expr;
|
|
3051
|
-
this.kind = "include";
|
|
2839
|
+
get plugins() {
|
|
2840
|
+
return this.inputPlugins;
|
|
3052
2841
|
}
|
|
3053
2842
|
};
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
2843
|
+
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
|
|
2844
|
+
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
|
|
2845
|
+
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
|
|
2846
|
+
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
|
|
2847
|
+
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
|
|
2848
|
+
//#endregion
|
|
2849
|
+
//#region src/options/normalized-output-options.ts
|
|
2850
|
+
var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
|
|
2851
|
+
inner;
|
|
2852
|
+
outputOptions;
|
|
2853
|
+
normalizedOutputPlugins;
|
|
2854
|
+
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
2855
|
+
super();
|
|
2856
|
+
this.inner = inner;
|
|
2857
|
+
this.outputOptions = outputOptions;
|
|
2858
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3060
2859
|
}
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
return new And(...args);
|
|
3064
|
-
}
|
|
3065
|
-
function or(...args) {
|
|
3066
|
-
return new Or(...args);
|
|
3067
|
-
}
|
|
3068
|
-
function id(pattern, params) {
|
|
3069
|
-
return new Id(pattern, params);
|
|
3070
|
-
}
|
|
3071
|
-
function moduleType(pattern) {
|
|
3072
|
-
return new ModuleType(pattern);
|
|
3073
|
-
}
|
|
3074
|
-
function code(pattern) {
|
|
3075
|
-
return new Code(pattern);
|
|
3076
|
-
}
|
|
3077
|
-
function include(expr) {
|
|
3078
|
-
return new Include(expr);
|
|
3079
|
-
}
|
|
3080
|
-
function exclude(expr) {
|
|
3081
|
-
return new Exclude(expr);
|
|
3082
|
-
}
|
|
3083
|
-
//#endregion
|
|
3084
|
-
//#region ../../node_modules/.pnpm/remeda@2.34.1/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
|
|
3085
|
-
function e(e, t, n) {
|
|
3086
|
-
let r = (n) => e(n, ...t);
|
|
3087
|
-
return n === void 0 ? r : Object.assign(r, {
|
|
3088
|
-
lazy: n,
|
|
3089
|
-
lazyArgs: t
|
|
3090
|
-
});
|
|
3091
|
-
}
|
|
3092
|
-
//#endregion
|
|
3093
|
-
//#region ../../node_modules/.pnpm/remeda@2.34.1/node_modules/remeda/dist/purry.js
|
|
3094
|
-
function t$1(t, n, r) {
|
|
3095
|
-
let i = t.length - n.length;
|
|
3096
|
-
if (i === 0) return t(...n);
|
|
3097
|
-
if (i === 1) return e(t, n, r);
|
|
3098
|
-
throw Error(`Wrong number of arguments`);
|
|
3099
|
-
}
|
|
3100
|
-
//#endregion
|
|
3101
|
-
//#region ../../node_modules/.pnpm/remeda@2.34.1/node_modules/remeda/dist/partition.js
|
|
3102
|
-
function t(...t) {
|
|
3103
|
-
return t$1(n, t);
|
|
3104
|
-
}
|
|
3105
|
-
const n = (e, t) => {
|
|
3106
|
-
let n = [[], []];
|
|
3107
|
-
for (let [r, i] of e.entries()) t(i, r, e) ? n[0].push(i) : n[1].push(i);
|
|
3108
|
-
return n;
|
|
3109
|
-
};
|
|
3110
|
-
//#endregion
|
|
3111
|
-
//#region src/plugin/bindingify-hook-filter.ts
|
|
3112
|
-
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
3113
|
-
if (typeof matcher === "string" || matcher instanceof RegExp) return [include(generateAtomMatcher(stringKind, matcher))];
|
|
3114
|
-
if (Array.isArray(matcher)) return matcher.map((m) => include(generateAtomMatcher(stringKind, m)));
|
|
3115
|
-
let ret = [];
|
|
3116
|
-
if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => exclude(generateAtomMatcher(stringKind, m))));
|
|
3117
|
-
if (matcher.include) ret.push(...arraify(matcher.include).map((m) => include(generateAtomMatcher(stringKind, m))));
|
|
3118
|
-
return ret;
|
|
3119
|
-
}
|
|
3120
|
-
function generateAtomMatcher(kind, matcher) {
|
|
3121
|
-
return kind === "code" ? code(matcher) : id(matcher);
|
|
3122
|
-
}
|
|
3123
|
-
function transformFilterMatcherToFilterExprs(filterOption) {
|
|
3124
|
-
if (!filterOption) return;
|
|
3125
|
-
if (Array.isArray(filterOption)) return filterOption;
|
|
3126
|
-
const { id, code, moduleType: moduleType$1 } = filterOption;
|
|
3127
|
-
let ret = [];
|
|
3128
|
-
let idIncludes = [];
|
|
3129
|
-
let idExcludes = [];
|
|
3130
|
-
let codeIncludes = [];
|
|
3131
|
-
let codeExcludes = [];
|
|
3132
|
-
if (id) [idIncludes, idExcludes] = t(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m) => m.kind === "include");
|
|
3133
|
-
if (code) [codeIncludes, codeExcludes] = t(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m) => m.kind === "include");
|
|
3134
|
-
ret.push(...idExcludes);
|
|
3135
|
-
ret.push(...codeExcludes);
|
|
3136
|
-
let andExprList = [];
|
|
3137
|
-
if (moduleType$1) {
|
|
3138
|
-
let moduleTypes = Array.isArray(moduleType$1) ? moduleType$1 : moduleType$1.include ?? [];
|
|
3139
|
-
andExprList.push(or(...moduleTypes.map((m) => moduleType(m))));
|
|
2860
|
+
get dir() {
|
|
2861
|
+
return this.inner.dir ?? void 0;
|
|
3140
2862
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
if (andExprList.length) ret.push(include(and(...andExprList)));
|
|
3144
|
-
return ret;
|
|
3145
|
-
}
|
|
3146
|
-
function bindingifyGeneralHookFilter(stringKind, pattern) {
|
|
3147
|
-
let filterExprs = generalHookFilterMatcherToFilterExprs(pattern, stringKind);
|
|
3148
|
-
let ret = [];
|
|
3149
|
-
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
3150
|
-
return ret.length > 0 ? { value: ret } : void 0;
|
|
3151
|
-
}
|
|
3152
|
-
function bindingifyFilterExpr(expr) {
|
|
3153
|
-
let list = [];
|
|
3154
|
-
bindingifyFilterExprImpl(expr, list);
|
|
3155
|
-
return list;
|
|
3156
|
-
}
|
|
3157
|
-
function containsImporterId(expr) {
|
|
3158
|
-
switch (expr.kind) {
|
|
3159
|
-
case "and":
|
|
3160
|
-
case "or": return expr.args.some(containsImporterId);
|
|
3161
|
-
case "not":
|
|
3162
|
-
case "include":
|
|
3163
|
-
case "exclude": return containsImporterId(expr.expr);
|
|
3164
|
-
case "importerId": return true;
|
|
3165
|
-
default: return false;
|
|
2863
|
+
get entryFileNames() {
|
|
2864
|
+
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
3166
2865
|
}
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
if (filterExprs?.some(containsImporterId)) throw new Error(`The \`importerId\` filter can only be used with the \`resolveId\` hook, but it was used with the \`${hookName}\` hook.`);
|
|
3170
|
-
}
|
|
3171
|
-
function bindingifyFilterExprImpl(expr, list) {
|
|
3172
|
-
switch (expr.kind) {
|
|
3173
|
-
case "and": {
|
|
3174
|
-
let args = expr.args;
|
|
3175
|
-
for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
|
|
3176
|
-
list.push({
|
|
3177
|
-
kind: "And",
|
|
3178
|
-
payload: args.length
|
|
3179
|
-
});
|
|
3180
|
-
break;
|
|
3181
|
-
}
|
|
3182
|
-
case "or": {
|
|
3183
|
-
let args = expr.args;
|
|
3184
|
-
for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
|
|
3185
|
-
list.push({
|
|
3186
|
-
kind: "Or",
|
|
3187
|
-
payload: args.length
|
|
3188
|
-
});
|
|
3189
|
-
break;
|
|
3190
|
-
}
|
|
3191
|
-
case "not":
|
|
3192
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
3193
|
-
list.push({ kind: "Not" });
|
|
3194
|
-
break;
|
|
3195
|
-
case "id":
|
|
3196
|
-
list.push({
|
|
3197
|
-
kind: "Id",
|
|
3198
|
-
payload: expr.pattern
|
|
3199
|
-
});
|
|
3200
|
-
if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
|
|
3201
|
-
break;
|
|
3202
|
-
case "importerId":
|
|
3203
|
-
list.push({
|
|
3204
|
-
kind: "ImporterId",
|
|
3205
|
-
payload: expr.pattern
|
|
3206
|
-
});
|
|
3207
|
-
if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
|
|
3208
|
-
break;
|
|
3209
|
-
case "moduleType":
|
|
3210
|
-
list.push({
|
|
3211
|
-
kind: "ModuleType",
|
|
3212
|
-
payload: expr.pattern
|
|
3213
|
-
});
|
|
3214
|
-
break;
|
|
3215
|
-
case "code":
|
|
3216
|
-
list.push({
|
|
3217
|
-
kind: "Code",
|
|
3218
|
-
payload: expr.pattern
|
|
3219
|
-
});
|
|
3220
|
-
break;
|
|
3221
|
-
case "include":
|
|
3222
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
3223
|
-
list.push({ kind: "Include" });
|
|
3224
|
-
break;
|
|
3225
|
-
case "exclude":
|
|
3226
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
3227
|
-
list.push({ kind: "Exclude" });
|
|
3228
|
-
break;
|
|
3229
|
-
case "query":
|
|
3230
|
-
list.push({
|
|
3231
|
-
kind: "QueryKey",
|
|
3232
|
-
payload: expr.key
|
|
3233
|
-
});
|
|
3234
|
-
list.push({
|
|
3235
|
-
kind: "QueryValue",
|
|
3236
|
-
payload: expr.pattern
|
|
3237
|
-
});
|
|
3238
|
-
break;
|
|
3239
|
-
default: throw new Error(`Unknown filter expression: ${expr}`);
|
|
2866
|
+
get chunkFileNames() {
|
|
2867
|
+
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3240
2868
|
}
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
if (!filterOption) return;
|
|
3244
|
-
if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
|
|
3245
|
-
return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
|
|
3246
|
-
}
|
|
3247
|
-
function bindingifyLoadFilter(filterOption) {
|
|
3248
|
-
if (!filterOption) return;
|
|
3249
|
-
if (Array.isArray(filterOption)) {
|
|
3250
|
-
assertNoImporterId(filterOption, "load");
|
|
3251
|
-
return { value: filterOption.map(bindingifyFilterExpr) };
|
|
2869
|
+
get assetFileNames() {
|
|
2870
|
+
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
3252
2871
|
}
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
function bindingifyTransformFilter(filterOption) {
|
|
3256
|
-
if (!filterOption) return;
|
|
3257
|
-
let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
|
|
3258
|
-
assertNoImporterId(filterExprs, "transform");
|
|
3259
|
-
let ret = [];
|
|
3260
|
-
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
3261
|
-
return { value: ret.length > 0 ? ret : void 0 };
|
|
3262
|
-
}
|
|
3263
|
-
function bindingifyRenderChunkFilter(filterOption) {
|
|
3264
|
-
if (!filterOption) return;
|
|
3265
|
-
if (Array.isArray(filterOption)) {
|
|
3266
|
-
assertNoImporterId(filterOption, "renderChunk");
|
|
3267
|
-
return { value: filterOption.map(bindingifyFilterExpr) };
|
|
2872
|
+
get format() {
|
|
2873
|
+
return this.inner.format;
|
|
3268
2874
|
}
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
//#endregion
|
|
3272
|
-
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
3273
|
-
function bindingifyPluginHookMeta(options) {
|
|
3274
|
-
return { order: bindingPluginOrder(options.order) };
|
|
3275
|
-
}
|
|
3276
|
-
function bindingPluginOrder(order) {
|
|
3277
|
-
switch (order) {
|
|
3278
|
-
case "post": return BindingPluginOrder.Post;
|
|
3279
|
-
case "pre": return BindingPluginOrder.Pre;
|
|
3280
|
-
case null:
|
|
3281
|
-
case void 0: return;
|
|
3282
|
-
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
2875
|
+
get exports() {
|
|
2876
|
+
return this.inner.exports;
|
|
3283
2877
|
}
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
//#region src/plugin/fs.ts
|
|
3287
|
-
const fsModule = {
|
|
3288
|
-
appendFile: throwNoFileSystemError("fs.appendFile"),
|
|
3289
|
-
copyFile: throwNoFileSystemError("fs.copyFile"),
|
|
3290
|
-
mkdir: throwNoFileSystemError("fs.mkdir"),
|
|
3291
|
-
mkdtemp: throwNoFileSystemError("fs.mkdtemp"),
|
|
3292
|
-
readdir: throwNoFileSystemError("fs.readdir"),
|
|
3293
|
-
readFile: throwNoFileSystemError("fs.readFile"),
|
|
3294
|
-
realpath: throwNoFileSystemError("fs.realpath"),
|
|
3295
|
-
rename: throwNoFileSystemError("fs.rename"),
|
|
3296
|
-
rmdir: throwNoFileSystemError("fs.rmdir"),
|
|
3297
|
-
stat: throwNoFileSystemError("fs.stat"),
|
|
3298
|
-
lstat: throwNoFileSystemError("fs.lstat"),
|
|
3299
|
-
unlink: throwNoFileSystemError("fs.unlink"),
|
|
3300
|
-
writeFile: throwNoFileSystemError("fs.writeFile")
|
|
3301
|
-
};
|
|
3302
|
-
function throwNoFileSystemError(method) {
|
|
3303
|
-
return () => {
|
|
3304
|
-
error(logNoFileSystemInBrowser(method));
|
|
3305
|
-
};
|
|
3306
|
-
}
|
|
3307
|
-
//#endregion
|
|
3308
|
-
//#region src/plugin/plugin-context.ts
|
|
3309
|
-
var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
3310
|
-
outputOptions;
|
|
3311
|
-
context;
|
|
3312
|
-
data;
|
|
3313
|
-
onLog;
|
|
3314
|
-
currentLoadingModule;
|
|
3315
|
-
fs = fsModule;
|
|
3316
|
-
getModuleInfo;
|
|
3317
|
-
constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
|
|
3318
|
-
super(onLog, logLevel, plugin.name, watchMode);
|
|
3319
|
-
this.outputOptions = outputOptions;
|
|
3320
|
-
this.context = context;
|
|
3321
|
-
this.data = data;
|
|
3322
|
-
this.onLog = onLog;
|
|
3323
|
-
this.currentLoadingModule = currentLoadingModule;
|
|
3324
|
-
this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
|
|
2878
|
+
get sourcemap() {
|
|
2879
|
+
return this.inner.sourcemap;
|
|
3325
2880
|
}
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
3329
|
-
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
3330
|
-
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
3331
|
-
const rawOptions = {
|
|
3332
|
-
meta: options.meta || {},
|
|
3333
|
-
moduleSideEffects: options.moduleSideEffects || null,
|
|
3334
|
-
invalidate: false
|
|
3335
|
-
};
|
|
3336
|
-
this.data.updateModuleOption(id, rawOptions);
|
|
3337
|
-
let loadPromise = this.data.loadModulePromiseMap.get(id);
|
|
3338
|
-
if (!loadPromise) {
|
|
3339
|
-
loadPromise = this.context.load(id, options.moduleSideEffects ?? void 0, options.packageJsonPath ?? void 0).catch(() => {
|
|
3340
|
-
this.data.loadModulePromiseMap.delete(id);
|
|
3341
|
-
});
|
|
3342
|
-
this.data.loadModulePromiseMap.set(id, loadPromise);
|
|
3343
|
-
}
|
|
3344
|
-
await loadPromise;
|
|
3345
|
-
return this.data.getModuleInfo(id, this.context);
|
|
2881
|
+
get sourcemapBaseUrl() {
|
|
2882
|
+
return this.inner.sourcemapBaseUrl ?? void 0;
|
|
3346
2883
|
}
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
if (options != null) receipt = this.data.saveResolveOptions(options);
|
|
3350
|
-
const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
|
|
3351
|
-
if (key.startsWith("vite:")) (acc ??= {})[key] = value;
|
|
3352
|
-
return acc;
|
|
3353
|
-
}, void 0);
|
|
3354
|
-
const res = await this.context.resolve(source, importer, {
|
|
3355
|
-
importKind: options?.kind,
|
|
3356
|
-
custom: receipt,
|
|
3357
|
-
isEntry: options?.isEntry,
|
|
3358
|
-
skipSelf: options?.skipSelf,
|
|
3359
|
-
vitePluginCustom
|
|
3360
|
-
});
|
|
3361
|
-
if (receipt != null) this.data.removeSavedResolveOptions(receipt);
|
|
3362
|
-
if (res == null) return null;
|
|
3363
|
-
const info = this.data.getModuleOption(res.id) || {};
|
|
3364
|
-
return {
|
|
3365
|
-
...res,
|
|
3366
|
-
external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
|
|
3367
|
-
...info,
|
|
3368
|
-
moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null,
|
|
3369
|
-
packageJsonPath: res.packageJsonPath
|
|
3370
|
-
};
|
|
2884
|
+
get shimMissingExports() {
|
|
2885
|
+
return this.inner.shimMissingExports;
|
|
3371
2886
|
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
fileName: file.fileName,
|
|
3375
|
-
name: file.name,
|
|
3376
|
-
code: file.code,
|
|
3377
|
-
exports: file.exports,
|
|
3378
|
-
map: bindingifySourcemap$1(file.map),
|
|
3379
|
-
sourcemapFileName: file.sourcemapFileName,
|
|
3380
|
-
facadeModuleId: file.facadeModuleId,
|
|
3381
|
-
isEntry: file.isEntry,
|
|
3382
|
-
isDynamicEntry: file.isDynamicEntry
|
|
3383
|
-
});
|
|
3384
|
-
if (file.type === "chunk") return this.context.emitChunk({
|
|
3385
|
-
preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
|
|
3386
|
-
...file
|
|
3387
|
-
});
|
|
3388
|
-
const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
|
|
3389
|
-
const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
|
|
3390
|
-
return this.context.emitFile({
|
|
3391
|
-
...file,
|
|
3392
|
-
originalFileName: file.originalFileName || void 0,
|
|
3393
|
-
source: bindingAssetSource(file.source)
|
|
3394
|
-
}, filename, fnSanitizedFileName);
|
|
3395
|
-
};
|
|
3396
|
-
getAssetFileNames(file) {
|
|
3397
|
-
if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
|
|
3398
|
-
type: "asset",
|
|
3399
|
-
name: file.name,
|
|
3400
|
-
names: file.name ? [file.name] : [],
|
|
3401
|
-
originalFileName: file.originalFileName,
|
|
3402
|
-
originalFileNames: file.originalFileName ? [file.originalFileName] : [],
|
|
3403
|
-
source: file.source
|
|
3404
|
-
});
|
|
2887
|
+
get name() {
|
|
2888
|
+
return this.inner.name ?? void 0;
|
|
3405
2889
|
}
|
|
3406
|
-
|
|
3407
|
-
return this.
|
|
2890
|
+
get file() {
|
|
2891
|
+
return this.inner.file ?? void 0;
|
|
3408
2892
|
}
|
|
3409
|
-
|
|
3410
|
-
return this.
|
|
2893
|
+
get codeSplitting() {
|
|
2894
|
+
return this.inner.codeSplitting;
|
|
3411
2895
|
}
|
|
3412
|
-
|
|
3413
|
-
|
|
2896
|
+
/**
|
|
2897
|
+
* @deprecated Use `codeSplitting` instead.
|
|
2898
|
+
*/
|
|
2899
|
+
get inlineDynamicImports() {
|
|
2900
|
+
return !this.inner.codeSplitting;
|
|
3414
2901
|
}
|
|
3415
|
-
|
|
3416
|
-
return
|
|
2902
|
+
get dynamicImportInCjs() {
|
|
2903
|
+
return this.inner.dynamicImportInCjs;
|
|
3417
2904
|
}
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
//#region src/plugin/load-plugin-context.ts
|
|
3421
|
-
var LoadPluginContextImpl = class extends PluginContextImpl {
|
|
3422
|
-
inner;
|
|
3423
|
-
constructor(outputOptions, context, plugin, data, inner, moduleId, onLog, logLevelOption, watchMode) {
|
|
3424
|
-
super(outputOptions, context, plugin, data, onLog, logLevelOption, watchMode, moduleId);
|
|
3425
|
-
this.inner = inner;
|
|
2905
|
+
get externalLiveBindings() {
|
|
2906
|
+
return this.inner.externalLiveBindings;
|
|
3426
2907
|
}
|
|
3427
|
-
|
|
3428
|
-
this.
|
|
2908
|
+
get banner() {
|
|
2909
|
+
return normalizeAddon(this.outputOptions.banner);
|
|
3429
2910
|
}
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
this.
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
2911
|
+
get footer() {
|
|
2912
|
+
return normalizeAddon(this.outputOptions.footer);
|
|
2913
|
+
}
|
|
2914
|
+
get postBanner() {
|
|
2915
|
+
return normalizeAddon(this.outputOptions.postBanner);
|
|
2916
|
+
}
|
|
2917
|
+
get postFooter() {
|
|
2918
|
+
return normalizeAddon(this.outputOptions.postFooter);
|
|
2919
|
+
}
|
|
2920
|
+
get intro() {
|
|
2921
|
+
return normalizeAddon(this.outputOptions.intro);
|
|
2922
|
+
}
|
|
2923
|
+
get outro() {
|
|
2924
|
+
return normalizeAddon(this.outputOptions.outro);
|
|
2925
|
+
}
|
|
2926
|
+
get esModule() {
|
|
2927
|
+
return this.inner.esModule;
|
|
2928
|
+
}
|
|
2929
|
+
get extend() {
|
|
2930
|
+
return this.inner.extend;
|
|
2931
|
+
}
|
|
2932
|
+
get globals() {
|
|
2933
|
+
return this.inner.globals || this.outputOptions.globals;
|
|
2934
|
+
}
|
|
2935
|
+
get paths() {
|
|
2936
|
+
return this.outputOptions.paths;
|
|
2937
|
+
}
|
|
2938
|
+
get hashCharacters() {
|
|
2939
|
+
return this.inner.hashCharacters;
|
|
2940
|
+
}
|
|
2941
|
+
get sourcemapDebugIds() {
|
|
2942
|
+
return this.inner.sourcemapDebugIds;
|
|
2943
|
+
}
|
|
2944
|
+
get sourcemapExcludeSources() {
|
|
2945
|
+
return this.inner.sourcemapExcludeSources;
|
|
2946
|
+
}
|
|
2947
|
+
get sourcemapIgnoreList() {
|
|
2948
|
+
return this.outputOptions.sourcemapIgnoreList;
|
|
2949
|
+
}
|
|
2950
|
+
get sourcemapPathTransform() {
|
|
2951
|
+
return this.outputOptions.sourcemapPathTransform;
|
|
2952
|
+
}
|
|
2953
|
+
get minify() {
|
|
2954
|
+
let ret = this.inner.minify;
|
|
2955
|
+
if (typeof ret === "object" && ret !== null) {
|
|
2956
|
+
delete ret["codegen"];
|
|
2957
|
+
delete ret["module"];
|
|
2958
|
+
delete ret["sourcemap"];
|
|
2959
|
+
}
|
|
2960
|
+
return ret;
|
|
2961
|
+
}
|
|
2962
|
+
get legalComments() {
|
|
2963
|
+
return this.inner.legalComments;
|
|
2964
|
+
}
|
|
2965
|
+
get comments() {
|
|
2966
|
+
const c = this.inner.comments;
|
|
2967
|
+
return {
|
|
2968
|
+
legal: c.legal ?? true,
|
|
2969
|
+
annotation: c.annotation ?? true,
|
|
2970
|
+
jsdoc: c.jsdoc ?? true
|
|
3448
2971
|
};
|
|
3449
|
-
this.debug = getLogHandler(this.debug);
|
|
3450
|
-
this.warn = getLogHandler(this.warn);
|
|
3451
|
-
this.info = getLogHandler(this.info);
|
|
3452
2972
|
}
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
3456
|
-
e.id = this.moduleId;
|
|
3457
|
-
e.hook = "transform";
|
|
3458
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
2973
|
+
get polyfillRequire() {
|
|
2974
|
+
return this.inner.polyfillRequire;
|
|
3459
2975
|
}
|
|
3460
|
-
|
|
3461
|
-
return
|
|
2976
|
+
get plugins() {
|
|
2977
|
+
return this.normalizedOutputPlugins;
|
|
3462
2978
|
}
|
|
3463
|
-
|
|
3464
|
-
this.inner.
|
|
2979
|
+
get preserveModules() {
|
|
2980
|
+
return this.inner.preserveModules;
|
|
3465
2981
|
}
|
|
3466
|
-
|
|
3467
|
-
this.inner.
|
|
2982
|
+
get preserveModulesRoot() {
|
|
2983
|
+
return this.inner.preserveModulesRoot;
|
|
2984
|
+
}
|
|
2985
|
+
get virtualDirname() {
|
|
2986
|
+
return this.inner.virtualDirname;
|
|
2987
|
+
}
|
|
2988
|
+
get topLevelVar() {
|
|
2989
|
+
return this.inner.topLevelVar ?? false;
|
|
2990
|
+
}
|
|
2991
|
+
get minifyInternalExports() {
|
|
2992
|
+
return this.inner.minifyInternalExports ?? false;
|
|
3468
2993
|
}
|
|
3469
2994
|
};
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
};
|
|
3514
|
-
if (typeof ret === "string") return {
|
|
3515
|
-
id: ret,
|
|
3516
|
-
normalizeExternalId: false
|
|
3517
|
-
};
|
|
3518
|
-
let exist = args.pluginContextData.updateModuleOption(ret.id, {
|
|
3519
|
-
meta: ret.meta || {},
|
|
3520
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3521
|
-
invalidate: false
|
|
3522
|
-
});
|
|
3523
|
-
return {
|
|
3524
|
-
id: ret.id,
|
|
3525
|
-
external: ret.external,
|
|
3526
|
-
normalizeExternalId: false,
|
|
3527
|
-
moduleSideEffects: exist.moduleSideEffects ?? void 0,
|
|
3528
|
-
packageJsonPath: ret.packageJsonPath
|
|
3529
|
-
};
|
|
3530
|
-
},
|
|
3531
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
3532
|
-
filter: bindingifyResolveIdFilter(options.filter)
|
|
3533
|
-
};
|
|
3534
|
-
}
|
|
3535
|
-
function bindingifyResolveDynamicImport(args) {
|
|
3536
|
-
const hook = args.plugin.resolveDynamicImport;
|
|
3537
|
-
if (!hook) return {};
|
|
3538
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3539
|
-
return {
|
|
3540
|
-
plugin: async (ctx, specifier, importer) => {
|
|
3541
|
-
const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0);
|
|
3542
|
-
if (ret == null) return;
|
|
3543
|
-
if (ret === false) return {
|
|
3544
|
-
id: specifier,
|
|
3545
|
-
external: true
|
|
3546
|
-
};
|
|
3547
|
-
if (typeof ret === "string") return { id: ret };
|
|
3548
|
-
const result = {
|
|
3549
|
-
id: ret.id,
|
|
3550
|
-
external: ret.external,
|
|
3551
|
-
packageJsonPath: ret.packageJsonPath
|
|
3552
|
-
};
|
|
3553
|
-
if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
|
|
3554
|
-
args.pluginContextData.updateModuleOption(ret.id, {
|
|
3555
|
-
meta: ret.meta || {},
|
|
3556
|
-
moduleSideEffects: ret.moduleSideEffects || null,
|
|
3557
|
-
invalidate: false
|
|
3558
|
-
});
|
|
3559
|
-
return result;
|
|
3560
|
-
},
|
|
3561
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3562
|
-
};
|
|
3563
|
-
}
|
|
3564
|
-
function bindingifyTransform(args) {
|
|
3565
|
-
const hook = args.plugin.transform;
|
|
3566
|
-
if (!hook) return {};
|
|
3567
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
3568
|
-
return {
|
|
3569
|
-
plugin: async (ctx, code, id, meta) => {
|
|
3570
|
-
let magicStringInstance, astInstance;
|
|
3571
|
-
Object.defineProperties(meta, {
|
|
3572
|
-
magicString: { get() {
|
|
3573
|
-
if (magicStringInstance) return magicStringInstance;
|
|
3574
|
-
magicStringInstance = new RolldownMagicString(code);
|
|
3575
|
-
return magicStringInstance;
|
|
3576
|
-
} },
|
|
3577
|
-
ast: { get() {
|
|
3578
|
-
if (astInstance) return astInstance;
|
|
3579
|
-
let lang = "js";
|
|
3580
|
-
switch (meta.moduleType) {
|
|
3581
|
-
case "js":
|
|
3582
|
-
case "jsx":
|
|
3583
|
-
case "ts":
|
|
3584
|
-
case "tsx":
|
|
3585
|
-
lang = meta.moduleType;
|
|
3586
|
-
break;
|
|
3587
|
-
default: break;
|
|
3588
|
-
}
|
|
3589
|
-
astInstance = parseAst(code, {
|
|
3590
|
-
astType: meta.moduleType.includes("ts") ? "ts" : "js",
|
|
3591
|
-
lang
|
|
3592
|
-
});
|
|
3593
|
-
return astInstance;
|
|
3594
|
-
} }
|
|
3595
|
-
});
|
|
3596
|
-
const transformCtx = new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel, args.watchMode);
|
|
3597
|
-
const ret = await handler.call(transformCtx, code, id, meta);
|
|
3598
|
-
if (ret == null) return;
|
|
3599
|
-
if (typeof ret === "string") return { code: ret };
|
|
3600
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
3601
|
-
meta: ret.meta ?? {},
|
|
3602
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3603
|
-
invalidate: false
|
|
3604
|
-
});
|
|
3605
|
-
let normalizedCode = void 0;
|
|
3606
|
-
let map = ret.map;
|
|
3607
|
-
let mapHandledByNativeChannel = false;
|
|
3608
|
-
if (typeof ret.code === "string") normalizedCode = ret.code;
|
|
3609
|
-
else if (ret.code instanceof RolldownMagicString) {
|
|
3610
|
-
let magicString = ret.code;
|
|
3611
|
-
normalizedCode = magicString.toString();
|
|
3612
|
-
let fallbackSourcemap = ctx.sendMagicString(magicString);
|
|
3613
|
-
if (fallbackSourcemap != void 0) map = fallbackSourcemap;
|
|
3614
|
-
else mapHandledByNativeChannel = true;
|
|
3615
|
-
}
|
|
3616
|
-
return {
|
|
3617
|
-
code: normalizedCode,
|
|
3618
|
-
map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id, code, map)) ?? (mapHandledByNativeChannel || ret.map === null ? null : void 0),
|
|
3619
|
-
moduleSideEffects: moduleOption.moduleSideEffects ?? void 0,
|
|
3620
|
-
moduleType: ret.moduleType
|
|
3621
|
-
};
|
|
3622
|
-
},
|
|
3623
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
3624
|
-
filter: bindingifyTransformFilter(options.filter)
|
|
3625
|
-
};
|
|
2995
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dir", null);
|
|
2996
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "entryFileNames", null);
|
|
2997
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "chunkFileNames", null);
|
|
2998
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "assetFileNames", null);
|
|
2999
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "format", null);
|
|
3000
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "exports", null);
|
|
3001
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemap", null);
|
|
3002
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapBaseUrl", null);
|
|
3003
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "shimMissingExports", null);
|
|
3004
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "name", null);
|
|
3005
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "file", null);
|
|
3006
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "codeSplitting", null);
|
|
3007
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "inlineDynamicImports", null);
|
|
3008
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dynamicImportInCjs", null);
|
|
3009
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "externalLiveBindings", null);
|
|
3010
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "banner", null);
|
|
3011
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "footer", null);
|
|
3012
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postBanner", null);
|
|
3013
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postFooter", null);
|
|
3014
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "intro", null);
|
|
3015
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "outro", null);
|
|
3016
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "esModule", null);
|
|
3017
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "extend", null);
|
|
3018
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "globals", null);
|
|
3019
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "paths", null);
|
|
3020
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "hashCharacters", null);
|
|
3021
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapDebugIds", null);
|
|
3022
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapExcludeSources", null);
|
|
3023
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapIgnoreList", null);
|
|
3024
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapPathTransform", null);
|
|
3025
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minify", null);
|
|
3026
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "legalComments", null);
|
|
3027
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "comments", null);
|
|
3028
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "polyfillRequire", null);
|
|
3029
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "plugins", null);
|
|
3030
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModules", null);
|
|
3031
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModulesRoot", null);
|
|
3032
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "virtualDirname", null);
|
|
3033
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "topLevelVar", null);
|
|
3034
|
+
__decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minifyInternalExports", null);
|
|
3035
|
+
function normalizeAddon(value) {
|
|
3036
|
+
if (typeof value === "function") return value;
|
|
3037
|
+
return () => value || "";
|
|
3626
3038
|
}
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
3039
|
+
//#endregion
|
|
3040
|
+
//#region src/utils/transform-module-info.ts
|
|
3041
|
+
function transformModuleInfo(info, option) {
|
|
3631
3042
|
return {
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
if (ret == null) return;
|
|
3635
|
-
if (typeof ret === "string") return { code: ret };
|
|
3636
|
-
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
3637
|
-
meta: ret.meta || {},
|
|
3638
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3639
|
-
invalidate: false
|
|
3640
|
-
});
|
|
3641
|
-
let map = preProcessSourceMap(ret, id);
|
|
3642
|
-
return {
|
|
3643
|
-
code: ret.code,
|
|
3644
|
-
map: bindingifySourcemap$1(map),
|
|
3645
|
-
moduleType: ret.moduleType,
|
|
3646
|
-
moduleSideEffects: moduleOption.moduleSideEffects ?? void 0
|
|
3647
|
-
};
|
|
3043
|
+
get ast() {
|
|
3044
|
+
return unsupported("ModuleInfo#ast");
|
|
3648
3045
|
},
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
};
|
|
3652
|
-
}
|
|
3653
|
-
function preProcessSourceMap(ret, id) {
|
|
3654
|
-
if (!ret.map) return;
|
|
3655
|
-
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
3656
|
-
if (!isEmptySourcemapFiled(map.sources)) {
|
|
3657
|
-
const directory = posix.dirname(id) || ".";
|
|
3658
|
-
const sourceRoot = map.sourceRoot || ".";
|
|
3659
|
-
map.sources = map.sources.map((source) => posix.resolve(directory, sourceRoot, source));
|
|
3660
|
-
}
|
|
3661
|
-
return map;
|
|
3662
|
-
}
|
|
3663
|
-
function bindingifyModuleParsed(args) {
|
|
3664
|
-
const hook = args.plugin.moduleParsed;
|
|
3665
|
-
if (!hook) return {};
|
|
3666
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3667
|
-
return {
|
|
3668
|
-
plugin: async (ctx, moduleInfo) => {
|
|
3669
|
-
await handler.call(createPluginContext(args, ctx), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
3046
|
+
get code() {
|
|
3047
|
+
return info.code;
|
|
3670
3048
|
},
|
|
3671
|
-
|
|
3049
|
+
id: info.id,
|
|
3050
|
+
importers: info.importers,
|
|
3051
|
+
dynamicImporters: info.dynamicImporters,
|
|
3052
|
+
importedIds: info.importedIds,
|
|
3053
|
+
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
3054
|
+
exports: info.exports,
|
|
3055
|
+
isEntry: info.isEntry,
|
|
3056
|
+
inputFormat: info.inputFormat,
|
|
3057
|
+
...option
|
|
3672
3058
|
};
|
|
3673
3059
|
}
|
|
3674
3060
|
//#endregion
|
|
3675
|
-
//#region src/plugin/
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
if (
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
map: bindingifySourcemap$1({
|
|
3712
|
-
file: generatedMap.file,
|
|
3713
|
-
mappings: generatedMap.mappings,
|
|
3714
|
-
names: generatedMap.names,
|
|
3715
|
-
sources: generatedMap.sources,
|
|
3716
|
-
sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
|
|
3717
|
-
})
|
|
3718
|
-
};
|
|
3719
|
-
}
|
|
3720
|
-
if (typeof ret === "string") return { code: ret };
|
|
3721
|
-
if (ret.code instanceof RolldownMagicString) {
|
|
3722
|
-
const magicString = ret.code;
|
|
3723
|
-
const normalizedCode = magicString.toString();
|
|
3724
|
-
if (ret.map === null) return {
|
|
3725
|
-
code: normalizedCode,
|
|
3726
|
-
map: null
|
|
3727
|
-
};
|
|
3728
|
-
if (ret.map === void 0) {
|
|
3729
|
-
const generatedMap = magicString.generateMap();
|
|
3730
|
-
return {
|
|
3731
|
-
code: normalizedCode,
|
|
3732
|
-
map: bindingifySourcemap$1({
|
|
3733
|
-
file: generatedMap.file,
|
|
3734
|
-
mappings: generatedMap.mappings,
|
|
3735
|
-
names: generatedMap.names,
|
|
3736
|
-
sources: generatedMap.sources,
|
|
3737
|
-
sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
|
|
3738
|
-
})
|
|
3739
|
-
};
|
|
3740
|
-
}
|
|
3741
|
-
return {
|
|
3742
|
-
code: normalizedCode,
|
|
3743
|
-
map: bindingifySourcemap$1(ret.map)
|
|
3744
|
-
};
|
|
3745
|
-
}
|
|
3746
|
-
if (ret.map === null) return {
|
|
3747
|
-
code: ret.code,
|
|
3748
|
-
map: null
|
|
3749
|
-
};
|
|
3750
|
-
return {
|
|
3751
|
-
code: ret.code,
|
|
3752
|
-
map: bindingifySourcemap$1(ret.map)
|
|
3753
|
-
};
|
|
3754
|
-
},
|
|
3755
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
3756
|
-
filter: bindingifyRenderChunkFilter(options.filter)
|
|
3757
|
-
};
|
|
3758
|
-
}
|
|
3759
|
-
function bindingifyAugmentChunkHash(args) {
|
|
3760
|
-
const hook = args.plugin.augmentChunkHash;
|
|
3761
|
-
if (!hook) return {};
|
|
3762
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3763
|
-
return {
|
|
3764
|
-
plugin: async (ctx, chunk) => {
|
|
3765
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3766
|
-
},
|
|
3767
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3768
|
-
};
|
|
3769
|
-
}
|
|
3770
|
-
function bindingifyRenderError(args) {
|
|
3771
|
-
const hook = args.plugin.renderError;
|
|
3772
|
-
if (!hook) return {};
|
|
3773
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3774
|
-
return {
|
|
3775
|
-
plugin: async (ctx, err) => {
|
|
3776
|
-
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), aggregateBindingErrorsIntoJsError(err));
|
|
3777
|
-
},
|
|
3778
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3779
|
-
};
|
|
3780
|
-
}
|
|
3781
|
-
function bindingifyGenerateBundle(args) {
|
|
3782
|
-
const hook = args.plugin.generateBundle;
|
|
3783
|
-
if (!hook) return {};
|
|
3784
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3785
|
-
return {
|
|
3786
|
-
plugin: async (ctx, bundle, isWrite, opts) => {
|
|
3787
|
-
const changed = {
|
|
3788
|
-
updated: /* @__PURE__ */ new Set(),
|
|
3789
|
-
deleted: /* @__PURE__ */ new Set()
|
|
3790
|
-
};
|
|
3791
|
-
const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
|
|
3792
|
-
const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
|
|
3793
|
-
await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
|
|
3794
|
-
return collectChangedBundle(changed, output);
|
|
3795
|
-
},
|
|
3796
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3797
|
-
};
|
|
3798
|
-
}
|
|
3799
|
-
function bindingifyWriteBundle(args) {
|
|
3800
|
-
const hook = args.plugin.writeBundle;
|
|
3801
|
-
if (!hook) return {};
|
|
3802
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3803
|
-
return {
|
|
3804
|
-
plugin: async (ctx, bundle, opts) => {
|
|
3805
|
-
const changed = {
|
|
3806
|
-
updated: /* @__PURE__ */ new Set(),
|
|
3807
|
-
deleted: /* @__PURE__ */ new Set()
|
|
3061
|
+
//#region src/plugin/plugin-context-data.ts
|
|
3062
|
+
var PluginContextData = class {
|
|
3063
|
+
onLog;
|
|
3064
|
+
outputOptions;
|
|
3065
|
+
normalizedInputPlugins;
|
|
3066
|
+
normalizedOutputPlugins;
|
|
3067
|
+
moduleOptionMap = /* @__PURE__ */ new Map();
|
|
3068
|
+
resolveOptionsMap = /* @__PURE__ */ new Map();
|
|
3069
|
+
loadModulePromiseMap = /* @__PURE__ */ new Map();
|
|
3070
|
+
renderedChunkMeta = null;
|
|
3071
|
+
normalizedInputOptions = null;
|
|
3072
|
+
normalizedOutputOptions = null;
|
|
3073
|
+
constructor(onLog, outputOptions, normalizedInputPlugins, normalizedOutputPlugins) {
|
|
3074
|
+
this.onLog = onLog;
|
|
3075
|
+
this.outputOptions = outputOptions;
|
|
3076
|
+
this.normalizedInputPlugins = normalizedInputPlugins;
|
|
3077
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3078
|
+
}
|
|
3079
|
+
updateModuleOption(id, option) {
|
|
3080
|
+
const existing = this.moduleOptionMap.get(id);
|
|
3081
|
+
if (existing) {
|
|
3082
|
+
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
3083
|
+
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
3084
|
+
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
3085
|
+
} else {
|
|
3086
|
+
this.moduleOptionMap.set(id, option);
|
|
3087
|
+
return option;
|
|
3088
|
+
}
|
|
3089
|
+
return existing;
|
|
3090
|
+
}
|
|
3091
|
+
getModuleOption(id) {
|
|
3092
|
+
const option = this.moduleOptionMap.get(id);
|
|
3093
|
+
if (!option) {
|
|
3094
|
+
const raw = {
|
|
3095
|
+
moduleSideEffects: null,
|
|
3096
|
+
meta: {}
|
|
3808
3097
|
};
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
},
|
|
3814
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3815
|
-
};
|
|
3816
|
-
}
|
|
3817
|
-
function bindingifyCloseBundle(args) {
|
|
3818
|
-
const hook = args.plugin.closeBundle;
|
|
3819
|
-
if (!hook) return {};
|
|
3820
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3821
|
-
return {
|
|
3822
|
-
plugin: async (ctx, err) => {
|
|
3823
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
|
|
3824
|
-
},
|
|
3825
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3826
|
-
};
|
|
3827
|
-
}
|
|
3828
|
-
function bindingifyBanner(args) {
|
|
3829
|
-
const hook = args.plugin.banner;
|
|
3830
|
-
if (!hook) return {};
|
|
3831
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3832
|
-
return {
|
|
3833
|
-
plugin: async (ctx, chunk) => {
|
|
3834
|
-
if (typeof handler === "string") return handler;
|
|
3835
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3836
|
-
},
|
|
3837
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3838
|
-
};
|
|
3839
|
-
}
|
|
3840
|
-
function bindingifyFooter(args) {
|
|
3841
|
-
const hook = args.plugin.footer;
|
|
3842
|
-
if (!hook) return {};
|
|
3843
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3844
|
-
return {
|
|
3845
|
-
plugin: async (ctx, chunk) => {
|
|
3846
|
-
if (typeof handler === "string") return handler;
|
|
3847
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3848
|
-
},
|
|
3849
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3850
|
-
};
|
|
3851
|
-
}
|
|
3852
|
-
function bindingifyIntro(args) {
|
|
3853
|
-
const hook = args.plugin.intro;
|
|
3854
|
-
if (!hook) return {};
|
|
3855
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3856
|
-
return {
|
|
3857
|
-
plugin: async (ctx, chunk) => {
|
|
3858
|
-
if (typeof handler === "string") return handler;
|
|
3859
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3860
|
-
},
|
|
3861
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3862
|
-
};
|
|
3863
|
-
}
|
|
3864
|
-
function bindingifyOutro(args) {
|
|
3865
|
-
const hook = args.plugin.outro;
|
|
3866
|
-
if (!hook) return {};
|
|
3867
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3868
|
-
return {
|
|
3869
|
-
plugin: async (ctx, chunk) => {
|
|
3870
|
-
if (typeof handler === "string") return handler;
|
|
3871
|
-
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
3872
|
-
},
|
|
3873
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3874
|
-
};
|
|
3875
|
-
}
|
|
3876
|
-
//#endregion
|
|
3877
|
-
//#region src/plugin/bindingify-watch-hooks.ts
|
|
3878
|
-
function bindingifyWatchChange(args) {
|
|
3879
|
-
const hook = args.plugin.watchChange;
|
|
3880
|
-
if (!hook) return {};
|
|
3881
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3882
|
-
return {
|
|
3883
|
-
plugin: async (ctx, id, event) => {
|
|
3884
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
|
|
3885
|
-
},
|
|
3886
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3887
|
-
};
|
|
3888
|
-
}
|
|
3889
|
-
function bindingifyCloseWatcher(args) {
|
|
3890
|
-
const hook = args.plugin.closeWatcher;
|
|
3891
|
-
if (!hook) return {};
|
|
3892
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3893
|
-
return {
|
|
3894
|
-
plugin: async (ctx) => {
|
|
3895
|
-
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
3896
|
-
},
|
|
3897
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3898
|
-
};
|
|
3899
|
-
}
|
|
3900
|
-
//#endregion
|
|
3901
|
-
//#region src/plugin/generated/hook-usage.ts
|
|
3902
|
-
var HookUsage = class {
|
|
3903
|
-
bitflag = BigInt(0);
|
|
3904
|
-
constructor() {}
|
|
3905
|
-
union(kind) {
|
|
3906
|
-
this.bitflag |= BigInt(kind);
|
|
3098
|
+
this.moduleOptionMap.set(id, raw);
|
|
3099
|
+
return raw;
|
|
3100
|
+
}
|
|
3101
|
+
return option;
|
|
3907
3102
|
}
|
|
3908
|
-
|
|
3909
|
-
|
|
3103
|
+
getModuleInfo(id, context) {
|
|
3104
|
+
const bindingInfo = context.getModuleInfo(id);
|
|
3105
|
+
if (bindingInfo) {
|
|
3106
|
+
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
|
|
3107
|
+
return this.proxyModuleInfo(id, info);
|
|
3108
|
+
}
|
|
3109
|
+
return null;
|
|
3910
3110
|
}
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
if (plugin.augmentChunkHash) hookUsage.union(1024);
|
|
3925
|
-
if (plugin.generateBundle) hookUsage.union(2048);
|
|
3926
|
-
if (plugin.writeBundle) hookUsage.union(4096);
|
|
3927
|
-
if (plugin.closeBundle) hookUsage.union(8192);
|
|
3928
|
-
if (plugin.watchChange) hookUsage.union(16384);
|
|
3929
|
-
if (plugin.closeWatcher) hookUsage.union(32768);
|
|
3930
|
-
if (plugin.banner) hookUsage.union(131072);
|
|
3931
|
-
if (plugin.footer) hookUsage.union(262144);
|
|
3932
|
-
if (plugin.intro) hookUsage.union(524288);
|
|
3933
|
-
if (plugin.outro) hookUsage.union(1048576);
|
|
3934
|
-
return hookUsage;
|
|
3935
|
-
}
|
|
3936
|
-
//#endregion
|
|
3937
|
-
//#region src/plugin/bindingify-plugin.ts
|
|
3938
|
-
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
3939
|
-
const args = {
|
|
3940
|
-
plugin,
|
|
3941
|
-
options,
|
|
3942
|
-
outputOptions,
|
|
3943
|
-
pluginContextData,
|
|
3944
|
-
onLog,
|
|
3945
|
-
logLevel,
|
|
3946
|
-
watchMode,
|
|
3947
|
-
normalizedOutputPlugins
|
|
3948
|
-
};
|
|
3949
|
-
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
3950
|
-
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
|
|
3951
|
-
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
3952
|
-
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
3953
|
-
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
|
|
3954
|
-
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
3955
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
|
|
3956
|
-
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
|
|
3957
|
-
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
3958
|
-
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
3959
|
-
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
3960
|
-
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
3961
|
-
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
3962
|
-
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
3963
|
-
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
3964
|
-
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
3965
|
-
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
3966
|
-
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
3967
|
-
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
3968
|
-
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
3969
|
-
let hookUsage = extractHookUsage(plugin).inner();
|
|
3970
|
-
return wrapHandlers({
|
|
3971
|
-
name: plugin.name,
|
|
3972
|
-
buildStart,
|
|
3973
|
-
buildStartMeta,
|
|
3974
|
-
resolveId,
|
|
3975
|
-
resolveIdMeta,
|
|
3976
|
-
resolveIdFilter,
|
|
3977
|
-
resolveDynamicImport,
|
|
3978
|
-
resolveDynamicImportMeta,
|
|
3979
|
-
buildEnd,
|
|
3980
|
-
buildEndMeta,
|
|
3981
|
-
transform,
|
|
3982
|
-
transformMeta,
|
|
3983
|
-
transformFilter,
|
|
3984
|
-
moduleParsed,
|
|
3985
|
-
moduleParsedMeta,
|
|
3986
|
-
load,
|
|
3987
|
-
loadMeta,
|
|
3988
|
-
loadFilter,
|
|
3989
|
-
renderChunk,
|
|
3990
|
-
renderChunkMeta,
|
|
3991
|
-
renderChunkFilter,
|
|
3992
|
-
augmentChunkHash,
|
|
3993
|
-
augmentChunkHashMeta,
|
|
3994
|
-
renderStart,
|
|
3995
|
-
renderStartMeta,
|
|
3996
|
-
renderError,
|
|
3997
|
-
renderErrorMeta,
|
|
3998
|
-
generateBundle,
|
|
3999
|
-
generateBundleMeta,
|
|
4000
|
-
writeBundle,
|
|
4001
|
-
writeBundleMeta,
|
|
4002
|
-
closeBundle,
|
|
4003
|
-
closeBundleMeta,
|
|
4004
|
-
banner,
|
|
4005
|
-
bannerMeta,
|
|
4006
|
-
footer,
|
|
4007
|
-
footerMeta,
|
|
4008
|
-
intro,
|
|
4009
|
-
introMeta,
|
|
4010
|
-
outro,
|
|
4011
|
-
outroMeta,
|
|
4012
|
-
watchChange,
|
|
4013
|
-
watchChangeMeta,
|
|
4014
|
-
closeWatcher,
|
|
4015
|
-
closeWatcherMeta,
|
|
4016
|
-
hookUsage
|
|
4017
|
-
});
|
|
4018
|
-
}
|
|
4019
|
-
function wrapHandlers(plugin) {
|
|
4020
|
-
for (const hookName of [
|
|
4021
|
-
"buildStart",
|
|
4022
|
-
"resolveId",
|
|
4023
|
-
"resolveDynamicImport",
|
|
4024
|
-
"buildEnd",
|
|
4025
|
-
"transform",
|
|
4026
|
-
"moduleParsed",
|
|
4027
|
-
"load",
|
|
4028
|
-
"renderChunk",
|
|
4029
|
-
"augmentChunkHash",
|
|
4030
|
-
"renderStart",
|
|
4031
|
-
"renderError",
|
|
4032
|
-
"generateBundle",
|
|
4033
|
-
"writeBundle",
|
|
4034
|
-
"closeBundle",
|
|
4035
|
-
"banner",
|
|
4036
|
-
"footer",
|
|
4037
|
-
"intro",
|
|
4038
|
-
"outro",
|
|
4039
|
-
"watchChange",
|
|
4040
|
-
"closeWatcher"
|
|
4041
|
-
]) {
|
|
4042
|
-
const handler = plugin[hookName];
|
|
4043
|
-
if (handler) plugin[hookName] = async (...args) => {
|
|
4044
|
-
try {
|
|
4045
|
-
return await handler(...args);
|
|
4046
|
-
} catch (e) {
|
|
4047
|
-
return error(logPluginError(e, plugin.name, {
|
|
4048
|
-
hook: hookName,
|
|
4049
|
-
id: hookName === "transform" ? args[2] : void 0
|
|
4050
|
-
}));
|
|
3111
|
+
proxyModuleInfo(id, info) {
|
|
3112
|
+
let moduleSideEffects = info.moduleSideEffects;
|
|
3113
|
+
Object.defineProperty(info, "moduleSideEffects", {
|
|
3114
|
+
get() {
|
|
3115
|
+
return moduleSideEffects;
|
|
3116
|
+
},
|
|
3117
|
+
set: (v) => {
|
|
3118
|
+
this.updateModuleOption(id, {
|
|
3119
|
+
moduleSideEffects: v,
|
|
3120
|
+
meta: info.meta,
|
|
3121
|
+
invalidate: true
|
|
3122
|
+
});
|
|
3123
|
+
moduleSideEffects = v;
|
|
4051
3124
|
}
|
|
4052
|
-
};
|
|
4053
|
-
|
|
4054
|
-
return plugin;
|
|
4055
|
-
}
|
|
4056
|
-
//#endregion
|
|
4057
|
-
//#region src/options/normalized-input-options.ts
|
|
4058
|
-
var NormalizedInputOptionsImpl = class extends PlainObjectLike {
|
|
4059
|
-
onLog;
|
|
4060
|
-
inputPlugins;
|
|
4061
|
-
inner;
|
|
4062
|
-
constructor(inner, onLog, inputPlugins) {
|
|
4063
|
-
super();
|
|
4064
|
-
this.onLog = onLog;
|
|
4065
|
-
this.inputPlugins = inputPlugins;
|
|
4066
|
-
this.inner = inner;
|
|
4067
|
-
}
|
|
4068
|
-
get shimMissingExports() {
|
|
4069
|
-
return this.inner.shimMissingExports;
|
|
4070
|
-
}
|
|
4071
|
-
get input() {
|
|
4072
|
-
return this.inner.input;
|
|
4073
|
-
}
|
|
4074
|
-
get cwd() {
|
|
4075
|
-
return this.inner.cwd;
|
|
4076
|
-
}
|
|
4077
|
-
get platform() {
|
|
4078
|
-
return this.inner.platform;
|
|
4079
|
-
}
|
|
4080
|
-
get context() {
|
|
4081
|
-
return this.inner.context;
|
|
4082
|
-
}
|
|
4083
|
-
get plugins() {
|
|
4084
|
-
return this.inputPlugins;
|
|
4085
|
-
}
|
|
4086
|
-
};
|
|
4087
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
|
|
4088
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
|
|
4089
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
|
|
4090
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
|
|
4091
|
-
__decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
|
|
4092
|
-
//#endregion
|
|
4093
|
-
//#region src/options/normalized-output-options.ts
|
|
4094
|
-
var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
|
|
4095
|
-
inner;
|
|
4096
|
-
outputOptions;
|
|
4097
|
-
normalizedOutputPlugins;
|
|
4098
|
-
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
4099
|
-
super();
|
|
4100
|
-
this.inner = inner;
|
|
4101
|
-
this.outputOptions = outputOptions;
|
|
4102
|
-
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
4103
|
-
}
|
|
4104
|
-
get dir() {
|
|
4105
|
-
return this.inner.dir ?? void 0;
|
|
4106
|
-
}
|
|
4107
|
-
get entryFileNames() {
|
|
4108
|
-
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
4109
|
-
}
|
|
4110
|
-
get chunkFileNames() {
|
|
4111
|
-
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3125
|
+
});
|
|
3126
|
+
return info;
|
|
4112
3127
|
}
|
|
4113
|
-
|
|
4114
|
-
return
|
|
3128
|
+
getModuleIds(context) {
|
|
3129
|
+
return context.getModuleIds().values();
|
|
4115
3130
|
}
|
|
4116
|
-
|
|
4117
|
-
|
|
3131
|
+
saveResolveOptions(options) {
|
|
3132
|
+
const index = this.resolveOptionsMap.size;
|
|
3133
|
+
this.resolveOptionsMap.set(index, options);
|
|
3134
|
+
return index;
|
|
4118
3135
|
}
|
|
4119
|
-
|
|
4120
|
-
return this.
|
|
3136
|
+
getSavedResolveOptions(receipt) {
|
|
3137
|
+
return this.resolveOptionsMap.get(receipt);
|
|
4121
3138
|
}
|
|
4122
|
-
|
|
4123
|
-
|
|
3139
|
+
removeSavedResolveOptions(receipt) {
|
|
3140
|
+
this.resolveOptionsMap.delete(receipt);
|
|
4124
3141
|
}
|
|
4125
|
-
|
|
4126
|
-
|
|
3142
|
+
setRenderChunkMeta(meta) {
|
|
3143
|
+
this.renderedChunkMeta = meta;
|
|
4127
3144
|
}
|
|
4128
|
-
|
|
4129
|
-
return this.
|
|
3145
|
+
getRenderChunkMeta() {
|
|
3146
|
+
return this.renderedChunkMeta;
|
|
4130
3147
|
}
|
|
4131
|
-
|
|
4132
|
-
|
|
3148
|
+
getInputOptions(opts) {
|
|
3149
|
+
this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog, this.normalizedInputPlugins);
|
|
3150
|
+
return this.normalizedInputOptions;
|
|
4133
3151
|
}
|
|
4134
|
-
|
|
4135
|
-
|
|
3152
|
+
getOutputOptions(opts) {
|
|
3153
|
+
this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
|
|
3154
|
+
return this.normalizedOutputOptions;
|
|
4136
3155
|
}
|
|
4137
|
-
|
|
4138
|
-
|
|
3156
|
+
clear() {
|
|
3157
|
+
this.renderedChunkMeta = null;
|
|
3158
|
+
this.loadModulePromiseMap.clear();
|
|
4139
3159
|
}
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
3160
|
+
};
|
|
3161
|
+
//#endregion
|
|
3162
|
+
//#region src/binding-magic-string.ts
|
|
3163
|
+
Object.defineProperty(BindingMagicString.prototype, "isRolldownMagicString", {
|
|
3164
|
+
value: true,
|
|
3165
|
+
writable: false,
|
|
3166
|
+
configurable: false
|
|
3167
|
+
});
|
|
3168
|
+
function assertString(content, msg) {
|
|
3169
|
+
if (typeof content !== "string") throw new TypeError(msg);
|
|
3170
|
+
}
|
|
3171
|
+
const nativeAppend = BindingMagicString.prototype.append;
|
|
3172
|
+
const nativePrepend = BindingMagicString.prototype.prepend;
|
|
3173
|
+
const nativeAppendLeft = BindingMagicString.prototype.appendLeft;
|
|
3174
|
+
const nativeAppendRight = BindingMagicString.prototype.appendRight;
|
|
3175
|
+
const nativePrependLeft = BindingMagicString.prototype.prependLeft;
|
|
3176
|
+
const nativePrependRight = BindingMagicString.prototype.prependRight;
|
|
3177
|
+
const nativeOverwrite = BindingMagicString.prototype.overwrite;
|
|
3178
|
+
const nativeUpdate = BindingMagicString.prototype.update;
|
|
3179
|
+
BindingMagicString.prototype.append = function(content) {
|
|
3180
|
+
assertString(content, "outro content must be a string");
|
|
3181
|
+
return nativeAppend.call(this, content);
|
|
3182
|
+
};
|
|
3183
|
+
BindingMagicString.prototype.prepend = function(content) {
|
|
3184
|
+
assertString(content, "outro content must be a string");
|
|
3185
|
+
return nativePrepend.call(this, content);
|
|
3186
|
+
};
|
|
3187
|
+
BindingMagicString.prototype.appendLeft = function(index, content) {
|
|
3188
|
+
assertString(content, "inserted content must be a string");
|
|
3189
|
+
return nativeAppendLeft.call(this, index, content);
|
|
3190
|
+
};
|
|
3191
|
+
BindingMagicString.prototype.appendRight = function(index, content) {
|
|
3192
|
+
assertString(content, "inserted content must be a string");
|
|
3193
|
+
return nativeAppendRight.call(this, index, content);
|
|
3194
|
+
};
|
|
3195
|
+
BindingMagicString.prototype.prependLeft = function(index, content) {
|
|
3196
|
+
assertString(content, "inserted content must be a string");
|
|
3197
|
+
return nativePrependLeft.call(this, index, content);
|
|
3198
|
+
};
|
|
3199
|
+
BindingMagicString.prototype.prependRight = function(index, content) {
|
|
3200
|
+
assertString(content, "inserted content must be a string");
|
|
3201
|
+
return nativePrependRight.call(this, index, content);
|
|
3202
|
+
};
|
|
3203
|
+
BindingMagicString.prototype.overwrite = function(start, end, content, options) {
|
|
3204
|
+
assertString(content, "replacement content must be a string");
|
|
3205
|
+
return nativeOverwrite.call(this, start, end, content, options);
|
|
3206
|
+
};
|
|
3207
|
+
BindingMagicString.prototype.update = function(start, end, content, options) {
|
|
3208
|
+
assertString(content, "replacement content must be a string");
|
|
3209
|
+
return nativeUpdate.call(this, start, end, content, options);
|
|
3210
|
+
};
|
|
3211
|
+
const nativeReplace = BindingMagicString.prototype.replace;
|
|
3212
|
+
const nativeReplaceAll = BindingMagicString.prototype.replaceAll;
|
|
3213
|
+
BindingMagicString.prototype.replace = function(searchValue, replacement) {
|
|
3214
|
+
if (typeof searchValue === "string") return nativeReplace.call(this, searchValue, replacement);
|
|
3215
|
+
if (searchValue.global) searchValue.lastIndex = 0;
|
|
3216
|
+
const lastMatchEnd = this.replaceRegex(searchValue, replacement);
|
|
3217
|
+
if (searchValue.global) searchValue.lastIndex = 0;
|
|
3218
|
+
else if (searchValue.sticky) searchValue.lastIndex = lastMatchEnd === -1 ? 0 : lastMatchEnd;
|
|
3219
|
+
return this;
|
|
3220
|
+
};
|
|
3221
|
+
BindingMagicString.prototype.replaceAll = function(searchValue, replacement) {
|
|
3222
|
+
if (typeof searchValue === "string") return nativeReplaceAll.call(this, searchValue, replacement);
|
|
3223
|
+
if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
|
|
3224
|
+
searchValue.lastIndex = 0;
|
|
3225
|
+
this.replaceRegex(searchValue, replacement);
|
|
3226
|
+
searchValue.lastIndex = 0;
|
|
3227
|
+
return this;
|
|
3228
|
+
};
|
|
3229
|
+
/**
|
|
3230
|
+
* A native MagicString implementation powered by Rust.
|
|
3231
|
+
*
|
|
3232
|
+
* @experimental
|
|
3233
|
+
*/
|
|
3234
|
+
const RolldownMagicString = BindingMagicString;
|
|
3235
|
+
//#endregion
|
|
3236
|
+
//#region src/parse-ast-index.ts
|
|
3237
|
+
function wrap(result, filename, sourceText) {
|
|
3238
|
+
if (result.errors.length > 0) return normalizeParseError(filename, sourceText, result.errors);
|
|
3239
|
+
return result.program;
|
|
3240
|
+
}
|
|
3241
|
+
function normalizeParseError(filename, sourceText, errors) {
|
|
3242
|
+
let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
3243
|
+
const pos = errors[0]?.labels?.[0]?.start;
|
|
3244
|
+
for (let i = 0; i < errors.length; i++) {
|
|
3245
|
+
if (i >= 5) {
|
|
3246
|
+
message += "\n...";
|
|
3247
|
+
break;
|
|
3248
|
+
}
|
|
3249
|
+
const e = errors[i];
|
|
3250
|
+
message += e.message + "\n" + e.labels.map((label) => {
|
|
3251
|
+
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
3252
|
+
if (!location) return;
|
|
3253
|
+
return getCodeFrame(sourceText, location.line, location.column);
|
|
3254
|
+
}).filter(Boolean).join("\n");
|
|
4184
3255
|
}
|
|
4185
|
-
|
|
4186
|
-
|
|
3256
|
+
const log = logParseError(message, filename, pos);
|
|
3257
|
+
if (pos !== void 0 && filename) augmentCodeLocation(log, pos, sourceText, filename);
|
|
3258
|
+
return error(log);
|
|
3259
|
+
}
|
|
3260
|
+
const defaultParserOptions = {
|
|
3261
|
+
lang: "js",
|
|
3262
|
+
preserveParens: false
|
|
3263
|
+
};
|
|
3264
|
+
/**
|
|
3265
|
+
* Parse code synchronously and return the AST.
|
|
3266
|
+
*
|
|
3267
|
+
* This function is similar to Rollup's `parseAst` function.
|
|
3268
|
+
* Prefer using {@linkcode parseSync} instead of this function as it has more information in the return value.
|
|
3269
|
+
*
|
|
3270
|
+
* @category Utilities
|
|
3271
|
+
*/
|
|
3272
|
+
function parseAst(sourceText, options, filename) {
|
|
3273
|
+
return wrap(parseSync$1(filename ?? "file.js", sourceText, {
|
|
3274
|
+
...defaultParserOptions,
|
|
3275
|
+
...options
|
|
3276
|
+
}), filename, sourceText);
|
|
3277
|
+
}
|
|
3278
|
+
//#endregion
|
|
3279
|
+
//#region src/utils/transform-sourcemap.ts
|
|
3280
|
+
function isEmptySourcemapFiled(array) {
|
|
3281
|
+
if (!array) return true;
|
|
3282
|
+
if (array.length === 0 || !array[0]) return true;
|
|
3283
|
+
return false;
|
|
3284
|
+
}
|
|
3285
|
+
function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
3286
|
+
if (!rawMap) return;
|
|
3287
|
+
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
3288
|
+
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
3289
|
+
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
|
|
3290
|
+
return map;
|
|
3291
|
+
}
|
|
3292
|
+
//#endregion
|
|
3293
|
+
//#region ../../node_modules/.pnpm/@rolldown+pluginutils@1.0.1/node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs
|
|
3294
|
+
var And = class {
|
|
3295
|
+
kind;
|
|
3296
|
+
args;
|
|
3297
|
+
constructor(...args) {
|
|
3298
|
+
if (args.length === 0) throw new Error("`And` expects at least one operand");
|
|
3299
|
+
this.args = args;
|
|
3300
|
+
this.kind = "and";
|
|
4187
3301
|
}
|
|
4188
|
-
|
|
4189
|
-
|
|
3302
|
+
};
|
|
3303
|
+
var Or = class {
|
|
3304
|
+
kind;
|
|
3305
|
+
args;
|
|
3306
|
+
constructor(...args) {
|
|
3307
|
+
if (args.length === 0) throw new Error("`Or` expects at least one operand");
|
|
3308
|
+
this.args = args;
|
|
3309
|
+
this.kind = "or";
|
|
4190
3310
|
}
|
|
4191
|
-
|
|
4192
|
-
|
|
3311
|
+
};
|
|
3312
|
+
var Id = class {
|
|
3313
|
+
kind;
|
|
3314
|
+
pattern;
|
|
3315
|
+
params;
|
|
3316
|
+
constructor(pattern, params) {
|
|
3317
|
+
this.pattern = pattern;
|
|
3318
|
+
this.kind = "id";
|
|
3319
|
+
this.params = params ?? { cleanUrl: false };
|
|
4193
3320
|
}
|
|
4194
|
-
|
|
4195
|
-
|
|
3321
|
+
};
|
|
3322
|
+
var ModuleType = class {
|
|
3323
|
+
kind;
|
|
3324
|
+
pattern;
|
|
3325
|
+
constructor(pattern) {
|
|
3326
|
+
this.pattern = pattern;
|
|
3327
|
+
this.kind = "moduleType";
|
|
4196
3328
|
}
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
return ret;
|
|
3329
|
+
};
|
|
3330
|
+
var Code = class {
|
|
3331
|
+
kind;
|
|
3332
|
+
pattern;
|
|
3333
|
+
constructor(expr) {
|
|
3334
|
+
this.pattern = expr;
|
|
3335
|
+
this.kind = "code";
|
|
4205
3336
|
}
|
|
4206
|
-
|
|
4207
|
-
|
|
3337
|
+
};
|
|
3338
|
+
var Include = class {
|
|
3339
|
+
kind;
|
|
3340
|
+
expr;
|
|
3341
|
+
constructor(expr) {
|
|
3342
|
+
this.expr = expr;
|
|
3343
|
+
this.kind = "include";
|
|
4208
3344
|
}
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
3345
|
+
};
|
|
3346
|
+
var Exclude = class {
|
|
3347
|
+
kind;
|
|
3348
|
+
expr;
|
|
3349
|
+
constructor(expr) {
|
|
3350
|
+
this.expr = expr;
|
|
3351
|
+
this.kind = "exclude";
|
|
4216
3352
|
}
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
3353
|
+
};
|
|
3354
|
+
function and(...args) {
|
|
3355
|
+
return new And(...args);
|
|
3356
|
+
}
|
|
3357
|
+
function or(...args) {
|
|
3358
|
+
return new Or(...args);
|
|
3359
|
+
}
|
|
3360
|
+
function id(pattern, params) {
|
|
3361
|
+
return new Id(pattern, params);
|
|
3362
|
+
}
|
|
3363
|
+
function moduleType(pattern) {
|
|
3364
|
+
return new ModuleType(pattern);
|
|
3365
|
+
}
|
|
3366
|
+
function code(pattern) {
|
|
3367
|
+
return new Code(pattern);
|
|
3368
|
+
}
|
|
3369
|
+
function include(expr) {
|
|
3370
|
+
return new Include(expr);
|
|
3371
|
+
}
|
|
3372
|
+
function exclude(expr) {
|
|
3373
|
+
return new Exclude(expr);
|
|
3374
|
+
}
|
|
3375
|
+
//#endregion
|
|
3376
|
+
//#region ../../node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/lazyDataLastImpl--3B10z3s.js
|
|
3377
|
+
function e(e, t, n) {
|
|
3378
|
+
let r = (n) => e(n, ...t);
|
|
3379
|
+
return n === void 0 ? r : Object.assign(r, {
|
|
3380
|
+
lazy: n,
|
|
3381
|
+
lazyArgs: t
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
//#endregion
|
|
3385
|
+
//#region ../../node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/purry.js
|
|
3386
|
+
function t$1(t, n, r) {
|
|
3387
|
+
let i = t.length - n.length;
|
|
3388
|
+
if (i === 0) return t(...n);
|
|
3389
|
+
if (i === 1) return e(t, n, r);
|
|
3390
|
+
throw Error(`Wrong number of arguments`);
|
|
3391
|
+
}
|
|
3392
|
+
//#endregion
|
|
3393
|
+
//#region ../../node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/partition.js
|
|
3394
|
+
function t(...t) {
|
|
3395
|
+
return t$1(n, t);
|
|
3396
|
+
}
|
|
3397
|
+
const n = (e, t) => {
|
|
3398
|
+
let n = [[], []];
|
|
3399
|
+
for (let [r, i] of e.entries()) t(i, r, e) ? n[0].push(i) : n[1].push(i);
|
|
3400
|
+
return n;
|
|
3401
|
+
};
|
|
3402
|
+
//#endregion
|
|
3403
|
+
//#region src/plugin/bindingify-hook-filter.ts
|
|
3404
|
+
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
3405
|
+
if (typeof matcher === "string" || matcher instanceof RegExp) return [include(generateAtomMatcher(stringKind, matcher))];
|
|
3406
|
+
if (Array.isArray(matcher)) return matcher.map((m) => include(generateAtomMatcher(stringKind, m)));
|
|
3407
|
+
let ret = [];
|
|
3408
|
+
if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => exclude(generateAtomMatcher(stringKind, m))));
|
|
3409
|
+
if (matcher.include) ret.push(...arraify(matcher.include).map((m) => include(generateAtomMatcher(stringKind, m))));
|
|
3410
|
+
return ret;
|
|
3411
|
+
}
|
|
3412
|
+
function generateAtomMatcher(kind, matcher) {
|
|
3413
|
+
return kind === "code" ? code(matcher) : id(matcher);
|
|
3414
|
+
}
|
|
3415
|
+
function transformFilterMatcherToFilterExprs(filterOption) {
|
|
3416
|
+
if (!filterOption) return;
|
|
3417
|
+
if (Array.isArray(filterOption)) return filterOption;
|
|
3418
|
+
const { id, code, moduleType: moduleType$1 } = filterOption;
|
|
3419
|
+
let ret = [];
|
|
3420
|
+
let idIncludes = [];
|
|
3421
|
+
let idExcludes = [];
|
|
3422
|
+
let codeIncludes = [];
|
|
3423
|
+
let codeExcludes = [];
|
|
3424
|
+
if (id) [idIncludes, idExcludes] = t(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m) => m.kind === "include");
|
|
3425
|
+
if (code) [codeIncludes, codeExcludes] = t(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m) => m.kind === "include");
|
|
3426
|
+
ret.push(...idExcludes);
|
|
3427
|
+
ret.push(...codeExcludes);
|
|
3428
|
+
let andExprList = [];
|
|
3429
|
+
if (moduleType$1) {
|
|
3430
|
+
let moduleTypes = Array.isArray(moduleType$1) ? moduleType$1 : moduleType$1.include ?? [];
|
|
3431
|
+
andExprList.push(or(...moduleTypes.map((m) => moduleType(m))));
|
|
4222
3432
|
}
|
|
4223
|
-
|
|
4224
|
-
|
|
3433
|
+
if (idIncludes.length) andExprList.push(or(...idIncludes.map((item) => item.expr)));
|
|
3434
|
+
if (codeIncludes.length) andExprList.push(or(...codeIncludes.map((item) => item.expr)));
|
|
3435
|
+
if (andExprList.length) ret.push(include(and(...andExprList)));
|
|
3436
|
+
return ret;
|
|
3437
|
+
}
|
|
3438
|
+
function bindingifyGeneralHookFilter(stringKind, pattern) {
|
|
3439
|
+
let filterExprs = generalHookFilterMatcherToFilterExprs(pattern, stringKind);
|
|
3440
|
+
let ret = [];
|
|
3441
|
+
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
3442
|
+
return ret.length > 0 ? { value: ret } : void 0;
|
|
3443
|
+
}
|
|
3444
|
+
function bindingifyFilterExpr(expr) {
|
|
3445
|
+
let list = [];
|
|
3446
|
+
bindingifyFilterExprImpl(expr, list);
|
|
3447
|
+
return list;
|
|
3448
|
+
}
|
|
3449
|
+
function containsImporterId(expr) {
|
|
3450
|
+
switch (expr.kind) {
|
|
3451
|
+
case "and":
|
|
3452
|
+
case "or": return expr.args.some(containsImporterId);
|
|
3453
|
+
case "not":
|
|
3454
|
+
case "include":
|
|
3455
|
+
case "exclude": return containsImporterId(expr.expr);
|
|
3456
|
+
case "importerId": return true;
|
|
3457
|
+
default: return false;
|
|
4225
3458
|
}
|
|
4226
|
-
|
|
4227
|
-
|
|
3459
|
+
}
|
|
3460
|
+
function assertNoImporterId(filterExprs, hookName) {
|
|
3461
|
+
if (filterExprs?.some(containsImporterId)) throw new Error(`The \`importerId\` filter can only be used with the \`resolveId\` hook, but it was used with the \`${hookName}\` hook.`);
|
|
3462
|
+
}
|
|
3463
|
+
function bindingifyFilterExprImpl(expr, list) {
|
|
3464
|
+
switch (expr.kind) {
|
|
3465
|
+
case "and": {
|
|
3466
|
+
let args = expr.args;
|
|
3467
|
+
for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
|
|
3468
|
+
list.push({
|
|
3469
|
+
kind: "And",
|
|
3470
|
+
payload: args.length
|
|
3471
|
+
});
|
|
3472
|
+
break;
|
|
3473
|
+
}
|
|
3474
|
+
case "or": {
|
|
3475
|
+
let args = expr.args;
|
|
3476
|
+
for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
|
|
3477
|
+
list.push({
|
|
3478
|
+
kind: "Or",
|
|
3479
|
+
payload: args.length
|
|
3480
|
+
});
|
|
3481
|
+
break;
|
|
3482
|
+
}
|
|
3483
|
+
case "not":
|
|
3484
|
+
bindingifyFilterExprImpl(expr.expr, list);
|
|
3485
|
+
list.push({ kind: "Not" });
|
|
3486
|
+
break;
|
|
3487
|
+
case "id":
|
|
3488
|
+
list.push({
|
|
3489
|
+
kind: "Id",
|
|
3490
|
+
payload: expr.pattern
|
|
3491
|
+
});
|
|
3492
|
+
if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
|
|
3493
|
+
break;
|
|
3494
|
+
case "importerId":
|
|
3495
|
+
list.push({
|
|
3496
|
+
kind: "ImporterId",
|
|
3497
|
+
payload: expr.pattern
|
|
3498
|
+
});
|
|
3499
|
+
if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
|
|
3500
|
+
break;
|
|
3501
|
+
case "moduleType":
|
|
3502
|
+
list.push({
|
|
3503
|
+
kind: "ModuleType",
|
|
3504
|
+
payload: expr.pattern
|
|
3505
|
+
});
|
|
3506
|
+
break;
|
|
3507
|
+
case "code":
|
|
3508
|
+
list.push({
|
|
3509
|
+
kind: "Code",
|
|
3510
|
+
payload: expr.pattern
|
|
3511
|
+
});
|
|
3512
|
+
break;
|
|
3513
|
+
case "include":
|
|
3514
|
+
bindingifyFilterExprImpl(expr.expr, list);
|
|
3515
|
+
list.push({ kind: "Include" });
|
|
3516
|
+
break;
|
|
3517
|
+
case "exclude":
|
|
3518
|
+
bindingifyFilterExprImpl(expr.expr, list);
|
|
3519
|
+
list.push({ kind: "Exclude" });
|
|
3520
|
+
break;
|
|
3521
|
+
case "query":
|
|
3522
|
+
list.push({
|
|
3523
|
+
kind: "QueryKey",
|
|
3524
|
+
payload: expr.key
|
|
3525
|
+
});
|
|
3526
|
+
list.push({
|
|
3527
|
+
kind: "QueryValue",
|
|
3528
|
+
payload: expr.pattern
|
|
3529
|
+
});
|
|
3530
|
+
break;
|
|
3531
|
+
default: throw new Error(`Unknown filter expression: ${expr}`);
|
|
4228
3532
|
}
|
|
4229
|
-
|
|
4230
|
-
|
|
3533
|
+
}
|
|
3534
|
+
function bindingifyResolveIdFilter(filterOption) {
|
|
3535
|
+
if (!filterOption) return;
|
|
3536
|
+
if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
|
|
3537
|
+
return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
|
|
3538
|
+
}
|
|
3539
|
+
function bindingifyLoadFilter(filterOption) {
|
|
3540
|
+
if (!filterOption) return;
|
|
3541
|
+
if (Array.isArray(filterOption)) {
|
|
3542
|
+
assertNoImporterId(filterOption, "load");
|
|
3543
|
+
return { value: filterOption.map(bindingifyFilterExpr) };
|
|
4231
3544
|
}
|
|
4232
|
-
|
|
4233
|
-
|
|
3545
|
+
return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
|
|
3546
|
+
}
|
|
3547
|
+
function bindingifyTransformFilter(filterOption) {
|
|
3548
|
+
if (!filterOption) return;
|
|
3549
|
+
let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
|
|
3550
|
+
assertNoImporterId(filterExprs, "transform");
|
|
3551
|
+
let ret = [];
|
|
3552
|
+
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
3553
|
+
return { value: ret.length > 0 ? ret : void 0 };
|
|
3554
|
+
}
|
|
3555
|
+
function bindingifyRenderChunkFilter(filterOption) {
|
|
3556
|
+
if (!filterOption) return;
|
|
3557
|
+
if (Array.isArray(filterOption)) {
|
|
3558
|
+
assertNoImporterId(filterOption, "renderChunk");
|
|
3559
|
+
return { value: filterOption.map(bindingifyFilterExpr) };
|
|
4234
3560
|
}
|
|
4235
|
-
|
|
4236
|
-
|
|
3561
|
+
return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
|
|
3562
|
+
}
|
|
3563
|
+
//#endregion
|
|
3564
|
+
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
3565
|
+
function bindingifyPluginHookMeta(options) {
|
|
3566
|
+
return { order: bindingPluginOrder(options.order) };
|
|
3567
|
+
}
|
|
3568
|
+
function bindingPluginOrder(order) {
|
|
3569
|
+
switch (order) {
|
|
3570
|
+
case "post": return BindingPluginOrder.Post;
|
|
3571
|
+
case "pre": return BindingPluginOrder.Pre;
|
|
3572
|
+
case null:
|
|
3573
|
+
case void 0: return;
|
|
3574
|
+
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
4237
3575
|
}
|
|
3576
|
+
}
|
|
3577
|
+
//#endregion
|
|
3578
|
+
//#region src/plugin/fs.ts
|
|
3579
|
+
const fsModule = {
|
|
3580
|
+
appendFile: throwNoFileSystemError("fs.appendFile"),
|
|
3581
|
+
copyFile: throwNoFileSystemError("fs.copyFile"),
|
|
3582
|
+
mkdir: throwNoFileSystemError("fs.mkdir"),
|
|
3583
|
+
mkdtemp: throwNoFileSystemError("fs.mkdtemp"),
|
|
3584
|
+
readdir: throwNoFileSystemError("fs.readdir"),
|
|
3585
|
+
readFile: throwNoFileSystemError("fs.readFile"),
|
|
3586
|
+
realpath: throwNoFileSystemError("fs.realpath"),
|
|
3587
|
+
rename: throwNoFileSystemError("fs.rename"),
|
|
3588
|
+
rmdir: throwNoFileSystemError("fs.rmdir"),
|
|
3589
|
+
stat: throwNoFileSystemError("fs.stat"),
|
|
3590
|
+
lstat: throwNoFileSystemError("fs.lstat"),
|
|
3591
|
+
unlink: throwNoFileSystemError("fs.unlink"),
|
|
3592
|
+
writeFile: throwNoFileSystemError("fs.writeFile")
|
|
4238
3593
|
};
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
3594
|
+
function throwNoFileSystemError(method) {
|
|
3595
|
+
return () => {
|
|
3596
|
+
error(logNoFileSystemInBrowser(method));
|
|
3597
|
+
};
|
|
3598
|
+
}
|
|
3599
|
+
//#endregion
|
|
3600
|
+
//#region src/plugin/plugin-context.ts
|
|
3601
|
+
var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
3602
|
+
outputOptions;
|
|
3603
|
+
context;
|
|
3604
|
+
data;
|
|
3605
|
+
onLog;
|
|
3606
|
+
currentLoadingModule;
|
|
3607
|
+
fs = fsModule;
|
|
3608
|
+
getModuleInfo;
|
|
3609
|
+
constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
|
|
3610
|
+
super(onLog, logLevel, plugin.name, watchMode);
|
|
3611
|
+
this.outputOptions = outputOptions;
|
|
3612
|
+
this.context = context;
|
|
3613
|
+
this.data = data;
|
|
3614
|
+
this.onLog = onLog;
|
|
3615
|
+
this.currentLoadingModule = currentLoadingModule;
|
|
3616
|
+
this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
|
|
3617
|
+
}
|
|
3618
|
+
async load(options) {
|
|
3619
|
+
const id = options.id;
|
|
3620
|
+
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
3621
|
+
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
3622
|
+
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
3623
|
+
const rawOptions = {
|
|
3624
|
+
meta: options.meta || {},
|
|
3625
|
+
moduleSideEffects: options.moduleSideEffects || null,
|
|
3626
|
+
invalidate: false
|
|
3627
|
+
};
|
|
3628
|
+
this.data.updateModuleOption(id, rawOptions);
|
|
3629
|
+
let loadPromise = this.data.loadModulePromiseMap.get(id);
|
|
3630
|
+
if (!loadPromise) {
|
|
3631
|
+
loadPromise = this.context.load(id, options.moduleSideEffects ?? void 0, options.packageJsonPath ?? void 0).catch(() => {
|
|
3632
|
+
this.data.loadModulePromiseMap.delete(id);
|
|
3633
|
+
});
|
|
3634
|
+
this.data.loadModulePromiseMap.set(id, loadPromise);
|
|
3635
|
+
}
|
|
3636
|
+
await loadPromise;
|
|
3637
|
+
return this.data.getModuleInfo(id, this.context);
|
|
3638
|
+
}
|
|
3639
|
+
async resolve(source, importer, options) {
|
|
3640
|
+
let receipt = void 0;
|
|
3641
|
+
if (options != null) receipt = this.data.saveResolveOptions(options);
|
|
3642
|
+
const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
|
|
3643
|
+
if (key.startsWith("vite:")) (acc ??= {})[key] = value;
|
|
3644
|
+
return acc;
|
|
3645
|
+
}, void 0);
|
|
3646
|
+
const res = await this.context.resolve(source, importer, {
|
|
3647
|
+
importKind: options?.kind,
|
|
3648
|
+
custom: receipt,
|
|
3649
|
+
isEntry: options?.isEntry,
|
|
3650
|
+
skipSelf: options?.skipSelf,
|
|
3651
|
+
vitePluginCustom
|
|
3652
|
+
});
|
|
3653
|
+
if (receipt != null) this.data.removeSavedResolveOptions(receipt);
|
|
3654
|
+
if (res == null) return null;
|
|
3655
|
+
const info = this.data.getModuleOption(res.id) || {};
|
|
3656
|
+
return {
|
|
3657
|
+
...res,
|
|
3658
|
+
external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
|
|
3659
|
+
...info,
|
|
3660
|
+
moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null,
|
|
3661
|
+
packageJsonPath: res.packageJsonPath
|
|
3662
|
+
};
|
|
3663
|
+
}
|
|
3664
|
+
emitFile = (file) => {
|
|
3665
|
+
if (file.type === "prebuilt-chunk") return this.context.emitPrebuiltChunk({
|
|
3666
|
+
fileName: file.fileName,
|
|
3667
|
+
name: file.name,
|
|
3668
|
+
code: file.code,
|
|
3669
|
+
exports: file.exports,
|
|
3670
|
+
map: bindingifySourcemap$1(file.map),
|
|
3671
|
+
sourcemapFileName: file.sourcemapFileName,
|
|
3672
|
+
facadeModuleId: file.facadeModuleId,
|
|
3673
|
+
isEntry: file.isEntry,
|
|
3674
|
+
isDynamicEntry: file.isDynamicEntry
|
|
3675
|
+
});
|
|
3676
|
+
if (file.type === "chunk") return this.context.emitChunk({
|
|
3677
|
+
preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
|
|
3678
|
+
...file
|
|
3679
|
+
});
|
|
3680
|
+
const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
|
|
3681
|
+
const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
|
|
3682
|
+
return this.context.emitFile({
|
|
3683
|
+
...file,
|
|
3684
|
+
originalFileName: file.originalFileName || void 0,
|
|
3685
|
+
source: bindingAssetSource(file.source)
|
|
3686
|
+
}, filename, fnSanitizedFileName);
|
|
3687
|
+
};
|
|
3688
|
+
getAssetFileNames(file) {
|
|
3689
|
+
if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
|
|
3690
|
+
type: "asset",
|
|
3691
|
+
name: file.name,
|
|
3692
|
+
names: file.name ? [file.name] : [],
|
|
3693
|
+
originalFileName: file.originalFileName,
|
|
3694
|
+
originalFileNames: file.originalFileName ? [file.originalFileName] : [],
|
|
3695
|
+
source: file.source
|
|
3696
|
+
});
|
|
3697
|
+
}
|
|
3698
|
+
getFileName(referenceId) {
|
|
3699
|
+
return this.context.getFileName(referenceId);
|
|
3700
|
+
}
|
|
3701
|
+
getModuleIds() {
|
|
3702
|
+
return this.data.getModuleIds(this.context);
|
|
3703
|
+
}
|
|
3704
|
+
addWatchFile(id) {
|
|
3705
|
+
this.context.addWatchFile(id);
|
|
3706
|
+
}
|
|
3707
|
+
parse(input, options) {
|
|
3708
|
+
return parseAst(input, options);
|
|
3709
|
+
}
|
|
3710
|
+
};
|
|
3711
|
+
//#endregion
|
|
3712
|
+
//#region src/plugin/load-plugin-context.ts
|
|
3713
|
+
var LoadPluginContextImpl = class extends PluginContextImpl {
|
|
3714
|
+
inner;
|
|
3715
|
+
constructor(outputOptions, context, plugin, data, inner, moduleId, onLog, logLevelOption, watchMode) {
|
|
3716
|
+
super(outputOptions, context, plugin, data, onLog, logLevelOption, watchMode, moduleId);
|
|
3717
|
+
this.inner = inner;
|
|
3718
|
+
}
|
|
3719
|
+
addWatchFile(id) {
|
|
3720
|
+
this.inner.addWatchFile(id);
|
|
3721
|
+
}
|
|
3722
|
+
};
|
|
3723
|
+
//#endregion
|
|
3724
|
+
//#region src/plugin/transform-plugin-context.ts
|
|
3725
|
+
var TransformPluginContextImpl = class extends PluginContextImpl {
|
|
3726
|
+
inner;
|
|
3727
|
+
moduleId;
|
|
3728
|
+
moduleSource;
|
|
3729
|
+
constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
|
|
3730
|
+
super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
|
|
3731
|
+
this.inner = inner;
|
|
3732
|
+
this.moduleId = moduleId;
|
|
3733
|
+
this.moduleSource = moduleSource;
|
|
3734
|
+
const getLogHandler = (handler) => (log, pos) => {
|
|
3735
|
+
log = normalizeLog(log);
|
|
3736
|
+
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
3737
|
+
log.id = moduleId;
|
|
3738
|
+
log.hook = "transform";
|
|
3739
|
+
handler(log);
|
|
3740
|
+
};
|
|
3741
|
+
this.debug = getLogHandler(this.debug);
|
|
3742
|
+
this.warn = getLogHandler(this.warn);
|
|
3743
|
+
this.info = getLogHandler(this.info);
|
|
3744
|
+
}
|
|
3745
|
+
error(e, pos) {
|
|
3746
|
+
if (typeof e === "string") e = { message: e };
|
|
3747
|
+
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
3748
|
+
e.id = this.moduleId;
|
|
3749
|
+
e.hook = "transform";
|
|
3750
|
+
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
3751
|
+
}
|
|
3752
|
+
getCombinedSourcemap() {
|
|
3753
|
+
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
3754
|
+
}
|
|
3755
|
+
addWatchFile(id) {
|
|
3756
|
+
this.inner.addWatchFile(id);
|
|
3757
|
+
}
|
|
3758
|
+
sendMagicString(s) {
|
|
3759
|
+
this.inner.sendMagicString(s);
|
|
3760
|
+
}
|
|
3761
|
+
};
|
|
3762
|
+
//#endregion
|
|
3763
|
+
//#region src/plugin/bindingify-build-hooks.ts
|
|
3764
|
+
function createPluginContext(args, ctx) {
|
|
3765
|
+
return new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
|
|
3766
|
+
}
|
|
3767
|
+
function bindingifyBuildStart(args) {
|
|
3768
|
+
const hook = args.plugin.buildStart;
|
|
3769
|
+
if (!hook) return {};
|
|
3770
|
+
const { handler, meta } = normalizeHook(hook);
|
|
3771
|
+
return {
|
|
3772
|
+
plugin: async (ctx, opts) => {
|
|
3773
|
+
await handler.call(createPluginContext(args, ctx), args.pluginContextData.getInputOptions(opts));
|
|
3774
|
+
},
|
|
3775
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
3776
|
+
};
|
|
3777
|
+
}
|
|
3778
|
+
function bindingifyBuildEnd(args) {
|
|
3779
|
+
const hook = args.plugin.buildEnd;
|
|
3780
|
+
if (!hook) return {};
|
|
3781
|
+
const { handler, meta } = normalizeHook(hook);
|
|
3782
|
+
return {
|
|
3783
|
+
plugin: async (ctx, err) => {
|
|
3784
|
+
await handler.call(createPluginContext(args, ctx), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
|
|
3785
|
+
},
|
|
3786
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
3787
|
+
};
|
|
3788
|
+
}
|
|
3789
|
+
function bindingifyResolveId(args) {
|
|
3790
|
+
const hook = args.plugin.resolveId;
|
|
3791
|
+
if (!hook) return {};
|
|
3792
|
+
const { handler, meta, options } = normalizeHook(hook);
|
|
3793
|
+
return {
|
|
3794
|
+
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
3795
|
+
const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
3796
|
+
const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0, {
|
|
3797
|
+
...extraOptions,
|
|
3798
|
+
custom: contextResolveOptions?.custom
|
|
3799
|
+
});
|
|
3800
|
+
if (ret == null) return;
|
|
3801
|
+
if (ret === false) return {
|
|
3802
|
+
id: specifier,
|
|
3803
|
+
external: true,
|
|
3804
|
+
normalizeExternalId: true
|
|
3805
|
+
};
|
|
3806
|
+
if (typeof ret === "string") return {
|
|
3807
|
+
id: ret,
|
|
3808
|
+
normalizeExternalId: false
|
|
3809
|
+
};
|
|
3810
|
+
let exist = args.pluginContextData.updateModuleOption(ret.id, {
|
|
3811
|
+
meta: ret.meta || {},
|
|
3812
|
+
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3813
|
+
invalidate: false
|
|
3814
|
+
});
|
|
3815
|
+
return {
|
|
3816
|
+
id: ret.id,
|
|
3817
|
+
external: ret.external,
|
|
3818
|
+
normalizeExternalId: false,
|
|
3819
|
+
moduleSideEffects: exist.moduleSideEffects ?? void 0,
|
|
3820
|
+
packageJsonPath: ret.packageJsonPath
|
|
3821
|
+
};
|
|
3822
|
+
},
|
|
3823
|
+
meta: bindingifyPluginHookMeta(meta),
|
|
3824
|
+
filter: bindingifyResolveIdFilter(options.filter)
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
function bindingifyResolveDynamicImport(args) {
|
|
3828
|
+
const hook = args.plugin.resolveDynamicImport;
|
|
3829
|
+
if (!hook) return {};
|
|
3830
|
+
const { handler, meta } = normalizeHook(hook);
|
|
3831
|
+
return {
|
|
3832
|
+
plugin: async (ctx, specifier, importer) => {
|
|
3833
|
+
const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0);
|
|
3834
|
+
if (ret == null) return;
|
|
3835
|
+
if (ret === false) return {
|
|
3836
|
+
id: specifier,
|
|
3837
|
+
external: true
|
|
3838
|
+
};
|
|
3839
|
+
if (typeof ret === "string") return { id: ret };
|
|
3840
|
+
const result = {
|
|
3841
|
+
id: ret.id,
|
|
3842
|
+
external: ret.external,
|
|
3843
|
+
packageJsonPath: ret.packageJsonPath
|
|
3844
|
+
};
|
|
3845
|
+
if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
|
|
3846
|
+
args.pluginContextData.updateModuleOption(ret.id, {
|
|
3847
|
+
meta: ret.meta || {},
|
|
3848
|
+
moduleSideEffects: ret.moduleSideEffects || null,
|
|
3849
|
+
invalidate: false
|
|
3850
|
+
});
|
|
3851
|
+
return result;
|
|
3852
|
+
},
|
|
3853
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
3854
|
+
};
|
|
3855
|
+
}
|
|
3856
|
+
function bindingifyTransform(args) {
|
|
3857
|
+
const hook = args.plugin.transform;
|
|
3858
|
+
if (!hook) return {};
|
|
3859
|
+
const { handler, meta, options } = normalizeHook(hook);
|
|
3860
|
+
return {
|
|
3861
|
+
plugin: async (ctx, code, id, meta) => {
|
|
3862
|
+
let magicStringInstance, astInstance;
|
|
3863
|
+
Object.defineProperties(meta, {
|
|
3864
|
+
magicString: { get() {
|
|
3865
|
+
if (magicStringInstance) return magicStringInstance;
|
|
3866
|
+
magicStringInstance = new RolldownMagicString(code);
|
|
3867
|
+
return magicStringInstance;
|
|
3868
|
+
} },
|
|
3869
|
+
ast: { get() {
|
|
3870
|
+
if (astInstance) return astInstance;
|
|
3871
|
+
let lang = "js";
|
|
3872
|
+
switch (meta.moduleType) {
|
|
3873
|
+
case "js":
|
|
3874
|
+
case "jsx":
|
|
3875
|
+
case "ts":
|
|
3876
|
+
case "tsx":
|
|
3877
|
+
lang = meta.moduleType;
|
|
3878
|
+
break;
|
|
3879
|
+
default: break;
|
|
3880
|
+
}
|
|
3881
|
+
astInstance = parseAst(code, {
|
|
3882
|
+
astType: meta.moduleType.includes("ts") ? "ts" : "js",
|
|
3883
|
+
lang
|
|
3884
|
+
});
|
|
3885
|
+
return astInstance;
|
|
3886
|
+
} }
|
|
3887
|
+
});
|
|
3888
|
+
const transformCtx = new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel, args.watchMode);
|
|
3889
|
+
const ret = await handler.call(transformCtx, code, id, meta);
|
|
3890
|
+
if (ret == null) return;
|
|
3891
|
+
if (typeof ret === "string") return { code: ret };
|
|
3892
|
+
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
3893
|
+
meta: ret.meta ?? {},
|
|
3894
|
+
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3895
|
+
invalidate: false
|
|
3896
|
+
});
|
|
3897
|
+
let normalizedCode = void 0;
|
|
3898
|
+
let map = ret.map;
|
|
3899
|
+
let mapHandledByNativeChannel = false;
|
|
3900
|
+
if (typeof ret.code === "string") normalizedCode = ret.code;
|
|
3901
|
+
else if (ret.code instanceof RolldownMagicString) {
|
|
3902
|
+
let magicString = ret.code;
|
|
3903
|
+
normalizedCode = magicString.toString();
|
|
3904
|
+
let fallbackSourcemap = ctx.sendMagicString(magicString);
|
|
3905
|
+
if (fallbackSourcemap != void 0) map = fallbackSourcemap;
|
|
3906
|
+
else mapHandledByNativeChannel = true;
|
|
3907
|
+
}
|
|
3908
|
+
return {
|
|
3909
|
+
code: normalizedCode,
|
|
3910
|
+
map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id, code, map)) ?? (mapHandledByNativeChannel || ret.map === null ? null : void 0),
|
|
3911
|
+
moduleSideEffects: moduleOption.moduleSideEffects ?? void 0,
|
|
3912
|
+
moduleType: ret.moduleType
|
|
3913
|
+
};
|
|
3914
|
+
},
|
|
3915
|
+
meta: bindingifyPluginHookMeta(meta),
|
|
3916
|
+
filter: bindingifyTransformFilter(options.filter)
|
|
3917
|
+
};
|
|
3918
|
+
}
|
|
3919
|
+
function bindingifyLoad(args) {
|
|
3920
|
+
const hook = args.plugin.load;
|
|
3921
|
+
if (!hook) return {};
|
|
3922
|
+
const { handler, meta, options } = normalizeHook(hook);
|
|
3923
|
+
return {
|
|
3924
|
+
plugin: async (ctx, id) => {
|
|
3925
|
+
const ret = await handler.call(new LoadPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, args.onLog, args.logLevel, args.watchMode), id);
|
|
3926
|
+
if (ret == null) return;
|
|
3927
|
+
if (typeof ret === "string") return { code: ret };
|
|
3928
|
+
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
3929
|
+
meta: ret.meta || {},
|
|
3930
|
+
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3931
|
+
invalidate: false
|
|
3932
|
+
});
|
|
3933
|
+
let map = preProcessSourceMap(ret, id);
|
|
3934
|
+
return {
|
|
3935
|
+
code: ret.code,
|
|
3936
|
+
map: bindingifySourcemap$1(map),
|
|
3937
|
+
moduleType: ret.moduleType,
|
|
3938
|
+
moduleSideEffects: moduleOption.moduleSideEffects ?? void 0
|
|
3939
|
+
};
|
|
3940
|
+
},
|
|
3941
|
+
meta: bindingifyPluginHookMeta(meta),
|
|
3942
|
+
filter: bindingifyLoadFilter(options.filter)
|
|
3943
|
+
};
|
|
3944
|
+
}
|
|
3945
|
+
function preProcessSourceMap(ret, id) {
|
|
3946
|
+
if (!ret.map) return;
|
|
3947
|
+
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
3948
|
+
if (!isEmptySourcemapFiled(map.sources)) {
|
|
3949
|
+
const directory = posix.dirname(id) || ".";
|
|
3950
|
+
const sourceRoot = map.sourceRoot || ".";
|
|
3951
|
+
map.sources = map.sources.map((source) => posix.resolve(directory, sourceRoot, source));
|
|
3952
|
+
}
|
|
3953
|
+
return map;
|
|
3954
|
+
}
|
|
3955
|
+
function bindingifyModuleParsed(args) {
|
|
3956
|
+
const hook = args.plugin.moduleParsed;
|
|
3957
|
+
if (!hook) return {};
|
|
3958
|
+
const { handler, meta } = normalizeHook(hook);
|
|
3959
|
+
return {
|
|
3960
|
+
plugin: async (ctx, moduleInfo) => {
|
|
3961
|
+
await handler.call(createPluginContext(args, ctx), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
3962
|
+
},
|
|
3963
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
3964
|
+
};
|
|
3965
|
+
}
|
|
3966
|
+
//#endregion
|
|
3967
|
+
//#region src/plugin/bindingify-output-hooks.ts
|
|
3968
|
+
function bindingifyRenderStart(args) {
|
|
3969
|
+
const hook = args.plugin.renderStart;
|
|
3970
|
+
if (!hook) return {};
|
|
3971
|
+
const { handler, meta } = normalizeHook(hook);
|
|
3972
|
+
return {
|
|
3973
|
+
plugin: async (ctx, opts) => {
|
|
3974
|
+
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getInputOptions(opts));
|
|
3975
|
+
},
|
|
3976
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
3977
|
+
};
|
|
3978
|
+
}
|
|
3979
|
+
function bindingifyRenderChunk(args) {
|
|
3980
|
+
const hook = args.plugin.renderChunk;
|
|
3981
|
+
if (!hook) return {};
|
|
3982
|
+
const { handler, meta, options } = normalizeHook(hook);
|
|
3983
|
+
return {
|
|
3984
|
+
plugin: async (ctx, code, chunk, opts, meta) => {
|
|
3985
|
+
if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
3986
|
+
const renderChunkMeta = args.pluginContextData.getRenderChunkMeta();
|
|
3987
|
+
let magicStringInstance;
|
|
3988
|
+
if (args.options.experimental?.nativeMagicString) Object.defineProperty(renderChunkMeta, "magicString", {
|
|
3989
|
+
get() {
|
|
3990
|
+
if (magicStringInstance) return magicStringInstance;
|
|
3991
|
+
magicStringInstance = new RolldownMagicString(code);
|
|
3992
|
+
return magicStringInstance;
|
|
3993
|
+
},
|
|
3994
|
+
configurable: true
|
|
3995
|
+
});
|
|
3996
|
+
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code, transformRenderedChunk(chunk), args.pluginContextData.getOutputOptions(opts), renderChunkMeta);
|
|
3997
|
+
if (ret == null) return;
|
|
3998
|
+
if (ret instanceof RolldownMagicString) {
|
|
3999
|
+
const normalizedCode = ret.toString();
|
|
4000
|
+
const generatedMap = ret.generateMap();
|
|
4001
|
+
return {
|
|
4002
|
+
code: normalizedCode,
|
|
4003
|
+
map: bindingifySourcemap$1({
|
|
4004
|
+
file: generatedMap.file,
|
|
4005
|
+
mappings: generatedMap.mappings,
|
|
4006
|
+
names: generatedMap.names,
|
|
4007
|
+
sources: generatedMap.sources,
|
|
4008
|
+
sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
|
|
4009
|
+
})
|
|
4010
|
+
};
|
|
4011
|
+
}
|
|
4012
|
+
if (typeof ret === "string") return { code: ret };
|
|
4013
|
+
if (ret.code instanceof RolldownMagicString) {
|
|
4014
|
+
const magicString = ret.code;
|
|
4015
|
+
const normalizedCode = magicString.toString();
|
|
4016
|
+
if (ret.map === null) return {
|
|
4017
|
+
code: normalizedCode,
|
|
4018
|
+
map: null
|
|
4019
|
+
};
|
|
4020
|
+
if (ret.map === void 0) {
|
|
4021
|
+
const generatedMap = magicString.generateMap();
|
|
4022
|
+
return {
|
|
4023
|
+
code: normalizedCode,
|
|
4024
|
+
map: bindingifySourcemap$1({
|
|
4025
|
+
file: generatedMap.file,
|
|
4026
|
+
mappings: generatedMap.mappings,
|
|
4027
|
+
names: generatedMap.names,
|
|
4028
|
+
sources: generatedMap.sources,
|
|
4029
|
+
sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
|
|
4030
|
+
})
|
|
4031
|
+
};
|
|
4032
|
+
}
|
|
4033
|
+
return {
|
|
4034
|
+
code: normalizedCode,
|
|
4035
|
+
map: bindingifySourcemap$1(ret.map)
|
|
4036
|
+
};
|
|
4037
|
+
}
|
|
4038
|
+
if (ret.map === null) return {
|
|
4039
|
+
code: ret.code,
|
|
4040
|
+
map: null
|
|
4041
|
+
};
|
|
4042
|
+
return {
|
|
4043
|
+
code: ret.code,
|
|
4044
|
+
map: bindingifySourcemap$1(ret.map)
|
|
4045
|
+
};
|
|
4046
|
+
},
|
|
4047
|
+
meta: bindingifyPluginHookMeta(meta),
|
|
4048
|
+
filter: bindingifyRenderChunkFilter(options.filter)
|
|
4049
|
+
};
|
|
4050
|
+
}
|
|
4051
|
+
function bindingifyAugmentChunkHash(args) {
|
|
4052
|
+
const hook = args.plugin.augmentChunkHash;
|
|
4053
|
+
if (!hook) return {};
|
|
4054
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4055
|
+
return {
|
|
4056
|
+
plugin: async (ctx, chunk) => {
|
|
4057
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
4058
|
+
},
|
|
4059
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4060
|
+
};
|
|
4061
|
+
}
|
|
4062
|
+
function bindingifyRenderError(args) {
|
|
4063
|
+
const hook = args.plugin.renderError;
|
|
4064
|
+
if (!hook) return {};
|
|
4065
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4066
|
+
return {
|
|
4067
|
+
plugin: async (ctx, err) => {
|
|
4068
|
+
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), aggregateBindingErrorsIntoJsError(err));
|
|
4069
|
+
},
|
|
4070
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4071
|
+
};
|
|
4072
|
+
}
|
|
4073
|
+
function bindingifyGenerateBundle(args) {
|
|
4074
|
+
const hook = args.plugin.generateBundle;
|
|
4075
|
+
if (!hook) return {};
|
|
4076
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4077
|
+
return {
|
|
4078
|
+
plugin: async (ctx, bundle, isWrite, opts) => {
|
|
4079
|
+
const changed = {
|
|
4080
|
+
updated: /* @__PURE__ */ new Set(),
|
|
4081
|
+
deleted: /* @__PURE__ */ new Set()
|
|
4082
|
+
};
|
|
4083
|
+
const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
|
|
4084
|
+
const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
|
|
4085
|
+
await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
|
|
4086
|
+
return collectChangedBundle(changed, output);
|
|
4087
|
+
},
|
|
4088
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4089
|
+
};
|
|
4090
|
+
}
|
|
4091
|
+
function bindingifyWriteBundle(args) {
|
|
4092
|
+
const hook = args.plugin.writeBundle;
|
|
4093
|
+
if (!hook) return {};
|
|
4094
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4095
|
+
return {
|
|
4096
|
+
plugin: async (ctx, bundle, opts) => {
|
|
4097
|
+
const changed = {
|
|
4098
|
+
updated: /* @__PURE__ */ new Set(),
|
|
4099
|
+
deleted: /* @__PURE__ */ new Set()
|
|
4100
|
+
};
|
|
4101
|
+
const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
|
|
4102
|
+
const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
|
|
4103
|
+
await handler.call(context, args.pluginContextData.getOutputOptions(opts), output);
|
|
4104
|
+
return collectChangedBundle(changed, output);
|
|
4105
|
+
},
|
|
4106
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4107
|
+
};
|
|
4108
|
+
}
|
|
4109
|
+
function bindingifyCloseBundle(args) {
|
|
4110
|
+
const hook = args.plugin.closeBundle;
|
|
4111
|
+
if (!hook) return {};
|
|
4112
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4113
|
+
return {
|
|
4114
|
+
plugin: async (ctx, err) => {
|
|
4115
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
|
|
4116
|
+
},
|
|
4117
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4118
|
+
};
|
|
4119
|
+
}
|
|
4120
|
+
function bindingifyBanner(args) {
|
|
4121
|
+
const hook = args.plugin.banner;
|
|
4122
|
+
if (!hook) return {};
|
|
4123
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4124
|
+
return {
|
|
4125
|
+
plugin: async (ctx, chunk) => {
|
|
4126
|
+
if (typeof handler === "string") return handler;
|
|
4127
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
4128
|
+
},
|
|
4129
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4130
|
+
};
|
|
4131
|
+
}
|
|
4132
|
+
function bindingifyFooter(args) {
|
|
4133
|
+
const hook = args.plugin.footer;
|
|
4134
|
+
if (!hook) return {};
|
|
4135
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4136
|
+
return {
|
|
4137
|
+
plugin: async (ctx, chunk) => {
|
|
4138
|
+
if (typeof handler === "string") return handler;
|
|
4139
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
4140
|
+
},
|
|
4141
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4142
|
+
};
|
|
4143
|
+
}
|
|
4144
|
+
function bindingifyIntro(args) {
|
|
4145
|
+
const hook = args.plugin.intro;
|
|
4146
|
+
if (!hook) return {};
|
|
4147
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4148
|
+
return {
|
|
4149
|
+
plugin: async (ctx, chunk) => {
|
|
4150
|
+
if (typeof handler === "string") return handler;
|
|
4151
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
4152
|
+
},
|
|
4153
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4154
|
+
};
|
|
4155
|
+
}
|
|
4156
|
+
function bindingifyOutro(args) {
|
|
4157
|
+
const hook = args.plugin.outro;
|
|
4158
|
+
if (!hook) return {};
|
|
4159
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4160
|
+
return {
|
|
4161
|
+
plugin: async (ctx, chunk) => {
|
|
4162
|
+
if (typeof handler === "string") return handler;
|
|
4163
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
4164
|
+
},
|
|
4165
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4166
|
+
};
|
|
4167
|
+
}
|
|
4168
|
+
//#endregion
|
|
4169
|
+
//#region src/plugin/bindingify-watch-hooks.ts
|
|
4170
|
+
function bindingifyWatchChange(args) {
|
|
4171
|
+
const hook = args.plugin.watchChange;
|
|
4172
|
+
if (!hook) return {};
|
|
4173
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4174
|
+
return {
|
|
4175
|
+
plugin: async (ctx, id, event) => {
|
|
4176
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
|
|
4177
|
+
},
|
|
4178
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4179
|
+
};
|
|
4180
|
+
}
|
|
4181
|
+
function bindingifyCloseWatcher(args) {
|
|
4182
|
+
const hook = args.plugin.closeWatcher;
|
|
4183
|
+
if (!hook) return {};
|
|
4184
|
+
const { handler, meta } = normalizeHook(hook);
|
|
4185
|
+
return {
|
|
4186
|
+
plugin: async (ctx) => {
|
|
4187
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
4188
|
+
},
|
|
4189
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
4190
|
+
};
|
|
4282
4191
|
}
|
|
4283
4192
|
//#endregion
|
|
4284
|
-
//#region src/plugin/
|
|
4285
|
-
var
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
moduleOptionMap = /* @__PURE__ */ new Map();
|
|
4291
|
-
resolveOptionsMap = /* @__PURE__ */ new Map();
|
|
4292
|
-
loadModulePromiseMap = /* @__PURE__ */ new Map();
|
|
4293
|
-
renderedChunkMeta = null;
|
|
4294
|
-
normalizedInputOptions = null;
|
|
4295
|
-
normalizedOutputOptions = null;
|
|
4296
|
-
constructor(onLog, outputOptions, normalizedInputPlugins, normalizedOutputPlugins) {
|
|
4297
|
-
this.onLog = onLog;
|
|
4298
|
-
this.outputOptions = outputOptions;
|
|
4299
|
-
this.normalizedInputPlugins = normalizedInputPlugins;
|
|
4300
|
-
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
4301
|
-
}
|
|
4302
|
-
updateModuleOption(id, option) {
|
|
4303
|
-
const existing = this.moduleOptionMap.get(id);
|
|
4304
|
-
if (existing) {
|
|
4305
|
-
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
4306
|
-
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
4307
|
-
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
4308
|
-
} else {
|
|
4309
|
-
this.moduleOptionMap.set(id, option);
|
|
4310
|
-
return option;
|
|
4311
|
-
}
|
|
4312
|
-
return existing;
|
|
4313
|
-
}
|
|
4314
|
-
getModuleOption(id) {
|
|
4315
|
-
const option = this.moduleOptionMap.get(id);
|
|
4316
|
-
if (!option) {
|
|
4317
|
-
const raw = {
|
|
4318
|
-
moduleSideEffects: null,
|
|
4319
|
-
meta: {}
|
|
4320
|
-
};
|
|
4321
|
-
this.moduleOptionMap.set(id, raw);
|
|
4322
|
-
return raw;
|
|
4323
|
-
}
|
|
4324
|
-
return option;
|
|
4193
|
+
//#region src/plugin/generated/hook-usage.ts
|
|
4194
|
+
var HookUsage = class {
|
|
4195
|
+
bitflag = BigInt(0);
|
|
4196
|
+
constructor() {}
|
|
4197
|
+
union(kind) {
|
|
4198
|
+
this.bitflag |= BigInt(kind);
|
|
4325
4199
|
}
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
if (bindingInfo) {
|
|
4329
|
-
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
|
|
4330
|
-
return this.proxyModuleInfo(id, info);
|
|
4331
|
-
}
|
|
4332
|
-
return null;
|
|
4200
|
+
inner() {
|
|
4201
|
+
return Number(this.bitflag);
|
|
4333
4202
|
}
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4203
|
+
};
|
|
4204
|
+
function extractHookUsage(plugin) {
|
|
4205
|
+
let hookUsage = new HookUsage();
|
|
4206
|
+
if (plugin.buildStart) hookUsage.union(1);
|
|
4207
|
+
if (plugin.resolveId) hookUsage.union(2);
|
|
4208
|
+
if (plugin.resolveDynamicImport) hookUsage.union(4);
|
|
4209
|
+
if (plugin.load) hookUsage.union(8);
|
|
4210
|
+
if (plugin.transform) hookUsage.union(16);
|
|
4211
|
+
if (plugin.moduleParsed) hookUsage.union(32);
|
|
4212
|
+
if (plugin.buildEnd) hookUsage.union(64);
|
|
4213
|
+
if (plugin.renderStart) hookUsage.union(128);
|
|
4214
|
+
if (plugin.renderError) hookUsage.union(256);
|
|
4215
|
+
if (plugin.renderChunk) hookUsage.union(512);
|
|
4216
|
+
if (plugin.augmentChunkHash) hookUsage.union(1024);
|
|
4217
|
+
if (plugin.generateBundle) hookUsage.union(2048);
|
|
4218
|
+
if (plugin.writeBundle) hookUsage.union(4096);
|
|
4219
|
+
if (plugin.closeBundle) hookUsage.union(8192);
|
|
4220
|
+
if (plugin.watchChange) hookUsage.union(16384);
|
|
4221
|
+
if (plugin.closeWatcher) hookUsage.union(32768);
|
|
4222
|
+
if (plugin.banner) hookUsage.union(131072);
|
|
4223
|
+
if (plugin.footer) hookUsage.union(262144);
|
|
4224
|
+
if (plugin.intro) hookUsage.union(524288);
|
|
4225
|
+
if (plugin.outro) hookUsage.union(1048576);
|
|
4226
|
+
return hookUsage;
|
|
4227
|
+
}
|
|
4228
|
+
//#endregion
|
|
4229
|
+
//#region src/plugin/bindingify-plugin.ts
|
|
4230
|
+
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
4231
|
+
const args = {
|
|
4232
|
+
plugin,
|
|
4233
|
+
options,
|
|
4234
|
+
outputOptions,
|
|
4235
|
+
pluginContextData,
|
|
4236
|
+
onLog,
|
|
4237
|
+
logLevel,
|
|
4238
|
+
watchMode,
|
|
4239
|
+
normalizedOutputPlugins
|
|
4240
|
+
};
|
|
4241
|
+
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
4242
|
+
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
|
|
4243
|
+
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
4244
|
+
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
4245
|
+
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
|
|
4246
|
+
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
4247
|
+
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
|
|
4248
|
+
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
|
|
4249
|
+
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
4250
|
+
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
4251
|
+
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
4252
|
+
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
4253
|
+
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
4254
|
+
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
4255
|
+
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
4256
|
+
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
4257
|
+
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
4258
|
+
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
4259
|
+
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
4260
|
+
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
4261
|
+
let hookUsage = extractHookUsage(plugin).inner();
|
|
4262
|
+
return wrapHandlers({
|
|
4263
|
+
name: plugin.name,
|
|
4264
|
+
buildStart,
|
|
4265
|
+
buildStartMeta,
|
|
4266
|
+
resolveId,
|
|
4267
|
+
resolveIdMeta,
|
|
4268
|
+
resolveIdFilter,
|
|
4269
|
+
resolveDynamicImport,
|
|
4270
|
+
resolveDynamicImportMeta,
|
|
4271
|
+
buildEnd,
|
|
4272
|
+
buildEndMeta,
|
|
4273
|
+
transform,
|
|
4274
|
+
transformMeta,
|
|
4275
|
+
transformFilter,
|
|
4276
|
+
moduleParsed,
|
|
4277
|
+
moduleParsedMeta,
|
|
4278
|
+
load,
|
|
4279
|
+
loadMeta,
|
|
4280
|
+
loadFilter,
|
|
4281
|
+
renderChunk,
|
|
4282
|
+
renderChunkMeta,
|
|
4283
|
+
renderChunkFilter,
|
|
4284
|
+
augmentChunkHash,
|
|
4285
|
+
augmentChunkHashMeta,
|
|
4286
|
+
renderStart,
|
|
4287
|
+
renderStartMeta,
|
|
4288
|
+
renderError,
|
|
4289
|
+
renderErrorMeta,
|
|
4290
|
+
generateBundle,
|
|
4291
|
+
generateBundleMeta,
|
|
4292
|
+
writeBundle,
|
|
4293
|
+
writeBundleMeta,
|
|
4294
|
+
closeBundle,
|
|
4295
|
+
closeBundleMeta,
|
|
4296
|
+
banner,
|
|
4297
|
+
bannerMeta,
|
|
4298
|
+
footer,
|
|
4299
|
+
footerMeta,
|
|
4300
|
+
intro,
|
|
4301
|
+
introMeta,
|
|
4302
|
+
outro,
|
|
4303
|
+
outroMeta,
|
|
4304
|
+
watchChange,
|
|
4305
|
+
watchChangeMeta,
|
|
4306
|
+
closeWatcher,
|
|
4307
|
+
closeWatcherMeta,
|
|
4308
|
+
hookUsage
|
|
4309
|
+
});
|
|
4310
|
+
}
|
|
4311
|
+
function wrapHandlers(plugin) {
|
|
4312
|
+
for (const hookName of [
|
|
4313
|
+
"buildStart",
|
|
4314
|
+
"resolveId",
|
|
4315
|
+
"resolveDynamicImport",
|
|
4316
|
+
"buildEnd",
|
|
4317
|
+
"transform",
|
|
4318
|
+
"moduleParsed",
|
|
4319
|
+
"load",
|
|
4320
|
+
"renderChunk",
|
|
4321
|
+
"augmentChunkHash",
|
|
4322
|
+
"renderStart",
|
|
4323
|
+
"renderError",
|
|
4324
|
+
"generateBundle",
|
|
4325
|
+
"writeBundle",
|
|
4326
|
+
"closeBundle",
|
|
4327
|
+
"banner",
|
|
4328
|
+
"footer",
|
|
4329
|
+
"intro",
|
|
4330
|
+
"outro",
|
|
4331
|
+
"watchChange",
|
|
4332
|
+
"closeWatcher"
|
|
4333
|
+
]) {
|
|
4334
|
+
const handler = plugin[hookName];
|
|
4335
|
+
if (handler) plugin[hookName] = async (...args) => {
|
|
4336
|
+
try {
|
|
4337
|
+
return await handler(...args);
|
|
4338
|
+
} catch (e) {
|
|
4339
|
+
return error(logPluginError(e, plugin.name, {
|
|
4340
|
+
hook: hookName,
|
|
4341
|
+
id: hookName === "transform" ? args[2] : void 0
|
|
4342
|
+
}));
|
|
4347
4343
|
}
|
|
4348
|
-
}
|
|
4349
|
-
return info;
|
|
4350
|
-
}
|
|
4351
|
-
getModuleIds(context) {
|
|
4352
|
-
return context.getModuleIds().values();
|
|
4353
|
-
}
|
|
4354
|
-
saveResolveOptions(options) {
|
|
4355
|
-
const index = this.resolveOptionsMap.size;
|
|
4356
|
-
this.resolveOptionsMap.set(index, options);
|
|
4357
|
-
return index;
|
|
4358
|
-
}
|
|
4359
|
-
getSavedResolveOptions(receipt) {
|
|
4360
|
-
return this.resolveOptionsMap.get(receipt);
|
|
4361
|
-
}
|
|
4362
|
-
removeSavedResolveOptions(receipt) {
|
|
4363
|
-
this.resolveOptionsMap.delete(receipt);
|
|
4364
|
-
}
|
|
4365
|
-
setRenderChunkMeta(meta) {
|
|
4366
|
-
this.renderedChunkMeta = meta;
|
|
4367
|
-
}
|
|
4368
|
-
getRenderChunkMeta() {
|
|
4369
|
-
return this.renderedChunkMeta;
|
|
4370
|
-
}
|
|
4371
|
-
getInputOptions(opts) {
|
|
4372
|
-
this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog, this.normalizedInputPlugins);
|
|
4373
|
-
return this.normalizedInputOptions;
|
|
4374
|
-
}
|
|
4375
|
-
getOutputOptions(opts) {
|
|
4376
|
-
this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
|
|
4377
|
-
return this.normalizedOutputOptions;
|
|
4378
|
-
}
|
|
4379
|
-
clear() {
|
|
4380
|
-
this.renderedChunkMeta = null;
|
|
4381
|
-
this.loadModulePromiseMap.clear();
|
|
4344
|
+
};
|
|
4382
4345
|
}
|
|
4383
|
-
|
|
4346
|
+
return plugin;
|
|
4347
|
+
}
|
|
4384
4348
|
//#endregion
|
|
4385
4349
|
//#region src/utils/normalize-transform-options.ts
|
|
4386
4350
|
/**
|
|
@@ -4410,8 +4374,7 @@ function normalizeTransformOptions(inputOptions) {
|
|
|
4410
4374
|
}
|
|
4411
4375
|
//#endregion
|
|
4412
4376
|
//#region src/utils/bindingify-input-options.ts
|
|
4413
|
-
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions,
|
|
4414
|
-
const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedInputPlugins, normalizedOutputPlugins);
|
|
4377
|
+
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
4415
4378
|
const plugins = rawPlugins.map((plugin) => {
|
|
4416
4379
|
if ("_parallel" in plugin) return;
|
|
4417
4380
|
if (plugin instanceof BuiltinPlugin) switch (plugin.name) {
|
|
@@ -4653,15 +4616,14 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
|
|
|
4653
4616
|
//#region src/types/chunking-context.ts
|
|
4654
4617
|
var ChunkingContextImpl = class {
|
|
4655
4618
|
context;
|
|
4656
|
-
|
|
4619
|
+
pluginContextData;
|
|
4620
|
+
constructor(context, pluginContextData) {
|
|
4657
4621
|
this.context = context;
|
|
4622
|
+
this.pluginContextData = pluginContextData;
|
|
4658
4623
|
}
|
|
4659
4624
|
getModuleInfo(moduleId) {
|
|
4660
4625
|
const bindingInfo = this.context.getModuleInfo(moduleId);
|
|
4661
|
-
if (bindingInfo) return transformModuleInfo(bindingInfo,
|
|
4662
|
-
moduleSideEffects: null,
|
|
4663
|
-
meta: {}
|
|
4664
|
-
});
|
|
4626
|
+
if (bindingInfo) return transformModuleInfo(bindingInfo, this.pluginContextData.getModuleOption(moduleId));
|
|
4665
4627
|
return null;
|
|
4666
4628
|
}
|
|
4667
4629
|
};
|
|
@@ -5107,10 +5069,10 @@ createConsola();
|
|
|
5107
5069
|
const logger = createConsola({ formatOptions: { date: false } });
|
|
5108
5070
|
//#endregion
|
|
5109
5071
|
//#region src/utils/bindingify-output-options.ts
|
|
5110
|
-
function bindingifyOutputOptions(outputOptions) {
|
|
5072
|
+
function bindingifyOutputOptions(outputOptions, pluginContextData) {
|
|
5111
5073
|
const { dir, format, exports, hashCharacters, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapExcludeSources, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, banner, footer, postBanner, postFooter, intro, outro, esModule, globals, paths, generatedCode, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, comments, preserveModulesRoot, manualChunks, topLevelVar, cleanDir, strictExecutionOrder } = outputOptions;
|
|
5112
5074
|
if (legalComments != null) logger.warn("`legalComments` option is deprecated, please use `comments.legal` instead.");
|
|
5113
|
-
const { inlineDynamicImports, advancedChunks } = bindingifyCodeSplitting(outputOptions.codeSplitting, outputOptions.inlineDynamicImports, outputOptions.advancedChunks, manualChunks);
|
|
5075
|
+
const { inlineDynamicImports, advancedChunks } = bindingifyCodeSplitting(outputOptions.codeSplitting, outputOptions.inlineDynamicImports, outputOptions.advancedChunks, manualChunks, pluginContextData);
|
|
5114
5076
|
return {
|
|
5115
5077
|
dir,
|
|
5116
5078
|
file: file == null ? void 0 : file,
|
|
@@ -5204,7 +5166,7 @@ function bindingifyComments(comments) {
|
|
|
5204
5166
|
if (typeof comments === "boolean") return comments;
|
|
5205
5167
|
return comments;
|
|
5206
5168
|
}
|
|
5207
|
-
function bindingifyCodeSplitting(codeSplitting, inlineDynamicImportsOption, advancedChunks, manualChunks) {
|
|
5169
|
+
function bindingifyCodeSplitting(codeSplitting, inlineDynamicImportsOption, advancedChunks, manualChunks, pluginContextData) {
|
|
5208
5170
|
let inlineDynamicImports;
|
|
5209
5171
|
let effectiveChunksOption;
|
|
5210
5172
|
if (codeSplitting === false) {
|
|
@@ -5237,6 +5199,10 @@ function bindingifyCodeSplitting(codeSplitting, inlineDynamicImportsOption, adva
|
|
|
5237
5199
|
else if (manualChunks != null) effectiveChunksOption = { groups: [{ name(moduleId, ctx) {
|
|
5238
5200
|
return manualChunks(moduleId, { getModuleInfo: (id) => ctx.getModuleInfo(id) });
|
|
5239
5201
|
} }] };
|
|
5202
|
+
if (inlineDynamicImports === true && effectiveChunksOption != null) {
|
|
5203
|
+
logger.warn("`advancedChunks` option is ignored because `inlineDynamicImports: true` disables code splitting.");
|
|
5204
|
+
effectiveChunksOption = void 0;
|
|
5205
|
+
}
|
|
5240
5206
|
let advancedChunksResult;
|
|
5241
5207
|
if (effectiveChunksOption != null) {
|
|
5242
5208
|
const { groups, ...restOptions } = effectiveChunksOption;
|
|
@@ -5246,7 +5212,7 @@ function bindingifyCodeSplitting(codeSplitting, inlineDynamicImportsOption, adva
|
|
|
5246
5212
|
const { name, ...restGroup } = group;
|
|
5247
5213
|
return {
|
|
5248
5214
|
...restGroup,
|
|
5249
|
-
name: typeof name === "function" ? (id, ctx) => name(id, new ChunkingContextImpl(ctx)) : name
|
|
5215
|
+
name: typeof name === "function" ? (id, ctx) => name(id, new ChunkingContextImpl(ctx, pluginContextData)) : name
|
|
5250
5216
|
};
|
|
5251
5217
|
})
|
|
5252
5218
|
};
|
|
@@ -5270,10 +5236,11 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
|
|
|
5270
5236
|
let plugins = [...normalizedInputPlugins, ...checkOutputPluginOption(normalizedOutputPlugins, onLog)];
|
|
5271
5237
|
if (inputOptions.experimental?.strictExecutionOrder !== void 0) console.warn("`experimental.strictExecutionOrder` has been stabilized and moved to `output.strictExecutionOrder`. Please update your configuration.");
|
|
5272
5238
|
try {
|
|
5239
|
+
const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedInputPlugins, normalizedOutputPlugins);
|
|
5273
5240
|
return {
|
|
5274
5241
|
bundlerOptions: {
|
|
5275
|
-
inputOptions: bindingifyInputOptions(plugins, inputOptions, outputOptions,
|
|
5276
|
-
outputOptions: bindingifyOutputOptions(outputOptions),
|
|
5242
|
+
inputOptions: bindingifyInputOptions(plugins, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode),
|
|
5243
|
+
outputOptions: bindingifyOutputOptions(outputOptions, pluginContextData),
|
|
5277
5244
|
parallelPluginsRegistry: void 0
|
|
5278
5245
|
},
|
|
5279
5246
|
inputOptions,
|