@rolldown/browser 1.1.2 → 1.1.4

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