weapp-vite 6.23.0 → 6.25.0

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.
@@ -1,6 +1,6 @@
1
1
  import { n as applyWeappViteHostMeta } from "./pluginHost--CaeyWpA.mjs";
2
+ import { C as inlineAutoRoutesImports, T as MINI_PROGRAM_PLATFORM_ADAPTERS, _ as templateExtensions, a as findJsonEntry, b as isNativeTemplateSource, c as isJsOrTs, d as touch, g as supportedCssLangs, h as scriptExtensions, i as findJsEntry, l as isTemplate, m as jsExtensions, n as changeFileExtension, o as findTemplateEntry, p as configExtensions, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as vueExtensions, x as isSourceStyleExtension, y as ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS } from "./file-zQ4br3El.mjs";
2
3
  import { n as configureLogger, r as logger_default } from "./logger-mt4mSTqV.mjs";
3
- import { C as isNativeTemplateSource, S as ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS, T as MINI_PROGRAM_PLATFORM_ADAPTERS, _ as jsExtensions, a as findJsonEntry, b as templateExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as scriptExtensions, w as isSourceStyleExtension, x as vueExtensions, y as supportedCssLangs } from "./file-Cr034LIZ.mjs";
4
4
  import { createRequire, isBuiltin } from "node:module";
5
5
  import { createDebug } from "obug";
6
6
  import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
@@ -9,16 +9,16 @@ import path, { posix } from "pathe";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import path$1, { normalize, relative, win32 } from "node:path";
11
11
  import { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, addExtension, defu, escapeStringRegexp, escapeWxmlAttribute, escapeWxmlText, get, getDefaultMiniProgramPlatform, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, isEmptyObject, isObject, normalizeMiniProgramPlatform, removeExtension, removeExtensionDeep, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle } from "@weapp-core/shared";
12
+ import { parse, stringify } from "comment-json";
12
13
  import { fs as fs$1 } from "@weapp-core/shared/fs";
13
- import { BABEL_TS_MODULE_PARSER_OPTIONS, analyzeScript as analyzeScript$1, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parse, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
14
+ import process from "node:process";
15
+ import { compileScript, parse as parse$1 } from "vue/compiler-sfc";
16
+ import { BABEL_TS_MODULE_PARSER_OPTIONS, analyzeScript as analyzeScript$1, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parse as parse$2, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
14
17
  import { collectOnPageScrollPerformanceWarnings } from "@weapp-vite/ast/operations/onPageScroll";
15
18
  import { collectSetDataPickKeysFromTemplateCode } from "@weapp-vite/ast/operations/setDataPick";
16
19
  import { BABEL_TS_MODULE_PARSER_OPTIONS as BABEL_TS_MODULE_PARSER_OPTIONS$1, generate as generate$1, getVisitorKeys, parse as parse$3, parseJsLike, traverse } from "@weapp-vite/ast/babel";
17
- import { compileScript, parse as parse$1 } from "vue/compiler-sfc";
18
20
  import picomatch from "picomatch";
19
- import { VUE_COMPONENT_TAG_RE, WE_VU_COMPILER_REACTIVITY_MODULE_ID, WE_VU_COMPILER_RUNTIME_MODULE_ID, WE_VU_COMPILER_TEMPLATE_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, collectVueTemplateTags, compileJsxFile, compileVueFile, compileVueStyleToWxss, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isUniAppCompatibilityFile, pathExists, readAndParseSfc, readFile as readFile$1, refreshVueFileJsonConfig, resolveClassStyleWxsLocation, stripJsonMacroCallsFromCode, transformNestedWxssVars, transformUniAppSource, transformVueDeepSelectors } from "wevu/compiler";
20
- import process from "node:process";
21
- import { parse as parse$2, stringify } from "comment-json";
21
+ import { VUE_COMPONENT_TAG_RE, WE_VU_COMPILER_REACTIVITY_MODULE_ID, WE_VU_COMPILER_RUNTIME_MODULE_ID, WE_VU_COMPILER_TEMPLATE_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, classifyVueSfcBlockChanges, collectVueTemplateTags, compileJsxFile, compileVueFile, compileVueStyleToWxss, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isUniAppCompatibilityFile, pathExists, readAndParseSfc, readFile as readFile$1, refreshVueFileJsonConfig, resolveClassStyleWxsLocation, resolveVueSfcHmrSignatures, resolveVueSfcStyleIndependentSignature, transformNestedWxssVars, transformUniAppSource, transformVueDeepSelectors } from "wevu/compiler";
22
22
  import fs$2, { appendFile, copyFile, mkdir, readFile, readdir, rm } from "node:fs/promises";
23
23
  import { build, createLogger, createServer, loadConfigFromFile, preprocessCSS, transformWithOxc } from "vite";
24
24
  import { createHash, randomBytes } from "node:crypto";
@@ -725,179 +725,6 @@ function getVueComponentsSettings(ctx) {
725
725
  return { enabled: false };
726
726
  }
727
727
  //#endregion
728
- //#region src/runtime/autoImport/service/actions.ts
729
- function createAutoImportActions(options) {
730
- function bumpVersion() {
731
- options.autoImportState.version += 1;
732
- }
733
- async function awaitOutputWrites() {
734
- while (true) {
735
- const pending = [
736
- ...options.pendingRegistrations,
737
- options.outputsState.pendingWrite,
738
- options.outputsState.pendingTypedWrite,
739
- options.outputsState.pendingHtmlCustomDataWrite,
740
- options.outputsState.pendingVueComponentsWrite
741
- ].filter((task) => Boolean(task));
742
- if (!pending.length) return;
743
- await Promise.all(pending);
744
- }
745
- }
746
- function setSupportFileResolverComponents(components) {
747
- if (!options.resolverHelpers.setSupportFileResolverComponents(components)) return;
748
- bumpVersion();
749
- options.deferOrSchedule("manifest", true);
750
- const { typed, html, vue } = options.getOutputSettingsSnapshot();
751
- if (typed.enabled || html.enabled) options.resolverHelpers.syncResolverComponentProps();
752
- if (typed.enabled) options.deferOrSchedule("typed", true);
753
- if (html.enabled) options.deferOrSchedule("html", true);
754
- if (vue.enabled) {
755
- options.resolverHelpers.syncResolverComponentProps();
756
- options.deferOrSchedule("vue", true);
757
- }
758
- }
759
- function clearSupportFileResolverComponents() {
760
- if (!options.resolverHelpers.clearSupportFileResolverComponents()) return;
761
- bumpVersion();
762
- options.resolverHelpers.syncResolverComponentProps();
763
- }
764
- return {
765
- reset() {
766
- bumpVersion();
767
- options.registry.clear();
768
- options.autoImportState.matcher = void 0;
769
- options.autoImportState.matcherKey = "";
770
- options.autoImportState.preparedGlobsKey = void 0;
771
- options.resolvedResolverComponents.clear();
772
- options.resolverHelpers.clearResolveCache();
773
- options.deferOrSchedule("manifest", true);
774
- options.componentMetadataMap.clear();
775
- options.resolverComponentNames.clear();
776
- const { typed, html, vue } = options.getOutputSettingsSnapshot();
777
- if (typed.enabled || html.enabled) options.resolverHelpers.syncResolverComponentProps();
778
- options.deferOrSchedule("typed", true);
779
- options.deferOrSchedule("html", true);
780
- if (vue.enabled) options.resolverHelpers.syncResolverComponentProps();
781
- options.deferOrSchedule("vue", true);
782
- },
783
- async registerPotentialComponent(filePath) {
784
- const task = Promise.resolve().then(async () => {
785
- await options.registryHelpers.registerLocalComponent(filePath);
786
- }).finally(() => {
787
- options.pendingRegistrations.delete(task);
788
- });
789
- options.pendingRegistrations.add(task);
790
- await task;
791
- },
792
- removePotentialComponent(filePath) {
793
- bumpVersion();
794
- const { removed, removedNames } = options.registryHelpers.removeRegisteredComponent({
795
- baseName: removeExtensionDeep(filePath),
796
- templatePath: filePath
797
- });
798
- options.deferOrSchedule("manifest", removed);
799
- for (const name of removedNames) if (options.resolverComponentNames.has(name)) options.componentMetadataMap.set(name, {
800
- types: /* @__PURE__ */ new Map(),
801
- docs: /* @__PURE__ */ new Map()
802
- });
803
- else options.componentMetadataMap.delete(name);
804
- const shouldWriteArtifacts = removed || removedNames.length > 0;
805
- options.deferOrSchedule("typed", shouldWriteArtifacts);
806
- options.deferOrSchedule("html", shouldWriteArtifacts);
807
- options.deferOrSchedule("vue", shouldWriteArtifacts);
808
- },
809
- setSupportFileResolverComponents,
810
- clearSupportFileResolverComponents,
811
- async syncSupportFileResolverComponents() {
812
- try {
813
- setSupportFileResolverComponents(options.resolverHelpers.collectStaticResolverComponentsForSupportFiles());
814
- await awaitOutputWrites();
815
- } finally {
816
- clearSupportFileResolverComponents();
817
- }
818
- },
819
- collectStaticResolverComponentsForSupportFiles() {
820
- return options.resolverHelpers.collectStaticResolverComponentsForSupportFiles();
821
- },
822
- resolve(componentName, importerBaseName) {
823
- const local = options.registry.get(componentName);
824
- if (local) return local;
825
- const resolvedValue = options.resolverHelpers.resolveWithResolvers(componentName, importerBaseName);
826
- if (!resolvedValue) return;
827
- const resolverChanged = options.resolvedResolverComponents.get(resolvedValue.name) !== resolvedValue.from;
828
- options.resolvedResolverComponents.set(resolvedValue.name, resolvedValue.from);
829
- if (resolverChanged) bumpVersion();
830
- const resolved = {
831
- kind: "resolver",
832
- value: resolvedValue
833
- };
834
- const { typed, html, vue } = options.getOutputSettingsSnapshot();
835
- if (typed.enabled || html.enabled) {
836
- const metadataMissing = !options.componentMetadataMap.has(resolved.value.name);
837
- if (metadataMissing) options.componentMetadataMap.set(resolved.value.name, {
838
- types: /* @__PURE__ */ new Map(),
839
- docs: /* @__PURE__ */ new Map()
840
- });
841
- if (typed.enabled && (resolverChanged || metadataMissing)) options.deferOrSchedule("typed", true);
842
- if (html.enabled && (resolverChanged || metadataMissing)) options.deferOrSchedule("html", true);
843
- } else options.componentMetadataMap.delete(resolved.value.name);
844
- if (vue.enabled && resolverChanged) options.deferOrSchedule("vue", true);
845
- if (resolverChanged) options.deferOrSchedule("manifest", true);
846
- return resolved;
847
- },
848
- filter(id) {
849
- const globMatcher = options.registryHelpers.ensureMatcher();
850
- if (!globMatcher) return false;
851
- return globMatcher(id);
852
- },
853
- getRegisteredLocalComponents() {
854
- return Array.from(options.registry.values());
855
- },
856
- hasPendingRegistrations() {
857
- return options.pendingRegistrations.size > 0;
858
- },
859
- awaitPendingRegistrations() {
860
- return Promise.all([...options.pendingRegistrations]).then(() => {});
861
- },
862
- awaitManifestWrites() {
863
- return awaitOutputWrites();
864
- }
865
- };
866
- }
867
- //#endregion
868
- //#region src/ast/index.ts
869
- /**
870
- * 解析 AST 引擎配置。
871
- */
872
- function resolveAstEngine(config) {
873
- return config?.ast?.engine ?? "babel";
874
- }
875
- //#endregion
876
- //#region src/context/shared.ts
877
- const debug$2 = createDebugger("weapp-vite:context");
878
- function hasOwn$6(source, key) {
879
- return Object.prototype.hasOwnProperty.call(source, key);
880
- }
881
- function resolvedComponentName(entry) {
882
- const base = path.basename(entry);
883
- if (base === "index") {
884
- const dirName = path.dirname(entry);
885
- if (dirName === ".") return { base };
886
- return {
887
- componentName: path.basename(dirName),
888
- base
889
- };
890
- }
891
- return {
892
- componentName: base,
893
- base
894
- };
895
- }
896
- function isEmptyObject$1(obj) {
897
- for (const key in obj) if (hasOwn$6(obj, key)) return false;
898
- return true;
899
- }
900
- //#endregion
901
728
  //#region src/platform.ts
902
729
  const DEFAULT_MP_PLATFORM = getDefaultMiniProgramPlatform();
903
730
  const NPM_PROTOCOL_RE$1 = /^npm:/;
@@ -1198,6 +1025,315 @@ function normalizeNpmImportPathByPlatform(importee, options) {
1198
1025
  return normalizePlatformNpmImportPath(options.platform, normalized, { alipayNpmMode: options.alipayNpmMode });
1199
1026
  }
1200
1027
  //#endregion
1028
+ //#region src/utils/json.ts
1029
+ const ALIPAY_GENERIC_COMPONENT_PLACEHOLDER = "./__weapp_vite_generic_component";
1030
+ const WEAPP_SCOPED_SLOT_GENERIC_COMPONENT_PLACEHOLDER = "./__weapp_vite_scoped_slot_generic_component";
1031
+ const JSON_FILE_JS_EXTENSION_RE = /\.[jt]s$/;
1032
+ const COMPONENT_NAME_LOWER_TO_UPPER_RE = /([a-z0-9])([A-Z])/g;
1033
+ const COMPONENT_NAME_MULTI_UPPER_RE = /([A-Z]+)([A-Z][a-z])/g;
1034
+ const COMPONENT_NAME_HAS_UPPER_RE = /[A-Z]/;
1035
+ const SCOPED_SLOT_GENERIC_KEY_RE$1 = /^scoped-slots-/;
1036
+ function parseCommentJson(json) {
1037
+ return parse(json, void 0, true);
1038
+ }
1039
+ function jsonFileRemoveJsExtension(fileName) {
1040
+ return fileName.replace(JSON_FILE_JS_EXTENSION_RE, "");
1041
+ }
1042
+ function stringifyJson$1(value, replacer) {
1043
+ return stringify(value, replacer, 2);
1044
+ }
1045
+ function normalizeAppJson(json) {
1046
+ if (!json || typeof json !== "object" || Array.isArray(json)) return json;
1047
+ const subPackages = Array.isArray(json.subPackages) ? json.subPackages : Array.isArray(json.subpackages) ? json.subpackages : [];
1048
+ const { subpackages: _subpackages, ...rest } = json;
1049
+ return {
1050
+ ...rest,
1051
+ subPackages: subPackages.map((subPackage) => ({
1052
+ ...subPackage,
1053
+ pages: Array.isArray(subPackage?.pages) ? subPackage.pages : []
1054
+ }))
1055
+ };
1056
+ }
1057
+ function matches(pattern, importee) {
1058
+ if (pattern instanceof RegExp) return pattern.test(importee);
1059
+ if (importee.length < pattern.length) return false;
1060
+ if (importee === pattern) return true;
1061
+ return importee.startsWith(pattern + "/");
1062
+ }
1063
+ function getAliasEntries(options = {}) {
1064
+ if (options === false) return [];
1065
+ const { entries } = options;
1066
+ if (!entries) return [];
1067
+ if (Array.isArray(entries)) return entries.map((entry) => {
1068
+ return {
1069
+ find: entry.find,
1070
+ replacement: entry.replacement
1071
+ };
1072
+ });
1073
+ return Object.entries(entries).map(([key, value]) => {
1074
+ return {
1075
+ find: key,
1076
+ replacement: value
1077
+ };
1078
+ });
1079
+ }
1080
+ function resolveImportee$1(importee, jsonPath, aliasEntries) {
1081
+ if (Array.isArray(aliasEntries)) {
1082
+ if (!jsonPath) return importee;
1083
+ const matchedEntry = aliasEntries.find((x) => matches(x.find, importee));
1084
+ if (!matchedEntry) return importee;
1085
+ const updatedId = importee.replace(matchedEntry.find, matchedEntry.replacement);
1086
+ return toPosixPath(path.relative(path.dirname(jsonPath), updatedId));
1087
+ }
1088
+ return importee;
1089
+ }
1090
+ function toKebabCaseComponentName(name) {
1091
+ return name.replace(COMPONENT_NAME_LOWER_TO_UPPER_RE, "$1-$2").replace(COMPONENT_NAME_MULTI_UPPER_RE, "$1-$2").toLowerCase();
1092
+ }
1093
+ function normalizeUsingComponentPathByPlatform(importee, platform, dependencies, mode) {
1094
+ if (!hasNpmDependencyPrefix(dependencies, importee) && !importee.trim().startsWith("/")) return importee;
1095
+ return normalizeNpmImportPathByPlatform(importee, {
1096
+ platform,
1097
+ dependencies,
1098
+ alipayNpmMode: mode
1099
+ });
1100
+ }
1101
+ function normalizeUsingComponentsByPlatform(usingComponents, platform, options) {
1102
+ if (!shouldNormalizeUsingComponents(platform)) return usingComponents;
1103
+ const normalized = {};
1104
+ for (const [key, value] of Object.entries(usingComponents)) {
1105
+ const nextKey = COMPONENT_NAME_HAS_UPPER_RE.test(key) ? toKebabCaseComponentName(key) : key;
1106
+ const nextValue = normalizeUsingComponentPathByPlatform(value, platform, options?.dependencies, options?.alipayNpmMode);
1107
+ if (!Reflect.has(normalized, nextKey)) normalized[nextKey] = nextValue;
1108
+ }
1109
+ return normalized;
1110
+ }
1111
+ function normalizeComponentGenericsByPlatform(componentGenerics, platform) {
1112
+ if (!shouldFillComponentGenericsDefault(platform) && platform !== "weapp") return componentGenerics;
1113
+ const normalized = {};
1114
+ for (const [key, value] of Object.entries(componentGenerics)) {
1115
+ const placeholder = platform === "weapp" ? SCOPED_SLOT_GENERIC_KEY_RE$1.test(key) ? WEAPP_SCOPED_SLOT_GENERIC_COMPONENT_PLACEHOLDER : void 0 : ALIPAY_GENERIC_COMPONENT_PLACEHOLDER;
1116
+ if (!placeholder) {
1117
+ normalized[key] = value;
1118
+ continue;
1119
+ }
1120
+ if (value === true) {
1121
+ normalized[key] = { default: placeholder };
1122
+ continue;
1123
+ }
1124
+ if (isObject(value)) {
1125
+ const nextValue = { ...value };
1126
+ if (typeof nextValue.default !== "string" || !nextValue.default.trim()) nextValue.default = placeholder;
1127
+ normalized[key] = nextValue;
1128
+ continue;
1129
+ }
1130
+ normalized[key] = value;
1131
+ }
1132
+ return normalized;
1133
+ }
1134
+ function resolveJson(entry, aliasEntries, platform, options) {
1135
+ if (entry.json) {
1136
+ const json = entry.type === "app" ? normalizeAppJson(structuredClone(entry.json)) : structuredClone(entry.json);
1137
+ if (entry.jsonPath && Array.isArray(aliasEntries)) {
1138
+ const usingComponents = get(json, "usingComponents");
1139
+ if (isObject(usingComponents)) {
1140
+ for (const [key, importee] of Object.entries(usingComponents)) {
1141
+ const resolvedId = resolveImportee$1(importee, entry.jsonPath, aliasEntries);
1142
+ set(json, `usingComponents.${key}`, resolvedId);
1143
+ }
1144
+ set(json, "usingComponents", normalizeUsingComponentsByPlatform(usingComponents, platform, options));
1145
+ }
1146
+ if (entry.type === "app") for (const field of ["subPackages", "subpackages"]) {
1147
+ const subPackages = get(json, field);
1148
+ if (Array.isArray(subPackages)) {
1149
+ for (const subPackage of subPackages) if (subPackage.entry) subPackage.entry = changeFileExtension(subPackage.entry, "js");
1150
+ }
1151
+ }
1152
+ } else {
1153
+ const usingComponents = get(json, "usingComponents");
1154
+ if (isObject(usingComponents)) set(json, "usingComponents", normalizeUsingComponentsByPlatform(usingComponents, platform, options));
1155
+ }
1156
+ const componentGenerics = get(json, "componentGenerics");
1157
+ if (isObject(componentGenerics)) set(json, "componentGenerics", normalizeComponentGenericsByPlatform(componentGenerics, platform));
1158
+ if (Reflect.has(json, "$schema")) delete json.$schema;
1159
+ return stringifyJson$1(json);
1160
+ }
1161
+ }
1162
+ //#endregion
1163
+ //#region src/runtime/autoImport/service/actions.ts
1164
+ function createAutoImportActions(options) {
1165
+ function bumpVersion() {
1166
+ options.autoImportState.version += 1;
1167
+ }
1168
+ async function awaitOutputWrites() {
1169
+ while (true) {
1170
+ const pending = [
1171
+ ...options.pendingRegistrations,
1172
+ options.outputsState.pendingWrite,
1173
+ options.outputsState.pendingTypedWrite,
1174
+ options.outputsState.pendingHtmlCustomDataWrite,
1175
+ options.outputsState.pendingVueComponentsWrite
1176
+ ].filter((task) => Boolean(task));
1177
+ if (!pending.length) return;
1178
+ await Promise.all(pending);
1179
+ }
1180
+ }
1181
+ function setSupportFileResolverComponents(components) {
1182
+ if (!options.resolverHelpers.setSupportFileResolverComponents(components)) return;
1183
+ bumpVersion();
1184
+ options.deferOrSchedule("manifest", true);
1185
+ const { typed, html, vue } = options.getOutputSettingsSnapshot();
1186
+ if (typed.enabled || html.enabled) options.resolverHelpers.syncResolverComponentProps();
1187
+ if (typed.enabled) options.deferOrSchedule("typed", true);
1188
+ if (html.enabled) options.deferOrSchedule("html", true);
1189
+ if (vue.enabled) {
1190
+ options.resolverHelpers.syncResolverComponentProps();
1191
+ options.deferOrSchedule("vue", true);
1192
+ }
1193
+ }
1194
+ function clearSupportFileResolverComponents() {
1195
+ if (!options.resolverHelpers.clearSupportFileResolverComponents()) return;
1196
+ bumpVersion();
1197
+ options.resolverHelpers.syncResolverComponentProps();
1198
+ }
1199
+ return {
1200
+ reset() {
1201
+ bumpVersion();
1202
+ options.registry.clear();
1203
+ options.normalizedLocalComponents.clear();
1204
+ options.autoImportState.matcher = void 0;
1205
+ options.autoImportState.matcherKey = "";
1206
+ options.autoImportState.preparedGlobsKey = void 0;
1207
+ options.resolvedResolverComponents.clear();
1208
+ options.resolverHelpers.clearResolveCache();
1209
+ options.deferOrSchedule("manifest", true);
1210
+ options.componentMetadataMap.clear();
1211
+ options.resolverComponentNames.clear();
1212
+ const { typed, html, vue } = options.getOutputSettingsSnapshot();
1213
+ if (typed.enabled || html.enabled) options.resolverHelpers.syncResolverComponentProps();
1214
+ options.deferOrSchedule("typed", true);
1215
+ options.deferOrSchedule("html", true);
1216
+ if (vue.enabled) options.resolverHelpers.syncResolverComponentProps();
1217
+ options.deferOrSchedule("vue", true);
1218
+ },
1219
+ async registerPotentialComponent(filePath) {
1220
+ const task = Promise.resolve().then(async () => {
1221
+ await options.registryHelpers.registerLocalComponent(filePath);
1222
+ }).finally(() => {
1223
+ options.pendingRegistrations.delete(task);
1224
+ });
1225
+ options.pendingRegistrations.add(task);
1226
+ await task;
1227
+ },
1228
+ removePotentialComponent(filePath) {
1229
+ bumpVersion();
1230
+ const { removed, removedNames } = options.registryHelpers.removeRegisteredComponent({
1231
+ baseName: removeExtensionDeep(filePath),
1232
+ templatePath: filePath
1233
+ });
1234
+ options.deferOrSchedule("manifest", removed);
1235
+ for (const name of removedNames) if (options.resolverComponentNames.has(name)) options.componentMetadataMap.set(name, {
1236
+ types: /* @__PURE__ */ new Map(),
1237
+ docs: /* @__PURE__ */ new Map()
1238
+ });
1239
+ else options.componentMetadataMap.delete(name);
1240
+ const shouldWriteArtifacts = removed || removedNames.length > 0;
1241
+ options.deferOrSchedule("typed", shouldWriteArtifacts);
1242
+ options.deferOrSchedule("html", shouldWriteArtifacts);
1243
+ options.deferOrSchedule("vue", shouldWriteArtifacts);
1244
+ },
1245
+ setSupportFileResolverComponents,
1246
+ clearSupportFileResolverComponents,
1247
+ async syncSupportFileResolverComponents() {
1248
+ try {
1249
+ setSupportFileResolverComponents(options.resolverHelpers.collectStaticResolverComponentsForSupportFiles());
1250
+ await awaitOutputWrites();
1251
+ } finally {
1252
+ clearSupportFileResolverComponents();
1253
+ }
1254
+ },
1255
+ collectStaticResolverComponentsForSupportFiles() {
1256
+ return options.resolverHelpers.collectStaticResolverComponentsForSupportFiles();
1257
+ },
1258
+ resolve(componentName, importerBaseName) {
1259
+ const local = options.registry.get(componentName) ?? options.normalizedLocalComponents.get(toKebabCaseComponentName(componentName));
1260
+ if (local) return local;
1261
+ const resolvedValue = options.resolverHelpers.resolveWithResolvers(componentName, importerBaseName);
1262
+ if (!resolvedValue) return;
1263
+ const resolverChanged = options.resolvedResolverComponents.get(resolvedValue.name) !== resolvedValue.from;
1264
+ options.resolvedResolverComponents.set(resolvedValue.name, resolvedValue.from);
1265
+ if (resolverChanged) bumpVersion();
1266
+ const resolved = {
1267
+ kind: "resolver",
1268
+ value: resolvedValue
1269
+ };
1270
+ const { typed, html, vue } = options.getOutputSettingsSnapshot();
1271
+ if (typed.enabled || html.enabled) {
1272
+ const metadataMissing = !options.componentMetadataMap.has(resolved.value.name);
1273
+ if (metadataMissing) options.componentMetadataMap.set(resolved.value.name, {
1274
+ types: /* @__PURE__ */ new Map(),
1275
+ docs: /* @__PURE__ */ new Map()
1276
+ });
1277
+ if (typed.enabled && (resolverChanged || metadataMissing)) options.deferOrSchedule("typed", true);
1278
+ if (html.enabled && (resolverChanged || metadataMissing)) options.deferOrSchedule("html", true);
1279
+ } else options.componentMetadataMap.delete(resolved.value.name);
1280
+ if (vue.enabled && resolverChanged) options.deferOrSchedule("vue", true);
1281
+ if (resolverChanged) options.deferOrSchedule("manifest", true);
1282
+ return resolved;
1283
+ },
1284
+ filter(id) {
1285
+ const globMatcher = options.registryHelpers.ensureMatcher();
1286
+ if (!globMatcher) return false;
1287
+ return globMatcher(id);
1288
+ },
1289
+ getRegisteredLocalComponents() {
1290
+ return Array.from(options.registry.values());
1291
+ },
1292
+ hasPendingRegistrations() {
1293
+ return options.pendingRegistrations.size > 0;
1294
+ },
1295
+ awaitPendingRegistrations() {
1296
+ return Promise.all([...options.pendingRegistrations]).then(() => {});
1297
+ },
1298
+ awaitManifestWrites() {
1299
+ return awaitOutputWrites();
1300
+ }
1301
+ };
1302
+ }
1303
+ //#endregion
1304
+ //#region src/ast/index.ts
1305
+ /**
1306
+ * 解析 AST 引擎配置。
1307
+ */
1308
+ function resolveAstEngine(config) {
1309
+ return config?.ast?.engine ?? "babel";
1310
+ }
1311
+ //#endregion
1312
+ //#region src/context/shared.ts
1313
+ const debug$2 = createDebugger("weapp-vite:context");
1314
+ function hasOwn$6(source, key) {
1315
+ return Object.prototype.hasOwnProperty.call(source, key);
1316
+ }
1317
+ function resolvedComponentName(entry) {
1318
+ const base = path.basename(entry);
1319
+ if (base === "index") {
1320
+ const dirName = path.dirname(entry);
1321
+ if (dirName === ".") return { base };
1322
+ return {
1323
+ componentName: path.basename(dirName),
1324
+ base
1325
+ };
1326
+ }
1327
+ return {
1328
+ componentName: base,
1329
+ base
1330
+ };
1331
+ }
1332
+ function isEmptyObject$1(obj) {
1333
+ for (const key in obj) if (hasOwn$6(obj, key)) return false;
1334
+ return true;
1335
+ }
1336
+ //#endregion
1201
1337
  //#region src/runtime/componentProps.ts
1202
1338
  /**
1203
1339
  * 提取组件 `properties/props` 的静态类型信息。
@@ -1911,7 +2047,7 @@ function createHtmlCustomDataDefinition(componentNames, getMetadata, baseTags =
1911
2047
  if (attributes.length) tag.attributes = attributes;
1912
2048
  tag.references = [{
1913
2049
  name: "weapp-vite 自动导入组件",
1914
- url: "https://vite.icebreaker.top/guide/auto-import-components.html"
2050
+ url: "https://vite.weapp.dev/guide/auto-import-components.html"
1915
2051
  }];
1916
2052
  return tag;
1917
2053
  }))
@@ -5129,141 +5265,6 @@ async function resolveEntryPath(input, options) {
5129
5265
  for (const candidate of buildCandidates(base, extensions)) if (await exists(candidate)) return candidate;
5130
5266
  }
5131
5267
  //#endregion
5132
- //#region src/utils/json.ts
5133
- const ALIPAY_GENERIC_COMPONENT_PLACEHOLDER = "./__weapp_vite_generic_component";
5134
- const WEAPP_SCOPED_SLOT_GENERIC_COMPONENT_PLACEHOLDER = "./__weapp_vite_scoped_slot_generic_component";
5135
- const JSON_FILE_JS_EXTENSION_RE = /\.[jt]s$/;
5136
- const COMPONENT_NAME_LOWER_TO_UPPER_RE = /([a-z0-9])([A-Z])/g;
5137
- const COMPONENT_NAME_MULTI_UPPER_RE = /([A-Z]+)([A-Z][a-z])/g;
5138
- const COMPONENT_NAME_HAS_UPPER_RE = /[A-Z]/;
5139
- const SCOPED_SLOT_GENERIC_KEY_RE$1 = /^scoped-slots-/;
5140
- function parseCommentJson(json) {
5141
- return parse$2(json, void 0, true);
5142
- }
5143
- function jsonFileRemoveJsExtension(fileName) {
5144
- return fileName.replace(JSON_FILE_JS_EXTENSION_RE, "");
5145
- }
5146
- function stringifyJson$1(value, replacer) {
5147
- return stringify(value, replacer, 2);
5148
- }
5149
- function normalizeAppJson(json) {
5150
- if (!json || typeof json !== "object" || Array.isArray(json)) return json;
5151
- const subPackages = Array.isArray(json.subPackages) ? json.subPackages : Array.isArray(json.subpackages) ? json.subpackages : [];
5152
- const { subpackages: _subpackages, ...rest } = json;
5153
- return {
5154
- ...rest,
5155
- subPackages: subPackages.map((subPackage) => ({
5156
- ...subPackage,
5157
- pages: Array.isArray(subPackage?.pages) ? subPackage.pages : []
5158
- }))
5159
- };
5160
- }
5161
- function matches(pattern, importee) {
5162
- if (pattern instanceof RegExp) return pattern.test(importee);
5163
- if (importee.length < pattern.length) return false;
5164
- if (importee === pattern) return true;
5165
- return importee.startsWith(pattern + "/");
5166
- }
5167
- function getAliasEntries(options = {}) {
5168
- if (options === false) return [];
5169
- const { entries } = options;
5170
- if (!entries) return [];
5171
- if (Array.isArray(entries)) return entries.map((entry) => {
5172
- return {
5173
- find: entry.find,
5174
- replacement: entry.replacement
5175
- };
5176
- });
5177
- return Object.entries(entries).map(([key, value]) => {
5178
- return {
5179
- find: key,
5180
- replacement: value
5181
- };
5182
- });
5183
- }
5184
- function resolveImportee$1(importee, jsonPath, aliasEntries) {
5185
- if (Array.isArray(aliasEntries)) {
5186
- if (!jsonPath) return importee;
5187
- const matchedEntry = aliasEntries.find((x) => matches(x.find, importee));
5188
- if (!matchedEntry) return importee;
5189
- const updatedId = importee.replace(matchedEntry.find, matchedEntry.replacement);
5190
- return toPosixPath(path.relative(path.dirname(jsonPath), updatedId));
5191
- }
5192
- return importee;
5193
- }
5194
- function toKebabCaseComponentName(name) {
5195
- return name.replace(COMPONENT_NAME_LOWER_TO_UPPER_RE, "$1-$2").replace(COMPONENT_NAME_MULTI_UPPER_RE, "$1-$2").toLowerCase();
5196
- }
5197
- function normalizeUsingComponentPathByPlatform(importee, platform, dependencies, mode) {
5198
- if (!hasNpmDependencyPrefix(dependencies, importee) && !importee.trim().startsWith("/")) return importee;
5199
- return normalizeNpmImportPathByPlatform(importee, {
5200
- platform,
5201
- dependencies,
5202
- alipayNpmMode: mode
5203
- });
5204
- }
5205
- function normalizeUsingComponentsByPlatform(usingComponents, platform, options) {
5206
- if (!shouldNormalizeUsingComponents(platform)) return usingComponents;
5207
- const normalized = {};
5208
- for (const [key, value] of Object.entries(usingComponents)) {
5209
- const nextKey = COMPONENT_NAME_HAS_UPPER_RE.test(key) ? toKebabCaseComponentName(key) : key;
5210
- const nextValue = normalizeUsingComponentPathByPlatform(value, platform, options?.dependencies, options?.alipayNpmMode);
5211
- if (!Reflect.has(normalized, nextKey)) normalized[nextKey] = nextValue;
5212
- }
5213
- return normalized;
5214
- }
5215
- function normalizeComponentGenericsByPlatform(componentGenerics, platform) {
5216
- if (!shouldFillComponentGenericsDefault(platform) && platform !== "weapp") return componentGenerics;
5217
- const normalized = {};
5218
- for (const [key, value] of Object.entries(componentGenerics)) {
5219
- const placeholder = platform === "weapp" ? SCOPED_SLOT_GENERIC_KEY_RE$1.test(key) ? WEAPP_SCOPED_SLOT_GENERIC_COMPONENT_PLACEHOLDER : void 0 : ALIPAY_GENERIC_COMPONENT_PLACEHOLDER;
5220
- if (!placeholder) {
5221
- normalized[key] = value;
5222
- continue;
5223
- }
5224
- if (value === true) {
5225
- normalized[key] = { default: placeholder };
5226
- continue;
5227
- }
5228
- if (isObject(value)) {
5229
- const nextValue = { ...value };
5230
- if (typeof nextValue.default !== "string" || !nextValue.default.trim()) nextValue.default = placeholder;
5231
- normalized[key] = nextValue;
5232
- continue;
5233
- }
5234
- normalized[key] = value;
5235
- }
5236
- return normalized;
5237
- }
5238
- function resolveJson(entry, aliasEntries, platform, options) {
5239
- if (entry.json) {
5240
- const json = entry.type === "app" ? normalizeAppJson(structuredClone(entry.json)) : structuredClone(entry.json);
5241
- if (entry.jsonPath && Array.isArray(aliasEntries)) {
5242
- const usingComponents = get(json, "usingComponents");
5243
- if (isObject(usingComponents)) {
5244
- for (const [key, importee] of Object.entries(usingComponents)) {
5245
- const resolvedId = resolveImportee$1(importee, entry.jsonPath, aliasEntries);
5246
- set(json, `usingComponents.${key}`, resolvedId);
5247
- }
5248
- set(json, "usingComponents", normalizeUsingComponentsByPlatform(usingComponents, platform, options));
5249
- }
5250
- if (entry.type === "app") for (const field of ["subPackages", "subpackages"]) {
5251
- const subPackages = get(json, field);
5252
- if (Array.isArray(subPackages)) {
5253
- for (const subPackage of subPackages) if (subPackage.entry) subPackage.entry = changeFileExtension(subPackage.entry, "js");
5254
- }
5255
- }
5256
- } else {
5257
- const usingComponents = get(json, "usingComponents");
5258
- if (isObject(usingComponents)) set(json, "usingComponents", normalizeUsingComponentsByPlatform(usingComponents, platform, options));
5259
- }
5260
- const componentGenerics = get(json, "componentGenerics");
5261
- if (isObject(componentGenerics)) set(json, "componentGenerics", normalizeComponentGenericsByPlatform(componentGenerics, platform));
5262
- if (Reflect.has(json, "$schema")) delete json.$schema;
5263
- return stringifyJson$1(json);
5264
- }
5265
- }
5266
- //#endregion
5267
5268
  //#region src/utils/loadViteConfigFile.ts
5268
5269
  const DEFAULT_VITE_CONFIG_FILES = [
5269
5270
  "vite.config.ts",
@@ -5889,6 +5890,33 @@ async function resolveWeappConfigFile(options) {
5889
5890
  //#endregion
5890
5891
  //#region src/runtime/autoImport/service/registry.ts
5891
5892
  const JSON_LIKE_FILE_RE = /\.(?:json|jsonc|json5)$/i;
5893
+ function rebuildNormalizedLocalComponents(registry, normalizedLocalComponents) {
5894
+ normalizedLocalComponents.clear();
5895
+ const ambiguousNames = /* @__PURE__ */ new Set();
5896
+ for (const [componentName, match] of registry) {
5897
+ const normalizedName = toKebabCaseComponentName(componentName);
5898
+ if (ambiguousNames.has(normalizedName)) continue;
5899
+ if (normalizedLocalComponents.has(normalizedName)) {
5900
+ normalizedLocalComponents.delete(normalizedName);
5901
+ ambiguousNames.add(normalizedName);
5902
+ continue;
5903
+ }
5904
+ normalizedLocalComponents.set(normalizedName, match);
5905
+ }
5906
+ }
5907
+ function refreshNormalizedLocalComponent(registry, normalizedLocalComponents, normalizedName) {
5908
+ let normalizedMatch;
5909
+ for (const [componentName, match] of registry) {
5910
+ if (toKebabCaseComponentName(componentName) !== normalizedName) continue;
5911
+ if (normalizedMatch) {
5912
+ normalizedLocalComponents.delete(normalizedName);
5913
+ return;
5914
+ }
5915
+ normalizedMatch = match;
5916
+ }
5917
+ if (normalizedMatch) normalizedLocalComponents.set(normalizedName, normalizedMatch);
5918
+ else normalizedLocalComponents.delete(normalizedName);
5919
+ }
5892
5920
  function createRegistryHelpers(state) {
5893
5921
  function scheduleOutputs(shouldWrite, vueEnabled) {
5894
5922
  state.scheduleManifestWrite(shouldWrite);
@@ -5903,6 +5931,7 @@ function createRegistryHelpers(state) {
5903
5931
  const { baseName, templatePath, jsEntry, jsonPath } = paths;
5904
5932
  let removed = false;
5905
5933
  const removedNames = [];
5934
+ const removedNormalizedNames = /* @__PURE__ */ new Set();
5906
5935
  for (const [key, value] of state.registry) {
5907
5936
  if (value.kind !== "local") continue;
5908
5937
  const entry = value.entry;
@@ -5910,9 +5939,11 @@ function createRegistryHelpers(state) {
5910
5939
  if (state.registry.delete(key)) {
5911
5940
  removed = true;
5912
5941
  removedNames.push(key);
5942
+ removedNormalizedNames.add(toKebabCaseComponentName(key));
5913
5943
  }
5914
5944
  }
5915
5945
  }
5946
+ for (const normalizedName of removedNormalizedNames) refreshNormalizedLocalComponent(state.registry, state.normalizedLocalComponents, normalizedName);
5916
5947
  return {
5917
5948
  removed,
5918
5949
  removedNames
@@ -5984,7 +6015,7 @@ function createRegistryHelpers(state) {
5984
6015
  }
5985
6016
  const sourceWithoutExt = removeExtensionDeep(resolvedJsonPath);
5986
6017
  const from = `/${state.ctx.configService.relativeSrcRoot(state.ctx.configService.relativeCwd(sourceWithoutExt))}`;
5987
- state.registry.set(componentName, {
6018
+ const match = {
5988
6019
  kind: "local",
5989
6020
  entry: {
5990
6021
  path: resolvedJsEntry,
@@ -5998,7 +6029,9 @@ function createRegistryHelpers(state) {
5998
6029
  from,
5999
6030
  resolvedId: resolvedJsEntry
6000
6031
  }
6001
- });
6032
+ };
6033
+ state.registry.set(componentName, match);
6034
+ refreshNormalizedLocalComponent(state.registry, state.normalizedLocalComponents, toKebabCaseComponentName(componentName));
6002
6035
  state.scheduleManifestWrite(true);
6003
6036
  const typedSettings = getTypedComponentsSettings(state.ctx);
6004
6037
  const htmlSettings = getHtmlCustomDataSettings(state.ctx);
@@ -6383,6 +6416,8 @@ function logWarnOnce(message) {
6383
6416
  function createAutoImportService(ctx) {
6384
6417
  const autoImportState = ctx.runtimeState.autoImport;
6385
6418
  const registry = autoImportState.registry;
6419
+ const normalizedLocalComponents = autoImportState.normalizedLocalComponents;
6420
+ rebuildNormalizedLocalComponents(registry, normalizedLocalComponents);
6386
6421
  const resolvedResolverComponents = autoImportState.resolvedResolverComponents;
6387
6422
  const manifestFileName = DEFAULT_AUTO_IMPORT_MANIFEST_FILENAME;
6388
6423
  const manifestCache = /* @__PURE__ */ new Map();
@@ -6455,6 +6490,7 @@ function createAutoImportService(ctx) {
6455
6490
  return {
6456
6491
  ...createAutoImportActions({
6457
6492
  registry,
6493
+ normalizedLocalComponents,
6458
6494
  autoImportState,
6459
6495
  resolvedResolverComponents,
6460
6496
  componentMetadataMap,
@@ -6463,6 +6499,7 @@ function createAutoImportService(ctx) {
6463
6499
  registryHelpers: createRegistryHelpers({
6464
6500
  ctx,
6465
6501
  registry,
6502
+ normalizedLocalComponents,
6466
6503
  autoImportState,
6467
6504
  resolverComponentNames,
6468
6505
  componentMetadataMap,
@@ -9291,6 +9328,7 @@ function createRuntimeState() {
9291
9328
  },
9292
9329
  autoImport: {
9293
9330
  registry: /* @__PURE__ */ new Map(),
9331
+ normalizedLocalComponents: /* @__PURE__ */ new Map(),
9294
9332
  resolvedResolverComponents: /* @__PURE__ */ new Map(),
9295
9333
  matcherKey: "",
9296
9334
  preparedGlobsKey: void 0,
@@ -9317,9 +9355,7 @@ function createRuntimeState() {
9317
9355
  externalComponentEntryMap: /* @__PURE__ */ new Map(),
9318
9356
  entriesMap: /* @__PURE__ */ new Map(),
9319
9357
  vueEntryHasTemplate: /* @__PURE__ */ new Map(),
9320
- vueEntryNonJsonSignatures: /* @__PURE__ */ new Map(),
9321
- vueEntryScriptSignatures: /* @__PURE__ */ new Map(),
9322
- vueEntryStyleIndependentSignatures: /* @__PURE__ */ new Map(),
9358
+ vueEntrySfcSignatures: /* @__PURE__ */ new Map(),
9323
9359
  vueEntryTailwindContentSignatures: /* @__PURE__ */ new Map(),
9324
9360
  vueEntryTailwindTemplateContentSignatures: /* @__PURE__ */ new Map(),
9325
9361
  vueEntryTailwindScriptContentSignatures: /* @__PURE__ */ new Map(),
@@ -9409,6 +9445,7 @@ function resetRuntimeStateForFreshBuild(runtimeState) {
9409
9445
  autoRoutes.loadingAppConfig = fresh.autoRoutes.loadingAppConfig;
9410
9446
  const autoImport = runtimeState.autoImport;
9411
9447
  autoImport.registry.clear();
9448
+ autoImport.normalizedLocalComponents.clear();
9412
9449
  autoImport.resolvedResolverComponents.clear();
9413
9450
  autoImport.matcher = void 0;
9414
9451
  autoImport.matcherKey = fresh.autoImport.matcherKey;
@@ -12226,7 +12263,7 @@ function collectNativeBridgeContext(ast) {
12226
12263
  };
12227
12264
  }
12228
12265
  function hasNativeComponentBridge(source) {
12229
- return collectNativeBridgeContext(parse(source, BABEL_TS_MODULE_PARSER_OPTIONS)).nativeComponentTags.size > 0;
12266
+ return collectNativeBridgeContext(parse$2(source, BABEL_TS_MODULE_PARSER_OPTIONS)).nativeComponentTags.size > 0;
12230
12267
  }
12231
12268
  function findFunctionDeclaration(ast, componentName) {
12232
12269
  for (const statement of ast.program.body) {
@@ -12247,7 +12284,7 @@ function findFirstFunctionDeclaration(ast) {
12247
12284
  }
12248
12285
  }
12249
12286
  function compileStaticReactPage(source, filename, componentName) {
12250
- const ast = parse(source, BABEL_TS_MODULE_PARSER_OPTIONS);
12287
+ const ast = parse$2(source, BABEL_TS_MODULE_PARSER_OPTIONS);
12251
12288
  const bridgeContext = collectNativeBridgeContext(ast);
12252
12289
  try {
12253
12290
  const component = componentName ? findFunctionDeclaration(ast, componentName) : findFirstFunctionDeclaration(ast);
@@ -12508,10 +12545,13 @@ function createStatefulHmrSidecarPlugin() {
12508
12545
  name: "weapp-vite:stateful-hmr-sidecar",
12509
12546
  enforce: "pre",
12510
12547
  async load(id) {
12548
+ if (id.includes("\0")) return;
12511
12549
  const request = parseSidecarSourceRequest(id);
12512
- if (!request || request.kind === "style") return;
12550
+ if (!request) return;
12513
12551
  this.addWatchFile(request.sourceId);
12514
- const code = createStatefulHmrSidecarModuleCode(id, await readFile(request.sourceId, "utf8"));
12552
+ const source = await readFile(request.sourceId, "utf8");
12553
+ if (request.kind === "style") return source;
12554
+ const code = createStatefulHmrSidecarModuleCode(id, source);
12515
12555
  return code ? {
12516
12556
  code,
12517
12557
  moduleSideEffects: "no-treeshake"
@@ -12916,20 +12956,45 @@ function createId() {
12916
12956
  //#endregion
12917
12957
  //#region src/runtime/statefulHmr/viteAdapter.ts
12918
12958
  const clientId = "weapp-vite-stateful-hmr";
12959
+ const initialBuildTimeoutMs = 6e4;
12960
+ const require = createRequire(import.meta.url);
12961
+ function resolveViteDevEngine() {
12962
+ try {
12963
+ const vitePackagePath = require.resolve("vite/package.json");
12964
+ const viteRolldown = createRequire(vitePackagePath)("rolldown/experimental");
12965
+ if (typeof viteRolldown.dev === "function") return viteRolldown.dev;
12966
+ } catch {}
12967
+ return dev;
12968
+ }
12969
+ async function withInitialBuildTimeout(task, timeoutMs = initialBuildTimeoutMs) {
12970
+ let timeout;
12971
+ try {
12972
+ return await Promise.race([task, new Promise((_resolve, reject) => {
12973
+ timeout = setTimeout(() => {
12974
+ reject(/* @__PURE__ */ new Error(`stateful-experimental HMR 初始构建超时(>${timeoutMs}ms)。`));
12975
+ }, timeoutMs);
12976
+ })]);
12977
+ } finally {
12978
+ if (timeout) clearTimeout(timeout);
12979
+ }
12980
+ }
12919
12981
  var StatefulHmrViteAdapter = class {
12920
12982
  config;
12921
12983
  server;
12922
12984
  callbacks;
12923
12985
  watchOptions;
12924
12986
  createDevEngine;
12987
+ initialBuildTimeout;
12925
12988
  bundledDev;
12926
12989
  initialOutputError;
12927
- constructor(config, server, callbacks, watchOptions = {}, createDevEngine = dev) {
12990
+ initialRuntimeValidated = false;
12991
+ constructor(config, server, callbacks, watchOptions = {}, createDevEngine = resolveViteDevEngine(), initialBuildTimeout = initialBuildTimeoutMs) {
12928
12992
  this.config = config;
12929
12993
  this.server = server;
12930
12994
  this.callbacks = callbacks;
12931
12995
  this.watchOptions = watchOptions;
12932
12996
  this.createDevEngine = createDevEngine;
12997
+ this.initialBuildTimeout = initialBuildTimeout;
12933
12998
  }
12934
12999
  install() {
12935
13000
  const bundledDev = this.server.environments.client.bundledDev;
@@ -13016,7 +13081,10 @@ var StatefulHmrViteAdapter = class {
13016
13081
  const original = bundledDev.storeOutputFiles.bind(bundledDev);
13017
13082
  bundledDev.storeOutputFiles = (output) => {
13018
13083
  try {
13019
- if (output.some((item) => item.fileName === "app.js")) assertStatefulHmrRuntimeOutput(output);
13084
+ if (!this.initialRuntimeValidated && output.some((item) => item.fileName === "app.js")) {
13085
+ assertStatefulHmrRuntimeOutput(output);
13086
+ this.initialRuntimeValidated = true;
13087
+ }
13020
13088
  original(output);
13021
13089
  this.callbacks.onOutput(output);
13022
13090
  } catch (error) {
@@ -13052,10 +13120,10 @@ var StatefulHmrViteAdapter = class {
13052
13120
  this.callbacks.onError(message);
13053
13121
  });
13054
13122
  await engine.registerClient(clientId);
13055
- await engine.ensureCurrentBuildFinish();
13123
+ await withInitialBuildTimeout(engine.ensureCurrentBuildFinish(), this.initialBuildTimeout);
13056
13124
  if (this.initialOutputError) throw this.initialOutputError;
13057
13125
  if ((await engine.getBundleState()).lastBuildErrored) throw new Error("微信状态保持 HMR 初次构建失败。");
13058
- await this.callbacks.waitForInitialBundle();
13126
+ await withInitialBuildTimeout(this.callbacks.waitForInitialBundle(), this.initialBuildTimeout);
13059
13127
  };
13060
13128
  }
13061
13129
  handleHmrUpdates(result) {
@@ -13271,13 +13339,16 @@ var StatefulHmrSession = class {
13271
13339
  }
13272
13340
  handlePatch(files, output) {
13273
13341
  if (output.type === "Noop") return false;
13274
- if (!isSafeJavaScriptPatch(files, output, this.ctx.runtimeState.build.hmr.profile.dirtyReasonSummary, this.entryIds, this.server.config.root)) {
13342
+ const dirtyReasonSummary = this.ctx.runtimeState.build.hmr.profile.dirtyReasonSummary ?? [];
13343
+ const allowTailwindContentPatch = dirtyReasonSummary.some((reason) => reason.startsWith("tailwind-content:"));
13344
+ if (!isSafeJavaScriptPatch(files, output, dirtyReasonSummary, this.entryIds, this.server.config.root, { allowTailwindContent: allowTailwindContentPatch })) {
13275
13345
  if (shouldRestartStatefulHmrServer(files, this.ctx.configService?.configFileDependencies)) this.requestServerRestart();
13276
13346
  else if (this.snapshotScheduler.isPending() || files.length > 0 && files.every(isStatefulHmrAssetFile) || shouldUseStatefulHmrSnapshotOnly(this.ctx.runtimeState.build.hmr.profile.dirtyReasonSummary ?? [])) {
13277
13347
  if (!this.snapshotScheduler.isPending()) this.requestSnapshotRefresh(files);
13278
13348
  } else this.requestFullBuild(files);
13279
13349
  return false;
13280
13350
  }
13351
+ if (allowTailwindContentPatch) this.requestSnapshotRefresh(files);
13281
13352
  this.adapter.registerPatchModules(output.code).then(async () => {
13282
13353
  const code = await transformJavaScript(output.code, output.filename);
13283
13354
  if (shouldResetStatefulHmrRetention(this.transport.retainedDeltaCount, this.transport.retainedDeltaBytes, Buffer.byteLength(code))) {
@@ -13402,20 +13473,21 @@ function redirectNativeComponentRegistration(code) {
13402
13473
  } });
13403
13474
  return changed ? magicString.toString() : code;
13404
13475
  }
13405
- function isSafeJavaScriptPatch(files, output, dirtyReasonSummary = [], entryIds, root) {
13476
+ function isSafeJavaScriptPatch(files, output, dirtyReasonSummary = [], entryIds, root, options = {}) {
13406
13477
  const normalizedEntryIds = entryIds ? new Set(Array.from(entryIds, (entryId) => normalizeFsResolvedId(entryId))) : void 0;
13407
13478
  return output.type === "Patch" && files.every((file) => /\.(?:[cm]?[jt]sx?|vue)$/.test(file)) && (!normalizedEntryIds || files.every((file) => {
13408
13479
  const absoluteFile = path.isAbsolute(file) || !root ? file : path.resolve(root, file);
13409
13480
  return normalizedEntryIds.has(normalizeFsResolvedId(absoluteFile));
13410
- })) && !output.changedIds?.some(isNonJavaScriptSidecarId) && !dirtyReasonSummary.some(isUnsafeStatefulHmrReason);
13481
+ })) && !output.changedIds?.some(isNonJavaScriptSidecarId) && !dirtyReasonSummary.some((reason) => isUnsafeStatefulHmrReason(reason, options.allowTailwindContent === true));
13411
13482
  }
13412
13483
  function requiresStatefulHmrSnapshot(file, dirtyReasonSummary = []) {
13413
- return /\.(?:jsx|tsx)$/.test(file) || !/\.(?:[cm]?[jt]sx?|vue)$/.test(file) || dirtyReasonSummary.some(isUnsafeStatefulHmrReason);
13484
+ return /\.(?:jsx|tsx)$/.test(file) || !/\.(?:[cm]?[jt]sx?|vue)$/.test(file) || dirtyReasonSummary.some((reason) => isUnsafeStatefulHmrReason(reason));
13414
13485
  }
13415
13486
  function isStatefulHmrAssetFile(file) {
13416
13487
  return !/\.(?:[cm]?[jt]sx?|vue)$/.test(file);
13417
13488
  }
13418
- function isUnsafeStatefulHmrReason(reason) {
13489
+ function isUnsafeStatefulHmrReason(reason, allowTailwindContent = false) {
13490
+ if (allowTailwindContent && reason.startsWith("tailwind-content:")) return false;
13419
13491
  return /^(?:entry-json-only|entry-local-asset|entry-style-only|react-template|tailwind-content):/.test(reason);
13420
13492
  }
13421
13493
  function shouldUseStatefulHmrSnapshotOnly(dirtyReasonSummary) {
@@ -13591,6 +13663,11 @@ async function runAutoImportBatch(autoImportService, task) {
13591
13663
  if (typeof autoImportService?.runInBatch === "function") return await autoImportService.runInBatch(task);
13592
13664
  return await task();
13593
13665
  }
13666
+ function findMatchingComponentName(components, componentName) {
13667
+ if (hasOwn$4(components, componentName)) return componentName;
13668
+ const normalizedComponentName = toKebabCaseComponentName(componentName);
13669
+ for (const candidateName in components) if (hasOwn$4(components, candidateName) && toKebabCaseComponentName(candidateName) === normalizedComponentName) return candidateName;
13670
+ }
13594
13671
  async function refreshAutoImportImporters(ctx, filePath) {
13595
13672
  const { wxmlService, configService, autoImportService } = ctx;
13596
13673
  if (!wxmlService || !configService) return;
@@ -13599,9 +13676,10 @@ async function refreshAutoImportImporters(ctx, filePath) {
13599
13676
  const touchedImporters = /* @__PURE__ */ new Set();
13600
13677
  const entries = Array.from(wxmlService.wxmlComponentsMap.entries());
13601
13678
  for (const [baseName, components] of entries) {
13602
- if (!hasOwn$4(components, componentName)) continue;
13679
+ const matchingComponentName = findMatchingComponentName(components, componentName);
13680
+ if (!matchingComponentName) continue;
13603
13681
  const pendingEntriesByImporter = ctx.runtimeState?.autoImport?.pendingEntriesByImporter;
13604
- const pendingEntry = (autoImportService?.resolve(componentName, baseName))?.value.from;
13682
+ const pendingEntry = (autoImportService?.resolve(matchingComponentName, baseName))?.value.from;
13605
13683
  if (pendingEntriesByImporter && pendingEntry) {
13606
13684
  const pendingEntries = pendingEntriesByImporter.get(baseName) ?? /* @__PURE__ */ new Set();
13607
13685
  pendingEntries.add(pendingEntry);
@@ -14887,7 +14965,7 @@ const TRAILING_SLASH_PATTERN = /\/+$/;
14887
14965
  function hasDependency(packageJson, name) {
14888
14966
  return Boolean(packageJson?.dependencies?.[name] || packageJson?.devDependencies?.[name] || packageJson?.peerDependencies?.[name]);
14889
14967
  }
14890
- function unique(values) {
14968
+ function unique$1(values) {
14891
14969
  return [...new Set(values)];
14892
14970
  }
14893
14971
  function rebaseManagedPathValue(root, managedDir, value) {
@@ -14918,7 +14996,7 @@ function getManagedTypeScriptConfig(ctx) {
14918
14996
  async function readLegacyManagedTsconfigFile(filePath) {
14919
14997
  try {
14920
14998
  const content = await fs$1.readFile(filePath, "utf8");
14921
- const parsed = parse$2(content, void 0, true);
14999
+ const parsed = parse(content, void 0, true);
14922
15000
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return;
14923
15001
  return parsed;
14924
15002
  } catch {
@@ -14964,7 +15042,7 @@ function getAppTypes(ctx, legacyConfig) {
14964
15042
  if (config.web && config.web.enable !== false) types.push("vite/client");
14965
15043
  if (Array.isArray(legacyTypes) && legacyTypes.length > 0) types.push(...legacyTypes);
14966
15044
  if (Array.isArray(userTypes) && userTypes.length > 0) types.push(...userTypes);
14967
- return unique(types);
15045
+ return unique$1(types);
14968
15046
  }
14969
15047
  function getAppPaths(ctx, legacyConfig) {
14970
15048
  const configService = requireConfigService(ctx, "生成 app paths 前必须初始化 configService。");
@@ -15025,13 +15103,13 @@ function createAppTsconfig(ctx, legacyConfig) {
15025
15103
  ...legacyConfig?.app?.vueCompilerOptions ?? {},
15026
15104
  ...userConfig?.app?.vueCompilerOptions ?? {}
15027
15105
  };
15028
- const include = unique([
15106
+ const include = unique$1([
15029
15107
  ...createDefaultAppInclude(requireConfigService(ctx, "生成 app include 前必须初始化 configService。").srcRoot),
15030
15108
  ...legacyConfig?.app?.include ?? [],
15031
15109
  ...userConfig?.app?.include ?? []
15032
15110
  ]);
15033
- const exclude = unique([...legacyConfig?.app?.exclude ?? [], ...userConfig?.app?.exclude ?? []]);
15034
- const files = unique([...legacyConfig?.app?.files ?? [], ...userConfig?.app?.files ?? []]);
15111
+ const exclude = unique$1([...legacyConfig?.app?.exclude ?? [], ...userConfig?.app?.exclude ?? []]);
15112
+ const files = unique$1([...legacyConfig?.app?.files ?? [], ...userConfig?.app?.files ?? []]);
15035
15113
  return {
15036
15114
  extends: "./tsconfig.shared.json",
15037
15115
  compilerOptions,
@@ -15051,13 +15129,13 @@ function createNodeTsconfig(ctx, legacyConfig) {
15051
15129
  ...omitDeprecatedCompilerOptions(legacyConfig?.node?.compilerOptions) ?? {},
15052
15130
  ...omitDeprecatedCompilerOptions(userConfig?.node?.compilerOptions) ?? {}
15053
15131
  };
15054
- const include = unique([
15132
+ const include = unique$1([
15055
15133
  ...DEFAULT_NODE_INCLUDE,
15056
15134
  ...legacyConfig?.node?.include ?? [],
15057
15135
  ...userConfig?.node?.include ?? []
15058
15136
  ]);
15059
- const exclude = unique([...legacyConfig?.node?.exclude ?? [], ...userConfig?.node?.exclude ?? []]);
15060
- const files = unique([...legacyConfig?.node?.files ?? [], ...userConfig?.node?.files ?? []]);
15137
+ const exclude = unique$1([...legacyConfig?.node?.exclude ?? [], ...userConfig?.node?.exclude ?? []]);
15138
+ const files = unique$1([...legacyConfig?.node?.files ?? [], ...userConfig?.node?.files ?? []]);
15061
15139
  return {
15062
15140
  extends: "./tsconfig.shared.json",
15063
15141
  compilerOptions,
@@ -15076,9 +15154,9 @@ function createServerTsconfig(ctx, legacyConfig) {
15076
15154
  ...omitDeprecatedCompilerOptions(legacyConfig?.server?.compilerOptions) ?? {},
15077
15155
  ...omitDeprecatedCompilerOptions(userConfig?.server?.compilerOptions) ?? {}
15078
15156
  };
15079
- const files = unique([...legacyConfig?.server?.files ?? [], ...userConfig?.server?.files ?? []]);
15080
- const include = unique([...legacyConfig?.server?.include ?? [], ...userConfig?.server?.include ?? []]);
15081
- const exclude = unique([...legacyConfig?.server?.exclude ?? [], ...userConfig?.server?.exclude ?? []]);
15157
+ const files = unique$1([...legacyConfig?.server?.files ?? [], ...userConfig?.server?.files ?? []]);
15158
+ const include = unique$1([...legacyConfig?.server?.include ?? [], ...userConfig?.server?.include ?? []]);
15159
+ const exclude = unique$1([...legacyConfig?.server?.exclude ?? [], ...userConfig?.server?.exclude ?? []]);
15082
15160
  return {
15083
15161
  extends: "./tsconfig.shared.json",
15084
15162
  compilerOptions,
@@ -15158,7 +15236,7 @@ async function readTsconfigData(filePath) {
15158
15236
  const content = await fs$1.readFile(filePath, "utf8").catch(() => void 0);
15159
15237
  if (!content) return;
15160
15238
  try {
15161
- const parsed = parse$2(content, void 0, true);
15239
+ const parsed = parse(content, void 0, true);
15162
15240
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
15163
15241
  } catch {
15164
15242
  return;
@@ -15243,7 +15321,7 @@ async function syncManagedTsconfigBootstrapFiles(cwd) {
15243
15321
  function parseJsonObject(content) {
15244
15322
  if (!content) return;
15245
15323
  try {
15246
- const parsed = parse$2(content, void 0, true);
15324
+ const parsed = parse(content, void 0, true);
15247
15325
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
15248
15326
  } catch {
15249
15327
  return;
@@ -15781,6 +15859,19 @@ function toStatefulHmrOutput(output) {
15781
15859
  if (!Array.isArray(output) && !("output" in output)) throw new TypeError("stateful HMR snapshot build unexpectedly returned a watcher");
15782
15860
  return (Array.isArray(output) ? output : [output]).flatMap((result) => result.output);
15783
15861
  }
15862
+ function collectStatefulHmrEntryIds(initialEntryIds, snapshot, cwd, srcRoot) {
15863
+ const entryIds = new Set(Array.from(initialEntryIds, (id) => normalizeFsResolvedId(id)));
15864
+ const normalizedSrcRoot = normalizeFsResolvedId(srcRoot).replace(/\/$/, "");
15865
+ for (const item of snapshot) {
15866
+ if (item.type !== "chunk") continue;
15867
+ for (const moduleId of Object.keys(item.modules ?? {})) {
15868
+ const sourceId = moduleId.split("?")[0];
15869
+ const normalizedId = normalizeFsResolvedId(path.isAbsolute(sourceId) ? sourceId : path.resolve(cwd, sourceId));
15870
+ if (normalizedId.startsWith(`${normalizedSrcRoot}/`) && /\.(?:[cm]?[jt]sx?|vue)$/.test(normalizedId)) entryIds.add(normalizedId);
15871
+ }
15872
+ }
15873
+ return entryIds;
15874
+ }
15784
15875
  function resolveSnapshotSidecarDirtySummary(filePath, affectedEntries) {
15785
15876
  const normalizedFile = normalizeFsResolvedId(filePath);
15786
15877
  if (configSuffixes.find((suffix) => normalizedFile.endsWith(suffix))) return "json-sidecar:1";
@@ -16546,7 +16637,7 @@ function createBuildService(ctx) {
16546
16637
  }
16547
16638
  };
16548
16639
  const initialSnapshot = toStatefulHmrOutput(await build(snapshotBuildOptions));
16549
- const initialEntryIds = new Set(ctx.runtimeState.build.hmr.resolvedEntryMap.keys());
16640
+ const initialEntryIds = collectStatefulHmrEntryIds(ctx.runtimeState.build.hmr.resolvedEntryMap.keys(), initialSnapshot, configService.cwd, configService.absoluteSrcRoot);
16550
16641
  const skylineFiles = findSkylineRendererFiles(initialSnapshot);
16551
16642
  if (skylineFiles.length > 0) await applySkylineHmrFallback({
16552
16643
  compileHotReLoad,
@@ -18009,7 +18100,7 @@ async function inspectTsconfigPathsState(filePath, visited) {
18009
18100
  }
18010
18101
  let parsed;
18011
18102
  try {
18012
- parsed = parse$2(content);
18103
+ parsed = parse(content);
18013
18104
  } catch {
18014
18105
  return {
18015
18106
  root: false,
@@ -18450,6 +18541,17 @@ function transformTemplateForAlipay(source) {
18450
18541
  return rewriteAlipayReferenceExtensions(normalizeImportSjsAttributes(rewriteTemplateImportExtensionsForAlipay(rewriteAlipayTemplateSyntax(source))));
18451
18542
  }
18452
18543
  //#endregion
18544
+ //#region src/runtime/npmPlugin/builder/jsModule/helpers.ts
18545
+ const ESM_SYNTAX_RE$1 = /\bimport(?=[\s{'"*])|\bexport(?=[\s{*])/;
18546
+ function hasEsmSyntax(source) {
18547
+ return ESM_SYNTAX_RE$1.test(source);
18548
+ }
18549
+ function createExportAllStatements(source, scope) {
18550
+ const requireId = scope.generateUidIdentifier("reExported");
18551
+ const exportKeyId = scope.generateUidIdentifier("exportKey");
18552
+ return [t.variableDeclaration("const", [t.variableDeclarator(requireId, t.callExpression(t.identifier("require"), [source]))]), t.expressionStatement(t.callExpression(t.memberExpression(t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("keys")), [requireId]), t.identifier("forEach")), [t.arrowFunctionExpression([exportKeyId], t.blockStatement([t.ifStatement(t.logicalExpression("||", t.binaryExpression("===", exportKeyId, t.stringLiteral("default")), t.binaryExpression("===", exportKeyId, t.stringLiteral("__esModule"))), t.returnStatement()), t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("exports"), exportKeyId, true), t.memberExpression(requireId, exportKeyId, true)))]))]))];
18553
+ }
18554
+ //#endregion
18453
18555
  //#region src/runtime/npmPlugin/builder/shared.ts
18454
18556
  async function collectFiles(root) {
18455
18557
  const files = [];
@@ -18498,10 +18600,6 @@ async function resolvePreferredPackageEntry(rootPath, pkg) {
18498
18600
  }
18499
18601
  //#endregion
18500
18602
  //#region src/runtime/npmPlugin/builder/jsModule.ts
18501
- const ESM_SYNTAX_RE$1 = /\bimport\s|\bexport\s/;
18502
- function hasEsmSyntax(source) {
18503
- return ESM_SYNTAX_RE$1.test(source);
18504
- }
18505
18603
  function createExportsMember(name) {
18506
18604
  return t.memberExpression(t.identifier("exports"), t.isValidIdentifier(name) ? t.identifier(name) : t.stringLiteral(name), !t.isValidIdentifier(name));
18507
18605
  }
@@ -18615,6 +18713,11 @@ async function transformJsModuleToCjs(source, options) {
18615
18713
  }
18616
18714
  path.replaceWithMultiple(statements);
18617
18715
  transformed = true;
18716
+ },
18717
+ ExportAllDeclaration(path) {
18718
+ hasConvertedExport = true;
18719
+ path.replaceWithMultiple(createExportAllStatements(t.stringLiteral(path.node.source.value), path.scope));
18720
+ transformed = true;
18618
18721
  }
18619
18722
  });
18620
18723
  if (exportAssignments.length > 0) {
@@ -20982,7 +21085,11 @@ function collectAutoImportGlobExtensions(glob) {
20982
21085
  return AUTO_IMPORT_LOCAL_EXTENSIONS.filter((ext) => glob.includes(`.${ext}`));
20983
21086
  }
20984
21087
  function collectLocalCandidatePaths(componentName, globs, absoluteSrcRoot) {
20985
- const names = /* @__PURE__ */ new Set([componentName, toPascalTagName(componentName)]);
21088
+ const names = /* @__PURE__ */ new Set([
21089
+ componentName,
21090
+ toPascalTagName(componentName),
21091
+ toKebabCaseComponentName(componentName)
21092
+ ]);
20986
21093
  const candidates = /* @__PURE__ */ new Set();
20987
21094
  for (const glob of globs) {
20988
21095
  const extensions = collectAutoImportGlobExtensions(glob);
@@ -21197,191 +21304,16 @@ function createJsonEmitManager(configService) {
21197
21304
  };
21198
21305
  }
21199
21306
  //#endregion
21200
- //#region src/utils/file/vueSfcSignatureNative.ts
21201
- const require = createRequire(import.meta.url);
21202
- let binding;
21203
- function resolveNativeAstModulePath() {
21204
- return process.env.WEAPP_VITE_NATIVE_AST_PATH?.trim() || void 0;
21205
- }
21206
- function shouldUseNativeVueSfcSignature() {
21207
- return process.env.WEAPP_VITE_NATIVE === "1" && Boolean(resolveNativeAstModulePath());
21208
- }
21209
- function loadVueSfcSignatureNativeBindingSync() {
21210
- if (!shouldUseNativeVueSfcSignature()) return;
21211
- if (binding !== void 0) return binding || void 0;
21212
- try {
21213
- const modulePath = resolveNativeAstModulePath();
21214
- binding = require(modulePath);
21215
- } catch {
21216
- binding = false;
21217
- }
21218
- return binding || void 0;
21219
- }
21220
- //#endregion
21221
- //#region src/utils/file/vueSfcSignature.ts
21222
- const JSON_MACRO_HINT_RE = /\bdefine(?:App|Page|Component|Sitemap|Theme)Json\s*\(/;
21223
- const JS_STRING_LITERALS_RE = /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`/g;
21224
- const SCRIPT_CALL_EXPRESSION_RE = /\b[$a-z_][\w$]*\s*\((?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|[^()"'`])*\)/gi;
21225
- const CLASS_LIKE_TEMPLATE_ATTR_RE = /(?:^|[\s<])(?:[\w-]*class[\w-]*|v-bind(?::[\w-]*class[\w-]*)?|:[\w-]*class[\w-]*)(?:\.[\w-]+)*\s*=\s*(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|[^\s>]+)/g;
21226
- const VUE_DYNAMIC_CLASS_LIKE_BINDING_RE = /(?:^|[\s<])(?:v-bind(?::[\w-]*class[\w-]*)?|:[\w-]*class[\w-]*)(?:\.[\w-]+)*\s*=/;
21227
- const SCRIPT_DYNAMIC_CLASS_HINT_RE = /\b(?:import|export)\b|\b[$a-z_][\w$]*\s*\(/i;
21228
- const signaturePayloadCache = /* @__PURE__ */ new Map();
21229
- function hashPayload(payload) {
21230
- return createHash("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
21231
- }
21232
- function serializeAttrs(attrs) {
21233
- return Object.fromEntries(Object.entries(attrs).sort(([a], [b]) => a.localeCompare(b)));
21234
- }
21235
- function serializeBlock(block, content) {
21236
- if (!block) return null;
21237
- return {
21238
- type: block.type,
21239
- attrs: serializeAttrs(block.attrs),
21240
- content: content ?? block.content
21241
- };
21242
- }
21243
- function stripJsonMacrosFromScriptContent(content, filename) {
21244
- try {
21245
- return stripJsonMacroCallsFromCode(content, filename);
21246
- } catch {
21247
- return content;
21248
- }
21249
- }
21250
- function buildNonJsonDescriptorPayload(descriptor, filename) {
21251
- const scriptSetupContent = descriptor.scriptSetup ? stripJsonMacrosFromScriptContent(descriptor.scriptSetup.content, filename) : void 0;
21252
- return {
21253
- script: serializeBlock(descriptor.script),
21254
- scriptSetup: serializeBlock(descriptor.scriptSetup, scriptSetupContent),
21255
- template: serializeBlock(descriptor.template),
21256
- styles: descriptor.styles.map((style) => serializeBlock(style)),
21257
- customBlocks: descriptor.customBlocks.filter((block) => block.type !== "json").map((block) => serializeBlock(block))
21258
- };
21259
- }
21260
- function buildScriptDescriptorPayload(descriptor, filename) {
21261
- const scriptSetupContent = descriptor.scriptSetup ? stripJsonMacrosFromScriptContent(descriptor.scriptSetup.content, filename) : void 0;
21262
- return {
21263
- script: serializeBlock(descriptor.script),
21264
- scriptSetup: serializeBlock(descriptor.scriptSetup, scriptSetupContent)
21265
- };
21266
- }
21267
- function buildStyleIndependentDescriptorPayload(descriptor, filename) {
21268
- const scriptSetupContent = descriptor.scriptSetup ? stripJsonMacrosFromScriptContent(descriptor.scriptSetup.content, filename) : void 0;
21269
- return {
21270
- script: serializeBlock(descriptor.script),
21271
- scriptSetup: serializeBlock(descriptor.scriptSetup, scriptSetupContent),
21272
- template: serializeBlock(descriptor.template),
21273
- customBlocks: descriptor.customBlocks.filter((block) => block.type !== "json").map((block) => serializeBlock(block))
21274
- };
21275
- }
21276
- function collectScriptLiteralCandidates(content) {
21277
- const candidates = [];
21278
- for (const match of content.matchAll(JS_STRING_LITERALS_RE)) candidates.push(match[0]);
21279
- return candidates;
21280
- }
21281
- function collectScriptCallLiteralCandidates(content) {
21282
- const candidates = /* @__PURE__ */ new Set();
21283
- for (const callMatch of content.matchAll(SCRIPT_CALL_EXPRESSION_RE)) for (const literalMatch of callMatch[0].matchAll(JS_STRING_LITERALS_RE)) candidates.add(literalMatch[0]);
21284
- return Array.from(candidates).sort();
21285
- }
21286
- function collectTemplateTailwindCandidates(content) {
21287
- const candidates = /* @__PURE__ */ new Set();
21288
- for (const match of content.matchAll(CLASS_LIKE_TEMPLATE_ATTR_RE)) candidates.add(match[0].trim());
21289
- return Array.from(candidates).sort();
21290
- }
21291
- function hasScriptDynamicClassHint(content) {
21292
- return SCRIPT_DYNAMIC_CLASS_HINT_RE.test(content);
21293
- }
21294
- function normalizeTailwindContentPayload(payload) {
21295
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) return payload;
21296
- const content = payload;
21297
- const template = typeof content.template === "string" ? content.template : "";
21298
- const scriptLiterals = VUE_DYNAMIC_CLASS_LIKE_BINDING_RE.test(template) ? content.scriptLiterals : content.hasScriptTailwindClassHint === true ? content.scriptCallLiterals : [];
21299
- return {
21300
- ...content,
21301
- template: collectTemplateTailwindCandidates(template),
21302
- scriptLiterals,
21303
- scriptCallLiterals: []
21304
- };
21305
- }
21306
- function hashTailwindContentPayload(payload) {
21307
- return hashPayload(normalizeTailwindContentPayload(payload));
21308
- }
21309
- function hashTailwindTemplateContentPayload(payload) {
21310
- const normalized = normalizeTailwindContentPayload(payload);
21311
- if (!normalized || typeof normalized !== "object" || Array.isArray(normalized)) return hashPayload(normalized);
21312
- return hashPayload({ template: normalized.template });
21313
- }
21314
- function hashTailwindScriptContentPayload(payload) {
21315
- const normalized = normalizeTailwindContentPayload(payload);
21316
- if (!normalized || typeof normalized !== "object" || Array.isArray(normalized)) return hashPayload(normalized);
21317
- return hashPayload({ scriptLiterals: normalized.scriptLiterals });
21318
- }
21319
- function buildTailwindContentPayload(descriptor, filename) {
21320
- const script = descriptor.script ? stripJsonMacrosFromScriptContent(descriptor.script.content, filename) : "";
21321
- const scriptSetup = descriptor.scriptSetup ? stripJsonMacrosFromScriptContent(descriptor.scriptSetup.content, filename) : "";
21322
- const scriptLiterals = [...collectScriptLiteralCandidates(script), ...collectScriptLiteralCandidates(scriptSetup)];
21323
- const scriptCallLiterals = [...collectScriptCallLiteralCandidates(script), ...collectScriptCallLiteralCandidates(scriptSetup)];
21324
- return {
21325
- template: descriptor.template?.content ?? "",
21326
- scriptLiterals,
21327
- scriptCallLiterals,
21328
- hasScriptTailwindClassHint: hasScriptDynamicClassHint(`${script}\n${scriptSetup}`)
21329
- };
21330
- }
21331
- function buildVueSfcSignaturePayloadWithTs(source, filename) {
21332
- const { descriptor, errors } = parse$1(source, { filename });
21333
- if (errors.length) return;
21334
- return {
21335
- nonJson: buildNonJsonDescriptorPayload(descriptor, filename),
21336
- script: buildScriptDescriptorPayload(descriptor, filename),
21337
- styleIndependent: buildStyleIndependentDescriptorPayload(descriptor, filename),
21338
- tailwindContent: buildTailwindContentPayload(descriptor, filename),
21339
- hasTemplate: Boolean(descriptor.template?.content.trim())
21340
- };
21341
- }
21342
- function buildVueSfcSignaturePayloadWithNative(source) {
21343
- if (JSON_MACRO_HINT_RE.test(source)) return;
21344
- const binding = loadVueSfcSignatureNativeBindingSync();
21345
- if (!binding) return;
21346
- const payload = binding.getVueSfcSignaturePayloadNative(source);
21347
- if (!payload) return;
21348
- try {
21349
- const parsed = JSON.parse(payload);
21350
- const tailwindContent = parsed.tailwindContent;
21351
- if (!tailwindContent || typeof tailwindContent !== "object" || Array.isArray(tailwindContent) || !("hasScriptTailwindClassHint" in tailwindContent) || !("scriptCallLiterals" in tailwindContent)) return;
21352
- return parsed;
21353
- } catch {
21354
- return;
21355
- }
21356
- }
21357
- function buildVueSfcSignaturePayload(source, filename) {
21358
- const cacheKey = `${filename}\0${source}\0${shouldUseNativeVueSfcSignature() ? "native" : "ts"}`;
21359
- if (signaturePayloadCache.has(cacheKey)) return signaturePayloadCache.get(cacheKey);
21360
- const nativePayload = buildVueSfcSignaturePayloadWithNative(source);
21361
- if (nativePayload) {
21362
- signaturePayloadCache.set(cacheKey, nativePayload);
21363
- return nativePayload;
21364
- }
21365
- const tsPayload = buildVueSfcSignaturePayloadWithTs(source, filename);
21366
- signaturePayloadCache.set(cacheKey, tsPayload);
21367
- return tsPayload;
21368
- }
21369
- function resolveVueSfcStyleIndependentSignature(source, filename) {
21370
- const payload = buildVueSfcSignaturePayload(source, filename);
21371
- return payload ? hashPayload(payload.styleIndependent) : void 0;
21372
- }
21373
- function resolveVueSfcHmrSignatures(source, filename) {
21374
- const payload = buildVueSfcSignaturePayload(source, filename);
21375
- if (!payload) return {};
21376
- return {
21377
- nonJsonSignature: hashPayload(payload.nonJson),
21378
- scriptSignature: hashPayload(payload.script),
21379
- styleIndependentSignature: hashPayload(payload.styleIndependent),
21380
- tailwindContentSignature: hashTailwindContentPayload(payload.tailwindContent),
21381
- tailwindTemplateContentSignature: hashTailwindTemplateContentPayload(payload.tailwindContent),
21382
- tailwindScriptContentSignature: hashTailwindScriptContentPayload(payload.tailwindContent),
21383
- hasTemplate: payload.hasTemplate
21384
- };
21307
+ //#region src/runtime/storeVueSfcHmrSignatures.ts
21308
+ /**
21309
+ * 把编译器生成的 SFC 语义快照注册到 Vite HMR 运行状态。
21310
+ */
21311
+ function storeVueSfcHmrSignatures(hmr, filename, signatures) {
21312
+ if (signatures.blockSignatures) hmr.vueEntrySfcSignatures.set(filename, signatures.blockSignatures);
21313
+ if (signatures.tailwindContentSignature) hmr.vueEntryTailwindContentSignatures.set(filename, signatures.tailwindContentSignature);
21314
+ if (signatures.tailwindTemplateContentSignature) hmr.vueEntryTailwindTemplateContentSignatures.set(filename, signatures.tailwindTemplateContentSignature);
21315
+ if (signatures.tailwindScriptContentSignature) hmr.vueEntryTailwindScriptContentSignatures.set(filename, signatures.tailwindScriptContentSignature);
21316
+ if (signatures.hasTemplate !== void 0) hmr.vueEntryHasTemplate.set(filename, signatures.hasTemplate);
21385
21317
  }
21386
21318
  //#endregion
21387
21319
  //#region src/plugins/utils/analyze.ts
@@ -23463,12 +23395,7 @@ function createEntryLoader(options) {
23463
23395
  const signatures = resolveVueSfcHmrSignatures(vueSource, vueEntryPath);
23464
23396
  recordEntryDuration("entryVueSignatureMs", signatureStartedAt);
23465
23397
  appVueNonJsonSignature = signatures.nonJsonSignature;
23466
- if (signatures.nonJsonSignature) ctx.runtimeState.build.hmr.vueEntryNonJsonSignatures.set(normalizedVueEntryPath, signatures.nonJsonSignature);
23467
- if (signatures.scriptSignature) ctx.runtimeState.build.hmr.vueEntryScriptSignatures.set(normalizedVueEntryPath, signatures.scriptSignature);
23468
- if (signatures.tailwindContentSignature) ctx.runtimeState.build.hmr.vueEntryTailwindContentSignatures.set(normalizedVueEntryPath, signatures.tailwindContentSignature);
23469
- if (signatures.tailwindTemplateContentSignature) ctx.runtimeState.build.hmr.vueEntryTailwindTemplateContentSignatures?.set(normalizedVueEntryPath, signatures.tailwindTemplateContentSignature);
23470
- if (signatures.tailwindScriptContentSignature) ctx.runtimeState.build.hmr.vueEntryTailwindScriptContentSignatures?.set(normalizedVueEntryPath, signatures.tailwindScriptContentSignature);
23471
- if (signatures.hasTemplate !== void 0) ctx.runtimeState.build.hmr.vueEntryHasTemplate.set(normalizedVueEntryPath, signatures.hasTemplate);
23398
+ storeVueSfcHmrSignatures(ctx.runtimeState.build.hmr, normalizedVueEntryPath, signatures);
23472
23399
  }
23473
23400
  }
23474
23401
  if (vueEntryPath && ctx.autoRoutesService?.isEnabled?.() && !ctx.runtimeState.autoRoutes.loadingAppConfig) {
@@ -23603,12 +23530,7 @@ function createEntryLoader(options) {
23603
23530
  const signatureStartedAt = performance$1.now();
23604
23531
  const signatures = resolveVueSfcHmrSignatures(vueSource, vueEntryPath);
23605
23532
  recordEntryDuration("entryVueSignatureMs", signatureStartedAt);
23606
- if (signatures.nonJsonSignature) ctx.runtimeState.build.hmr.vueEntryNonJsonSignatures.set(normalizedId, signatures.nonJsonSignature);
23607
- if (signatures.scriptSignature) ctx.runtimeState.build.hmr.vueEntryScriptSignatures.set(normalizedId, signatures.scriptSignature);
23608
- if (signatures.tailwindContentSignature) ctx.runtimeState.build.hmr.vueEntryTailwindContentSignatures.set(normalizedId, signatures.tailwindContentSignature);
23609
- if (signatures.tailwindTemplateContentSignature) ctx.runtimeState.build.hmr.vueEntryTailwindTemplateContentSignatures?.set(normalizedId, signatures.tailwindTemplateContentSignature);
23610
- if (signatures.tailwindScriptContentSignature) ctx.runtimeState.build.hmr.vueEntryTailwindScriptContentSignatures?.set(normalizedId, signatures.tailwindScriptContentSignature);
23611
- if (signatures.hasTemplate !== void 0) ctx.runtimeState.build.hmr.vueEntryHasTemplate.set(normalizedId, signatures.hasTemplate);
23533
+ storeVueSfcHmrSignatures(ctx.runtimeState.build.hmr, normalizedId, signatures);
23612
23534
  }
23613
23535
  }
23614
23536
  const autoImportStartedAt = performance$1.now();
@@ -26113,10 +26035,73 @@ function injectSharedStyleImports(css, modulePath, fileName, sharedStyles, confi
26113
26035
  return prependSharedStyleImports(css, statements);
26114
26036
  }
26115
26037
  //#endregion
26038
+ //#region src/plugins/tailwindcssMarker.ts
26039
+ const MANAGED_TAILWINDCSS_ENTRY_MARKER_PREFIX = ".__weapp_vite_managed_tailwindcss_entry_";
26040
+ const MANAGED_TAILWINDCSS_ENTRY_MARKER_SUFFIX = "__{--weapp-vite-managed-tailwindcss-entry:1}";
26041
+ const MANAGED_TAILWINDCSS_OUTPUT_MARKER_PREFIX = "/*! weapp-vite managed-tailwindcss-output:";
26042
+ const MANAGED_TAILWINDCSS_OUTPUT_MARKER_RE = /\/\*! weapp-vite managed-tailwindcss-output:\d+ \*\/\s*/g;
26043
+ const managedTailwindcssEntries = /* @__PURE__ */ new WeakMap();
26044
+ function normalizeManagedTailwindcssEntryPath(id) {
26045
+ const normalized = normalizeFsResolvedId(id);
26046
+ try {
26047
+ return normalizeFsResolvedId(fs.realpathSync.native(normalized));
26048
+ } catch {
26049
+ return normalized;
26050
+ }
26051
+ }
26052
+ function registerManagedTailwindcssEntries(ctx, entries) {
26053
+ managedTailwindcssEntries.set(ctx, new Set(entries.map(normalizeManagedTailwindcssEntryPath)));
26054
+ }
26055
+ function isManagedTailwindcssEntry(ctx, id) {
26056
+ return managedTailwindcssEntries.get(ctx)?.has(normalizeManagedTailwindcssEntryPath(id)) === true;
26057
+ }
26058
+ function createManagedTailwindcssEntryMarker(index) {
26059
+ return `${MANAGED_TAILWINDCSS_ENTRY_MARKER_PREFIX}${index}${MANAGED_TAILWINDCSS_ENTRY_MARKER_SUFFIX}`;
26060
+ }
26061
+ function findManagedTailwindcssEntryMarker(css) {
26062
+ return css.indexOf(MANAGED_TAILWINDCSS_ENTRY_MARKER_PREFIX);
26063
+ }
26064
+ function createManagedTailwindcssOutputMarker(index) {
26065
+ return `${MANAGED_TAILWINDCSS_OUTPUT_MARKER_PREFIX}${index} */`;
26066
+ }
26067
+ function hasManagedTailwindcssOutputMarker(css) {
26068
+ return css.includes(MANAGED_TAILWINDCSS_OUTPUT_MARKER_PREFIX);
26069
+ }
26070
+ function stripManagedTailwindcssOutputMarkers(css) {
26071
+ return css.replace(MANAGED_TAILWINDCSS_OUTPUT_MARKER_RE, "");
26072
+ }
26073
+ //#endregion
26116
26074
  //#region src/plugins/css.ts
26117
26075
  const LEADING_BLANK_LINES_RE = /^(?:[ \t]*\r?\n)+/;
26118
26076
  const TAILWIND_CONTENT_HMR_NONCE_RE = /\n\/\* weapp-vite tailwind-content [^*\n]+ \*\/$/;
26119
26077
  const VITE_PREPROCESS_STYLE_RE = /\.(?:acss|css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
26078
+ const TAILWIND_GENERATOR_PLACEHOLDER = "/*! weapp-tailwindcss generator-placeholder */";
26079
+ const pendingOwnerStyleSources = /* @__PURE__ */ new WeakMap();
26080
+ function consumePendingOwnerStyleSources(ctx) {
26081
+ const sources = pendingOwnerStyleSources.get(ctx);
26082
+ pendingOwnerStyleSources.delete(ctx);
26083
+ return sources;
26084
+ }
26085
+ function findGeneratorBoundary(css) {
26086
+ const externalIndex = css.indexOf(TAILWIND_GENERATOR_PLACEHOLDER);
26087
+ const managedIndex = findManagedTailwindcssEntryMarker(css);
26088
+ if (externalIndex < 0) return managedIndex;
26089
+ if (managedIndex < 0) return externalIndex;
26090
+ return Math.min(externalIndex, managedIndex);
26091
+ }
26092
+ function extractPendingOwnerStyleSource(css) {
26093
+ const boundary = findGeneratorBoundary(css);
26094
+ return (boundary < 0 ? css : css.slice(0, boundary)).trim();
26095
+ }
26096
+ function recordPendingOwnerStyleSource(ctx, fileName, css) {
26097
+ const authorCss = extractPendingOwnerStyleSource(css);
26098
+ if (!authorCss) return;
26099
+ const sources = pendingOwnerStyleSources.get(ctx) ?? /* @__PURE__ */ new Map();
26100
+ const fragments = sources.get(fileName) ?? [];
26101
+ if (!fragments.includes(authorCss)) fragments.push(authorCss);
26102
+ sources.set(fileName, fragments);
26103
+ pendingOwnerStyleSources.set(ctx, sources);
26104
+ }
26120
26105
  function stripLeadingBlankLines(code) {
26121
26106
  return code.replace(LEADING_BLANK_LINES_RE, "");
26122
26107
  }
@@ -26154,6 +26139,9 @@ function shouldSkipUnchangedStyleHmrBundle(ctx, bundle) {
26154
26139
  function shouldPreprocessWithVite(fileName) {
26155
26140
  return VITE_PREPROCESS_STYLE_RE.test(fileName);
26156
26141
  }
26142
+ function hasViteStyleAssetPlaceholder(source) {
26143
+ return source.includes("__VITE_ASSET__") || source.includes("__VITE_PUBLIC_ASSET__");
26144
+ }
26157
26145
  async function preprocessStyleSource(code, fileName, resolvedConfig, options) {
26158
26146
  const normalizedCss = stripLeadingBlankLines(code);
26159
26147
  if (!resolvedConfig || options?.enabled === false || !shouldPreprocessWithVite(fileName)) return {
@@ -26286,6 +26274,7 @@ async function emitStyleSidecarAsset(ctx, pluginCtx, bundle, stylePath, resolved
26286
26274
  const { configService } = ctx;
26287
26275
  const fileName = resolveOutputStyleFileName(configService, stylePath);
26288
26276
  if (!fileName) return false;
26277
+ if (isManagedTailwindcssEntry(ctx, stylePath)) return false;
26289
26278
  const rawCss = await resolveMemoryStyleSource(ctx, stylePath) ?? await fs$1.readFile(stylePath, "utf8");
26290
26279
  const { css, dependencies } = await preprocessStyleSource(rawCss, stylePath, resolvedConfig);
26291
26280
  syncCssImportDependencies(ctx, stylePath, rawCss, dependencies);
@@ -26310,31 +26299,46 @@ async function handleBundleEntry(ctx, bundle, bundleKey, asset, configService, s
26310
26299
  let cached = preparedStyleAssets.get(cacheKey);
26311
26300
  if (!cached) {
26312
26301
  cached = (async () => {
26313
- const { css, dependencies } = await preprocessStyleSource(rawCss, preprocessId, resolvedConfig, { enabled: shouldPreprocess });
26314
- syncCssImportDependencies(ctx, preprocessId, await readStyleGraphSource(preprocessId, rawCss), dependencies);
26302
+ const graphSource = await readStyleGraphSource(preprocessId, rawCss);
26303
+ const { css, dependencies } = await preprocessStyleSource(shouldPreprocess && hasViteStyleAssetPlaceholder(rawCss) ? graphSource : rawCss, preprocessId, resolvedConfig, { enabled: shouldPreprocess });
26304
+ syncCssImportDependencies(ctx, preprocessId, graphSource, dependencies);
26315
26305
  if (typeof this.addWatchFile === "function") for (const dependency of dependencies) this.addWatchFile(normalizeWatchPath(dependency));
26316
- return { processedCss: await processCssWithCache(css, configService) };
26306
+ return { processedCss: stripManagedTailwindcssOutputMarkers(await processCssWithCache(css, configService)) };
26317
26307
  })();
26318
26308
  preparedStyleAssets.set(cacheKey, cached);
26319
26309
  }
26320
26310
  return cached;
26321
26311
  };
26322
- const emitStyleAssetForOwner = async (owner, preprocessId, shouldPreprocess) => {
26312
+ const prepareOwnedStyleAsset = async (owner, preprocessId, shouldPreprocess) => {
26323
26313
  const fileName = resolveOutputStyleFileName(configService, owner);
26324
26314
  if (!fileName) return;
26325
- const normalizedFileName = toPosixPath(fileName);
26326
26315
  const rawCss = asset.source.toString();
26327
26316
  const { processedCss } = await prepareStyleAssetForOwner(rawCss, preprocessId, shouldPreprocess);
26328
- const cssWithImports = injectSharedStyleImportsCached(processedCss, owner, fileName, sharedStyles, configService, sharedStyleImportCache);
26329
- emitCssAssetIfChanged(ctx, this, bundle, fileName, cssWithImports);
26330
- emitted.add(normalizedFileName);
26331
- return normalizedFileName;
26317
+ return {
26318
+ fileName,
26319
+ modulePath: owner,
26320
+ normalizedFileName: toPosixPath(fileName),
26321
+ processedCss
26322
+ };
26323
+ };
26324
+ const emitStyleAssetForOwner = async (owner, preprocessId, shouldPreprocess) => {
26325
+ const prepared = await prepareOwnedStyleAsset(owner, preprocessId, shouldPreprocess);
26326
+ if (!prepared) return;
26327
+ const cssWithImports = injectSharedStyleImportsCached(prepared.processedCss, prepared.modulePath, prepared.fileName, sharedStyles, configService, sharedStyleImportCache);
26328
+ emitCssAssetIfChanged(ctx, this, bundle, prepared.fileName, cssWithImports);
26329
+ emitted.add(prepared.normalizedFileName);
26330
+ return prepared.normalizedFileName;
26332
26331
  };
26333
26332
  const isCssAsset = bundleKey.endsWith(".css");
26334
26333
  const isFinalStyleAsset = bundleKey.endsWith(`.${configService.outputExtensions.wxss}`) && (!isCssAsset || path.posix.basename(bundleKey, ".css") === "app");
26335
26334
  const isSourceStyleAssetKey = isSourceStyleAsset(bundleKey);
26335
+ const originalStylePath = resolveOriginalStylePath();
26336
+ if (isManagedTailwindcssEntry(ctx, originalStylePath) && !hasManagedTailwindcssOutputMarker(asset.source.toString())) {
26337
+ delete bundle[bundleKey];
26338
+ return;
26339
+ }
26336
26340
  if (isFinalStyleAsset) {
26337
- const absOriginal = resolveOriginalStylePath();
26341
+ const absOriginal = originalStylePath;
26338
26342
  const fileName = resolveOutputStyleFileName(configService, absOriginal);
26339
26343
  if (fileName) emitted.add(toPosixPath(fileName));
26340
26344
  if (fileName) {
@@ -26343,11 +26347,13 @@ async function handleBundleEntry(ctx, bundle, bundleKey, asset, configService, s
26343
26347
  const normalizedFileName = toPosixPath(fileName);
26344
26348
  const freshHmrStyleSourcePath = resolveFreshHmrStyleSourcePath(ctx, normalizedFileName);
26345
26349
  const preprocessId = freshHmrStyleSourcePath ?? absOriginal;
26346
- const preprocessInput = freshHmrStyleSourcePath ? await resolveMemoryStyleSource(ctx, freshHmrStyleSourcePath) ?? await readStyleGraphSource(freshHmrStyleSourcePath, canonicalSource) : canonicalSource;
26347
- const { css, dependencies } = await preprocessStyleSource(preprocessInput, preprocessId, resolvedConfig, { enabled: shouldPreprocessWithVite(preprocessId) });
26348
- syncCssImportDependencies(ctx, preprocessId, freshHmrStyleSourcePath ? preprocessInput : await readStyleGraphSource(absOriginal, canonicalSource), dependencies);
26350
+ const shouldPreprocess = shouldPreprocessWithVite(preprocessId);
26351
+ const graphSource = await readStyleGraphSource(preprocessId, canonicalSource);
26352
+ const preprocessInput = freshHmrStyleSourcePath ? await resolveMemoryStyleSource(ctx, freshHmrStyleSourcePath) ?? graphSource : shouldPreprocess && hasViteStyleAssetPlaceholder(canonicalSource) ? graphSource : canonicalSource;
26353
+ const { css, dependencies } = await preprocessStyleSource(preprocessInput, preprocessId, resolvedConfig, { enabled: shouldPreprocess });
26354
+ syncCssImportDependencies(ctx, preprocessId, freshHmrStyleSourcePath ? preprocessInput : graphSource, dependencies);
26349
26355
  if (typeof this.addWatchFile === "function") for (const dependency of dependencies) this.addWatchFile(normalizeWatchPath(dependency));
26350
- const processedCss = await processCssWithCache(css, configService);
26356
+ const processedCss = stripManagedTailwindcssOutputMarkers(await processCssWithCache(css, configService));
26351
26357
  if (fileName !== bundleKey) {
26352
26358
  delete bundle[bundleKey];
26353
26359
  emitCssAssetIfChanged(ctx, this, bundle, fileName, processedCss);
@@ -26371,11 +26377,12 @@ async function handleBundleEntry(ctx, bundle, bundleKey, asset, configService, s
26371
26377
  delete bundle[bundleKey];
26372
26378
  return;
26373
26379
  }
26374
- const emittedOwners = await Promise.all(Array.from(owners).map(async (owner) => {
26375
- return await emitStyleAssetForOwner(owner, resolveOriginalStylePath(), !isCssAsset);
26376
- }));
26380
+ const preparedOwners = (await Promise.all(Array.from(owners).map(async (owner) => {
26381
+ return await prepareOwnedStyleAsset(owner, resolveOriginalStylePath(), !isCssAsset);
26382
+ }))).filter((prepared) => prepared !== void 0);
26377
26383
  const normalizedBundleKey = toPosixPath(bundleKey);
26378
- if (!isCssAsset || !emittedOwners.includes(normalizedBundleKey)) delete bundle[bundleKey];
26384
+ if (!isCssAsset || !preparedOwners.some((prepared) => prepared.normalizedFileName === normalizedBundleKey)) delete bundle[bundleKey];
26385
+ return preparedOwners;
26379
26386
  }
26380
26387
  async function emitSharedStyleEntries(ctx, sharedStyles, emitted, configService, bundle, resolvedConfig) {
26381
26388
  if (!sharedStyles.size) return;
@@ -26456,6 +26463,7 @@ async function emitSharedStyleImportsForChunks(ctx, sharedStyles, emitted, confi
26456
26463
  }
26457
26464
  }
26458
26465
  async function generateBundleSharedCss(ctx, configService, bundle, analysis, resolvedConfig) {
26466
+ pendingOwnerStyleSources.delete(ctx);
26459
26467
  const sharedStyles = collectSharedStyleEntries(ctx, configService);
26460
26468
  const { facadeChunks, ownersByCssAsset, styleAssets } = analysis;
26461
26469
  if (!sharedStyles.size && !styleAssets.length) return;
@@ -26464,7 +26472,29 @@ async function generateBundleSharedCss(ctx, configService, bundle, analysis, res
26464
26472
  const tasks = styleAssets.map(({ bundleKey, asset }) => {
26465
26473
  return handleBundleEntry.call(this, ctx, bundle, bundleKey, asset, configService, sharedStyles, ownersByCssAsset, emitted, sharedStyleImportCache, resolvedConfig);
26466
26474
  });
26467
- await Promise.all(tasks);
26475
+ const preparedOwnerStyles = (await Promise.all(tasks)).flatMap((result) => result ?? []);
26476
+ const ownerStyleGroups = /* @__PURE__ */ new Map();
26477
+ for (const prepared of preparedOwnerStyles) {
26478
+ let group = ownerStyleGroups.get(prepared.normalizedFileName);
26479
+ if (!group) {
26480
+ group = {
26481
+ fileName: prepared.fileName,
26482
+ fragments: [],
26483
+ modulePath: prepared.modulePath
26484
+ };
26485
+ ownerStyleGroups.set(prepared.normalizedFileName, group);
26486
+ }
26487
+ group.fragments.push(prepared.processedCss);
26488
+ }
26489
+ for (const [normalizedFileName, group] of ownerStyleGroups) {
26490
+ const cssWithImports = injectSharedStyleImportsCached(group.fragments.join("\n"), group.modulePath, group.fileName, sharedStyles, configService, sharedStyleImportCache);
26491
+ if (group.fragments.some((fragment) => findGeneratorBoundary(fragment) >= 0)) {
26492
+ const ownerCssWithImports = injectSharedStyleImportsCached(group.fragments.map(extractPendingOwnerStyleSource).filter(Boolean).join("\n"), group.modulePath, group.fileName, sharedStyles, configService, sharedStyleImportCache);
26493
+ recordPendingOwnerStyleSource(ctx, group.fileName, ownerCssWithImports);
26494
+ }
26495
+ emitCssAssetIfChanged(ctx, this, bundle, group.fileName, cssWithImports);
26496
+ emitted.add(normalizedFileName);
26497
+ }
26468
26498
  await emitSharedStyleEntries.call(this, ctx, sharedStyles, emitted, configService, bundle, resolvedConfig);
26469
26499
  await emitSharedStyleImportsForChunks.call(this, ctx, sharedStyles, emitted, configService, bundle, facadeChunks, sharedStyleImportCache);
26470
26500
  }
@@ -26484,13 +26514,13 @@ function css(ctx) {
26484
26514
  configResolved(config) {
26485
26515
  resolvedConfig = config;
26486
26516
  },
26487
- async generateBundle(_opts, bundle) {
26517
+ generateBundle: { async handler(_opts, bundle) {
26488
26518
  const rolldownBundle = bundle;
26489
26519
  if (shouldSkipUnchangedStyleHmrBundle(ctx, rolldownBundle)) return;
26490
26520
  const styleAnalysis = analyzeBundleStyles(rolldownBundle);
26491
26521
  await generateBundleSharedCss.call(this, ctx, configService, bundle, styleAnalysis, resolvedConfig);
26492
26522
  await emitCollectedStyleSidecars.call(this, ctx, rolldownBundle, resolvedConfig);
26493
- }
26523
+ } }
26494
26524
  }, {
26495
26525
  name: "weapp-vite:css-sidecar-source",
26496
26526
  async transform(code, id) {
@@ -26944,8 +26974,7 @@ function toEmittedAsset(output) {
26944
26974
  fileName: output.fileName,
26945
26975
  source: output.source,
26946
26976
  ...name ? { name } : {},
26947
- ...originalFileName ? { originalFileName } : {},
26948
- needsCodeReference: output.needsCodeReference
26977
+ ...originalFileName ? { originalFileName } : {}
26949
26978
  };
26950
26979
  }
26951
26980
  function getBundleOutputs(output) {
@@ -26989,20 +27018,30 @@ const TEMPLATE_STATIC_REWRITE_MARKERS = [
26989
27018
  ];
26990
27019
  const TEMPLATE_DIRECTIVE_PREFIXES = getSupportedMiniProgramDirectivePrefixes();
26991
27020
  const GRAPH_ONLY_OUTPUT_MARKERS = [WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX];
26992
- function parseGraphOnlyAssetOwner(fileName) {
27021
+ function parseGraphOnlyAssetModuleId(fileName) {
26993
27022
  for (const marker of GRAPH_ONLY_OUTPUT_MARKERS) {
26994
27023
  const markerIndex = fileName.indexOf(marker);
26995
27024
  if (markerIndex < 0) continue;
26996
27025
  const request = fileName.slice(markerIndex);
26997
27026
  const extension = path.extname(request);
26998
- const moduleId = `${extension ? request.slice(0, -extension.length) : request}.js`;
26999
- return parseLogicalEntryId(moduleId)?.sourceId ?? parseSidecarModuleId(moduleId)?.ownerId;
27027
+ return `${extension ? request.slice(0, -extension.length) : request}.js`;
27000
27028
  }
27001
27029
  }
27030
+ function parseGraphOnlyAssetOwner(fileName) {
27031
+ const moduleId = parseGraphOnlyAssetModuleId(fileName);
27032
+ return moduleId ? parseLogicalEntryId(moduleId)?.sourceId ?? parseSidecarModuleId(moduleId)?.ownerId : void 0;
27033
+ }
27002
27034
  function normalizeGraphOnlyAssets(ctx, bundle, emitAsset) {
27003
27035
  for (const [bundleFileName, output] of Object.entries(bundle)) {
27004
27036
  if (output?.type !== "asset") continue;
27005
- const ownerId = parseGraphOnlyAssetOwner(output.fileName || bundleFileName);
27037
+ const fileName = output.fileName || bundleFileName;
27038
+ const moduleId = parseGraphOnlyAssetModuleId(fileName);
27039
+ const sidecar = moduleId ? parseSidecarModuleId(moduleId) : void 0;
27040
+ if (sidecar?.kind === "style" && isManagedTailwindcssEntry(ctx, sidecar.sourceId) && !hasManagedTailwindcssOutputMarker(output.source.toString())) {
27041
+ delete bundle[bundleFileName];
27042
+ continue;
27043
+ }
27044
+ const ownerId = parseGraphOnlyAssetOwner(fileName);
27006
27045
  if (!ownerId) continue;
27007
27046
  delete bundle[bundleFileName];
27008
27047
  const outputFileName = ctx.configService.relativeOutputPath(changeFileExtension(ownerId, ctx.configService.outputExtensions.wxss));
@@ -27045,6 +27084,18 @@ function outputSourceToString(output) {
27045
27084
  const source = output.source;
27046
27085
  return typeof source === "string" ? source : Buffer.from(source).toString("base64");
27047
27086
  }
27087
+ function mergePendingOwnerStyleSources(ctx, bundle) {
27088
+ const pending = consumePendingOwnerStyleSources(ctx);
27089
+ if (!pending) return;
27090
+ for (const [fileName, fragments] of pending) {
27091
+ const output = bundle[fileName] ?? Object.values(bundle).find((candidate) => candidate.type === "asset" && candidate.fileName === fileName);
27092
+ if (output?.type !== "asset") continue;
27093
+ const source = output.source.toString();
27094
+ const missing = fragments.filter((fragment) => !source.includes(fragment));
27095
+ if (!missing.length) continue;
27096
+ output.source = `${source.trimEnd()}\n${missing.join("\n")}\n`;
27097
+ }
27098
+ }
27048
27099
  function mayNeedTemplateNormalization(code, platform) {
27049
27100
  let lowerCode;
27050
27101
  const readLowerCode = () => {
@@ -27169,6 +27220,7 @@ function createOutputFinalizerPlugin(ctx, subPackageMeta) {
27169
27220
  order: "post",
27170
27221
  async handler(_options, bundle) {
27171
27222
  const outputBundle = bundle;
27223
+ mergePendingOwnerStyleSources(ctx, outputBundle);
27172
27224
  rewriteWevuInternalRuntimeImports(bundle, wevuRuntimeRewriteOptions);
27173
27225
  stabilizeWevuRuntimeChunkAccess(bundle);
27174
27226
  restoreNativePageLayoutOutputs(ctx, outputBundle);
@@ -29822,6 +29874,7 @@ function createVueEntryUpdateInspector(state, normalizedId, options = {}) {
29822
29874
  const readFile = options.readFile ?? fs$1.readFile;
29823
29875
  let sourcePromise;
29824
29876
  let signatures;
29877
+ let changedBlocks;
29825
29878
  async function loadSource() {
29826
29879
  sourcePromise ??= readFile(normalizedId, "utf-8").catch(() => void 0);
29827
29880
  return await sourcePromise;
@@ -29829,10 +29882,21 @@ function createVueEntryUpdateInspector(state, normalizedId, options = {}) {
29829
29882
  async function resolveSignatures() {
29830
29883
  const source = await loadSource();
29831
29884
  if (source === void 0) return;
29832
- if (!signatures) signatures = resolveVueSfcHmrSignatures(source, normalizedId);
29885
+ signatures ??= resolveVueSfcHmrSignatures(source, normalizedId);
29833
29886
  return signatures;
29834
29887
  }
29888
+ async function resolveChangedBlocks() {
29889
+ if (changedBlocks) return changedBlocks;
29890
+ const previous = state.ctx.runtimeState.build.hmr.vueEntrySfcSignatures.get(normalizedId);
29891
+ const current = (await resolveSignatures())?.blockSignatures;
29892
+ if (!previous || !current) return;
29893
+ changedBlocks = classifyVueSfcBlockChanges(previous, current);
29894
+ return changedBlocks;
29895
+ }
29835
29896
  return {
29897
+ async getChangedBlocks() {
29898
+ return await resolveChangedBlocks();
29899
+ },
29836
29900
  async isAppShellTopologyUpdate() {
29837
29901
  if (!isAppVueFile(normalizedId)) return false;
29838
29902
  const previous = state.ctx.runtimeState.build.hmr.vueEntryHasTemplate.get(normalizedId);
@@ -29841,19 +29905,16 @@ function createVueEntryUpdateInspector(state, normalizedId, options = {}) {
29841
29905
  return current !== void 0 && current !== previous;
29842
29906
  },
29843
29907
  async isJsonOnlyUpdate() {
29844
- const previous = state.ctx.runtimeState.build.hmr.vueEntryNonJsonSignatures.get(normalizedId);
29845
- if (!previous) return false;
29846
- return (await resolveSignatures())?.nonJsonSignature === previous;
29908
+ const blocks = await resolveChangedBlocks();
29909
+ return blocks?.length === 1 && blocks[0] === "config";
29847
29910
  },
29848
29911
  async isLocalAssetOnlyUpdate() {
29849
- const previous = state.ctx.runtimeState.build.hmr.vueEntryScriptSignatures.get(normalizedId);
29850
- if (!previous) return false;
29851
- return (await resolveSignatures())?.scriptSignature === previous;
29912
+ const blocks = await resolveChangedBlocks();
29913
+ return Boolean(blocks && !blocks.includes("script"));
29852
29914
  },
29853
29915
  async isStyleOnlyUpdate() {
29854
- const previous = state.ctx.runtimeState.build.hmr.vueEntryStyleIndependentSignatures.get(normalizedId);
29855
- if (!previous) return false;
29856
- return (await resolveSignatures())?.styleIndependentSignature === previous;
29916
+ const blocks = await resolveChangedBlocks();
29917
+ return blocks?.length === 1 && blocks[0] === "style";
29857
29918
  },
29858
29919
  async isTailwindContentUpdate() {
29859
29920
  const previousTemplate = state.ctx.runtimeState.build.hmr.vueEntryTailwindTemplateContentSignatures?.get(normalizedId);
@@ -29883,7 +29944,7 @@ const tailwindContentExtensions = /* @__PURE__ */ new Set([
29883
29944
  ".mjs",
29884
29945
  ".cjs"
29885
29946
  ]);
29886
- const TAILWIND_APP_STYLE_RE = /@import\s+['"]tailwindcss['"]|@source\b|weapp-tailwindcss|tailwindcss\/vite/;
29947
+ const TAILWIND_APP_STYLE_RE = /@import\s+['"]tailwindcss['"]|weapp-tailwindcss|tailwindcss\/vite/;
29887
29948
  function resolveWatchPathKind(normalizedId) {
29888
29949
  const extension = path.extname(normalizedId);
29889
29950
  let configSuffix;
@@ -30110,9 +30171,7 @@ async function processChangedFile(state, id, event) {
30110
30171
  };
30111
30172
  if (isDeletedMissingSelf) {
30112
30173
  ctx.runtimeState.build.hmr.vueEntryHasTemplate.delete(normalizedId);
30113
- ctx.runtimeState.build.hmr.vueEntryNonJsonSignatures.delete(normalizedId);
30114
- ctx.runtimeState.build.hmr.vueEntryScriptSignatures.delete(normalizedId);
30115
- ctx.runtimeState.build.hmr.vueEntryStyleIndependentSignatures.delete(normalizedId);
30174
+ ctx.runtimeState.build.hmr.vueEntrySfcSignatures.delete(normalizedId);
30116
30175
  ctx.runtimeState.build.hmr.vueEntryTailwindContentSignatures?.delete(normalizedId);
30117
30176
  ctx.runtimeState.build.hmr.vueEntryTailwindTemplateContentSignatures?.delete(normalizedId);
30118
30177
  ctx.runtimeState.build.hmr.vueEntryTailwindScriptContentSignatures?.delete(normalizedId);
@@ -30542,19 +30601,36 @@ function weappVite(ctx, subPackageMeta) {
30542
30601
  //#region src/plugins/preflight.ts
30543
30602
  const debug = createDebugger("weapp-vite:preflight");
30544
30603
  const removePlugins = ["vite:build-import-analysis", "native:import-analysis-build"];
30604
+ const EXTERNAL_TAILWINDCSS_PLUGIN_PREFIX = "weapp-tailwindcss:";
30605
+ const BUILTIN_TAILWINDCSS_VERSION = "6.24.0";
30545
30606
  function createPluginPruner() {
30607
+ let warnedExternalTailwindcss = false;
30546
30608
  return {
30547
30609
  name: "weapp-vite:preflight",
30548
30610
  enforce: "pre",
30549
30611
  configResolved(config) {
30550
30612
  if (!config.plugins?.length) return;
30551
30613
  for (const removePlugin of removePlugins) {
30552
- const idx = config.plugins.findIndex((plugin) => plugin.name === removePlugin);
30614
+ const plugins = config.plugins;
30615
+ const idx = plugins.findIndex((plugin) => plugin.name === removePlugin);
30553
30616
  if (idx > -1) {
30554
- const [plugin] = config.plugins.splice(idx, 1);
30617
+ const [plugin] = plugins.splice(idx, 1);
30555
30618
  plugin && debug?.("remove plugin", plugin.name);
30556
30619
  }
30557
30620
  }
30621
+ if (config.plugins.filter((plugin) => plugin.name.startsWith(EXTERNAL_TAILWINDCSS_PLUGIN_PREFIX)).length === 0) return;
30622
+ const plugins = config.plugins;
30623
+ for (let index = plugins.length - 1; index >= 0; index--) {
30624
+ const plugin = plugins[index];
30625
+ if (plugin?.name.startsWith(EXTERNAL_TAILWINDCSS_PLUGIN_PREFIX)) {
30626
+ plugins.splice(index, 1);
30627
+ debug?.("remove plugin", plugin.name);
30628
+ }
30629
+ }
30630
+ if (!warnedExternalTailwindcss) {
30631
+ warnedExternalTailwindcss = true;
30632
+ logger_default.warn(`[weapp-vite] 检测到已注册 \`weapp-tailwindcss/vite\` 插件,已由内置集成接管并禁用外部插件。自 weapp-vite@${BUILTIN_TAILWINDCSS_VERSION} 起无需单独安装或注册 weapp-tailwindcss,请删除对应 import 和 plugins 配置。`);
30633
+ }
30558
30634
  }
30559
30635
  };
30560
30636
  }
@@ -30572,6 +30648,364 @@ function preflight(ctx) {
30572
30648
  return [createPluginPruner(), createEnvSynchronizer(ctx)];
30573
30649
  }
30574
30650
  //#endregion
30651
+ //#region src/plugins/tailwindcss.ts
30652
+ const CORE_NODE_RANGE = "^22.18.0 || >=24.11.0";
30653
+ const MANAGED_PLUGIN_NAME = "weapp-vite:tailwindcss";
30654
+ const VIRTUAL_ENTRY_PREFIX = "\0weapp-vite:managed-tailwindcss-entry:";
30655
+ const TAILWIND_IMPORT_RE = /@import\s+(?:url\(\s*)?['"]tailwindcss['"]\s*\)?(?:\s|;|$)/;
30656
+ const TAILWIND_SOURCE_DIRECTIVE_RE = /@(?:config|custom-variant|layer|plugin|reference|source|tailwind|theme|utility|variant)\b/;
30657
+ function unique(values) {
30658
+ return [...new Set(values)];
30659
+ }
30660
+ function resolveCssEntries(ctx, options, basedir) {
30661
+ const entries = unique([
30662
+ ...options.cssEntries ?? [],
30663
+ ...options.tailwindcss?.v4?.cssEntries ?? [],
30664
+ ...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries ?? []
30665
+ ]).map((entry) => path.isAbsolute(entry) ? path.normalize(entry) : path.resolve(basedir, entry));
30666
+ return entries.length > 0 ? entries : [path.resolve(ctx.configService.absoluteSrcRoot, "app.css")];
30667
+ }
30668
+ function resolveManagedTailwindcssOptions(ctx) {
30669
+ const input = ctx.configService.weappViteConfig?.tailwindcss;
30670
+ if (input === void 0) {
30671
+ const version = safeGetPackageInfoSync("tailwindcss", { paths: [ctx.configService.cwd] })?.version;
30672
+ if (!version || Number.parseInt(version.split(".")[0] ?? "", 10) !== 4) return;
30673
+ return {
30674
+ basedir: ctx.configService.cwd,
30675
+ cssEntries: [],
30676
+ generatorTarget: "weapp",
30677
+ autoDetected: true,
30678
+ options: {
30679
+ appType: "weapp-vite",
30680
+ platform: ctx.configService.platform,
30681
+ tailwindcssBasedir: ctx.configService.cwd
30682
+ }
30683
+ };
30684
+ }
30685
+ if (input === false) return;
30686
+ const userOptions = input === true ? {} : input;
30687
+ if (userOptions.disabled === true || typeof userOptions.disabled === "object" && userOptions.disabled.plugin === true) return;
30688
+ const cwd = ctx.configService.cwd;
30689
+ const basedir = userOptions.tailwindcssBasedir ? path.resolve(cwd, userOptions.tailwindcssBasedir) : cwd;
30690
+ const cssEntries = resolveCssEntries(ctx, userOptions, basedir);
30691
+ return {
30692
+ basedir,
30693
+ cssEntries,
30694
+ generatorTarget: typeof userOptions.generator === "object" && userOptions.generator.target ? userOptions.generator.target : "weapp",
30695
+ autoDetected: false,
30696
+ options: {
30697
+ ...userOptions,
30698
+ appType: "weapp-vite",
30699
+ cssEntries,
30700
+ platform: userOptions.platform ?? ctx.configService.platform,
30701
+ tailwindcssBasedir: basedir
30702
+ }
30703
+ };
30704
+ }
30705
+ function outputAssetSource(asset) {
30706
+ return typeof asset.source === "string" ? asset.source : Buffer.from(asset.source).toString("utf8");
30707
+ }
30708
+ function createVirtualEntryId(index, source) {
30709
+ const queryIndex = source.indexOf("?");
30710
+ const query = queryIndex >= 0 ? source.slice(queryIndex) : "";
30711
+ return `${VIRTUAL_ENTRY_PREFIX}${index}.css${query}`;
30712
+ }
30713
+ function parseVirtualEntryIndex(id) {
30714
+ if (!id.startsWith(VIRTUAL_ENTRY_PREFIX)) return;
30715
+ const value = Number.parseInt(id.slice(38), 10);
30716
+ return Number.isInteger(value) ? value : void 0;
30717
+ }
30718
+ function parseManagedEntryIndex(id, entries) {
30719
+ const sourceId = normalizeFsResolvedId(id.split("?")[0], { stripLeadingNullByte: true });
30720
+ return entries.get(normalizeManagedTailwindcssEntryPath(sourceId));
30721
+ }
30722
+ function isVueStyleModuleId(id) {
30723
+ return id.includes("?weapp-vite-vue&type=style&");
30724
+ }
30725
+ function resolveManagedEntryIndex(id, code, entries) {
30726
+ const directIndex = parseManagedEntryIndex(id, entries);
30727
+ if (directIndex !== void 0 || !isVueStyleModuleId(id)) return directIndex;
30728
+ for (const [entry, index] of entries) try {
30729
+ if (fs.readFileSync(entry, "utf8") === code) return index;
30730
+ } catch {}
30731
+ }
30732
+ function createTailwindV4SourceOptions(resolved, entry) {
30733
+ const tailwindcss = resolved.options.tailwindcss;
30734
+ const v4 = tailwindcss?.v4;
30735
+ return {
30736
+ projectRoot: resolved.basedir,
30737
+ cwd: tailwindcss?.cwd,
30738
+ base: v4?.base,
30739
+ cssSources: v4?.cssSources,
30740
+ cssEntries: [entry],
30741
+ packageName: tailwindcss?.packageName ?? "tailwindcss"
30742
+ };
30743
+ }
30744
+ function createCompilerRootId(index, entry) {
30745
+ return `weapp-vite:tailwindcss:${index}:${normalizeManagedTailwindcssEntryPath(entry)}`;
30746
+ }
30747
+ function assertRuntimeRequirements(resolved) {
30748
+ const [major = 0, minor = 0] = process.versions.node.split(".").map(Number);
30749
+ if (!(major === 22 && minor >= 18 || major >= 24 && (major > 24 || minor >= 11))) throw new Error(`weapp.tailwindcss requires Node ${CORE_NODE_RANGE}; current version is ${process.versions.node}.`);
30750
+ for (const entry of resolved.cssEntries) if (!fs.existsSync(entry)) throw new Error(`weapp.tailwindcss CSS entry does not exist: ${entry}`);
30751
+ }
30752
+ function hasTailwindImport(code) {
30753
+ return TAILWIND_IMPORT_RE.test(code);
30754
+ }
30755
+ function createTailwindcssPlugin(ctx) {
30756
+ const managedOptions = resolveManagedTailwindcssOptions(ctx);
30757
+ if (!managedOptions) return [];
30758
+ const resolved = managedOptions;
30759
+ registerManagedTailwindcssEntries(ctx, resolved.cssEntries);
30760
+ const entryIndex = new Map(resolved.cssEntries.map((entry, index) => [normalizeManagedTailwindcssEntryPath(entry), index]));
30761
+ const previousEntrySources = /* @__PURE__ */ new Map();
30762
+ const resolvedEntryIndexes = /* @__PURE__ */ new Set();
30763
+ const loadedEntryIndexes = /* @__PURE__ */ new Set();
30764
+ const previousGeneratedCss = /* @__PURE__ */ new Map();
30765
+ const generatedOutputEntries = /* @__PURE__ */ new Map();
30766
+ const compilerRootIds = /* @__PURE__ */ new Map();
30767
+ const compilerSourceOptions = /* @__PURE__ */ new Map();
30768
+ const compilerSnapshots = /* @__PURE__ */ new Map();
30769
+ let generatedEntriesPromise;
30770
+ let coreModulePromise;
30771
+ let compilerPromise;
30772
+ let resolvedConfig;
30773
+ let loaded = false;
30774
+ let compilerDisposed = false;
30775
+ function resolveAutoEntryIndex(id, code) {
30776
+ if (!resolved.autoDetected || !hasTailwindImport(code)) return;
30777
+ const sourceId = normalizeFsResolvedId(id.split("?")[0], { stripLeadingNullByte: true });
30778
+ if (!sourceId || !/\.(?:css|pcss|postcss|sss|scss|sass|less|styl|stylus)$/.test(sourceId)) return;
30779
+ const normalizedEntry = normalizeManagedTailwindcssEntryPath(sourceId);
30780
+ const existingIndex = entryIndex.get(normalizedEntry);
30781
+ if (existingIndex !== void 0) return existingIndex;
30782
+ const index = resolved.cssEntries.length;
30783
+ resolved.cssEntries.push(sourceId);
30784
+ entryIndex.set(normalizedEntry, index);
30785
+ registerManagedTailwindcssEntries(ctx, resolved.cssEntries);
30786
+ return index;
30787
+ }
30788
+ function getCoreModule() {
30789
+ coreModulePromise ??= import("weapp-tailwindcss/core");
30790
+ return coreModulePromise;
30791
+ }
30792
+ async function getCompiler() {
30793
+ compilerPromise ??= getCoreModule().then(({ createCompiler }) => createCompiler(resolved.options));
30794
+ const compiler = await compilerPromise;
30795
+ if (!loaded) {
30796
+ loaded = true;
30797
+ resolved.options.onLoad?.();
30798
+ }
30799
+ return compiler;
30800
+ }
30801
+ async function stripResidualTailwindSourceDirectives(css) {
30802
+ if (!TAILWIND_SOURCE_DIRECTIVE_RE.test(css)) return css;
30803
+ const { postcss, removeTailwindSourceDirectivesRoot } = await getCoreModule();
30804
+ const root = postcss.parse(css);
30805
+ removeTailwindSourceDirectivesRoot(root);
30806
+ return root.toString();
30807
+ }
30808
+ async function generateEntryCss(compiler, index, entry) {
30809
+ const sourceOptions = compilerSourceOptions.get(index) ?? createTailwindV4SourceOptions(resolved, entry);
30810
+ compilerSourceOptions.set(index, sourceOptions);
30811
+ const id = compilerRootIds.get(index) ?? createCompilerRootId(index, entry);
30812
+ compilerRootIds.set(index, id);
30813
+ const generated = await compiler.generate({
30814
+ id,
30815
+ sourceOptions,
30816
+ target: resolved.generatorTarget,
30817
+ scanSources: true,
30818
+ bareArbitraryValues: resolved.options.arbitraryValues?.bareArbitraryValues,
30819
+ styleOptions: typeof resolved.options.generator === "object" ? resolved.options.generator.styleOptions : void 0
30820
+ });
30821
+ compilerSnapshots.set(index, generated.snapshot);
30822
+ return generated;
30823
+ }
30824
+ async function disposeCompiler() {
30825
+ if (compilerDisposed) return;
30826
+ compilerDisposed = true;
30827
+ await compilerPromise?.then((compiler) => compiler.dispose());
30828
+ }
30829
+ async function invalidateCompilerForFile(id, event) {
30830
+ const compiler = await getCompiler();
30831
+ const normalizedId = normalizeFsResolvedId(id.split("?")[0], { stripLeadingNullByte: true });
30832
+ const index = entryIndex.get(normalizeManagedTailwindcssEntryPath(normalizedId));
30833
+ generatedEntriesPromise = void 0;
30834
+ if (event === "delete" && index !== void 0) {
30835
+ const rootId = compilerRootIds.get(index);
30836
+ if (rootId) await compiler.remove(rootId);
30837
+ compilerSourceOptions.delete(index);
30838
+ return;
30839
+ }
30840
+ compiler.invalidate([normalizedId]);
30841
+ }
30842
+ async function transformBundle(bundle, options = {}) {
30843
+ if (resolved.autoDetected && resolved.cssEntries.length === 0) return;
30844
+ const transformStyles = options.styles !== false;
30845
+ const transformTemplates = options.templates !== false;
30846
+ const compiler = await getCompiler();
30847
+ const generatedEntries = resolved.options.generator === false ? [] : await (generatedEntriesPromise ??= Promise.all(resolved.cssEntries.map((entry, index) => generateEntryCss(compiler, index, entry))));
30848
+ const snapshots = generatedEntries.length > 0 ? generatedEntries.map((generated, index) => compilerSnapshots.get(index) ?? generated.snapshot) : [compiler.createSnapshot({
30849
+ id: `${MANAGED_PLUGIN_NAME}:disabled`,
30850
+ classSet: [],
30851
+ target: resolved.generatorTarget
30852
+ })];
30853
+ const snapshot = compiler.mergeSnapshots(snapshots);
30854
+ const seenEntries = /* @__PURE__ */ new Set();
30855
+ const styleExtension = ctx.configService.outputExtensions.wxss;
30856
+ const templateExtension = ctx.configService.outputExtensions.wxml;
30857
+ const scriptSourceMap = Boolean(resolvedConfig?.build.sourcemap);
30858
+ for (const output of Object.values(bundle)) {
30859
+ if (!transformStyles) break;
30860
+ if (output.type !== "asset") continue;
30861
+ let source = outputAssetSource(output);
30862
+ let hasManagedEntry = false;
30863
+ let isMainChunk = output.fileName === `app.${styleExtension}`;
30864
+ for (let index = 0; index < generatedEntries.length; index++) {
30865
+ const marker = createManagedTailwindcssEntryMarker(index);
30866
+ const outputMarker = createManagedTailwindcssOutputMarker(index);
30867
+ const hasEntryMarker = source.includes(marker);
30868
+ const hasOutputMarker = source.includes(outputMarker);
30869
+ const previousCss = previousGeneratedCss.get(index);
30870
+ const isTrackedOutput = generatedOutputEntries.get(output.fileName)?.has(index) === true;
30871
+ const expectedOutputFile = typeof ctx.configService.relativeOutputPath === "function" ? ctx.configService.relativeOutputPath(changeFileExtension(resolved.cssEntries[index], styleExtension)) : void 0;
30872
+ const isCanonicalOutput = expectedOutputFile !== void 0 && normalizeManagedTailwindcssEntryPath(expectedOutputFile) === normalizeManagedTailwindcssEntryPath(output.fileName);
30873
+ if (!hasEntryMarker && !hasOutputMarker && !isTrackedOutput && !isCanonicalOutput) continue;
30874
+ const generated = generatedEntries[index];
30875
+ hasManagedEntry = true;
30876
+ isMainChunk ||= normalizeManagedTailwindcssEntryPath(resolved.cssEntries[index]) === normalizeManagedTailwindcssEntryPath(path.resolve(ctx.configService.absoluteSrcRoot, "app.css"));
30877
+ seenEntries.add(index);
30878
+ const replacement = `${outputMarker}\n${generated.css}`;
30879
+ if (hasEntryMarker) {
30880
+ const markerIndex = source.indexOf(marker);
30881
+ source = source.slice(0, markerIndex) + replacement + source.slice(markerIndex + marker.length).replaceAll(marker, "");
30882
+ } else if (previousCss !== void 0) source = source.includes(outputMarker) ? source.replace(`${outputMarker}\n${previousCss}`, replacement) : `${replacement}\n${source}`;
30883
+ else if (isCanonicalOutput) source = `${replacement}\n${source}`;
30884
+ else source = source.replace(outputMarker, replacement);
30885
+ previousGeneratedCss.set(index, generated.css);
30886
+ const trackedEntries = generatedOutputEntries.get(output.fileName) ?? /* @__PURE__ */ new Set();
30887
+ trackedEntries.add(index);
30888
+ generatedOutputEntries.set(output.fileName, trackedEntries);
30889
+ for (const dependency of generated.dependencies) this.addWatchFile(dependency);
30890
+ }
30891
+ if (!hasManagedEntry && !output.fileName.endsWith(`.${styleExtension}`)) continue;
30892
+ output.source = stripManagedTailwindcssOutputMarkers(await stripResidualTailwindSourceDirectives((await compiler.transformCss(source, snapshot, { isMainChunk })).css));
30893
+ }
30894
+ if (transformStyles && !ctx.configService.isDev && resolved.options.generator !== false) {
30895
+ const stages = resolved.cssEntries.filter((_entry, index) => resolvedEntryIndexes.has(index) || loadedEntryIndexes.has(index)).filter((entry) => !seenEntries.has(resolved.cssEntries.indexOf(entry))).map((entry) => {
30896
+ const index = resolved.cssEntries.indexOf(entry);
30897
+ return `${entry} (resolved: ${resolvedEntryIndexes.has(index)}, loaded: ${loadedEntryIndexes.has(index)})`;
30898
+ });
30899
+ if (stages.length > 0) throw new Error(`weapp.tailwindcss CSS entries must be imported by the build graph: ${stages.join(", ")}`);
30900
+ }
30901
+ if (!transformTemplates) return;
30902
+ for (const output of Object.values(bundle)) {
30903
+ if (output.type === "asset" && output.fileName.endsWith(`.${templateExtension}`)) {
30904
+ output.source = await compiler.transformTemplate(outputAssetSource(output), snapshot, { filename: output.fileName });
30905
+ continue;
30906
+ }
30907
+ if (output.type !== "chunk" || !output.fileName.endsWith(".js")) continue;
30908
+ const transformed = await compiler.transformJavaScript(output.code, snapshot, {
30909
+ filename: output.fileName,
30910
+ generateMap: scriptSourceMap
30911
+ });
30912
+ if (transformed.error) throw transformed.error;
30913
+ applyOutputChunkTransform(output, transformed.code, transformed.map);
30914
+ }
30915
+ }
30916
+ return [{
30917
+ name: MANAGED_PLUGIN_NAME,
30918
+ enforce: "pre",
30919
+ generateBundle: {
30920
+ order: "pre",
30921
+ async handler(_options, bundle) {
30922
+ generatedEntriesPromise = void 0;
30923
+ resolved.options.onStart?.();
30924
+ try {
30925
+ await transformBundle.call(this, bundle, { templates: false });
30926
+ } finally {
30927
+ resolved.options.onEnd?.();
30928
+ }
30929
+ }
30930
+ },
30931
+ async buildStart() {
30932
+ generatedEntriesPromise = void 0;
30933
+ assertRuntimeRequirements(resolved);
30934
+ if (ctx.configService.isDev) {
30935
+ const pendingChanges = ctx.moduleGraphService?.getPendingChanges?.() ?? [];
30936
+ if (pendingChanges.length > 0) await Promise.all(pendingChanges.map((change) => invalidateCompilerForFile(change.file, change.event)));
30937
+ }
30938
+ resolvedEntryIndexes.clear();
30939
+ loadedEntryIndexes.clear();
30940
+ for (const entry of resolved.cssEntries) this.addWatchFile(entry);
30941
+ },
30942
+ configResolved(config) {
30943
+ resolvedConfig = config;
30944
+ },
30945
+ resolveId(source) {
30946
+ if (resolved.options.generator === false) return null;
30947
+ const sidecar = parseSidecarSourceRequest(source);
30948
+ if (!sidecar || sidecar.kind !== "style") return null;
30949
+ let index = entryIndex.get(normalizeManagedTailwindcssEntryPath(sidecar.sourceId));
30950
+ if (index === void 0 && resolved.autoDetected) try {
30951
+ index = resolveAutoEntryIndex(sidecar.sourceId, fs.readFileSync(sidecar.sourceId, "utf8"));
30952
+ } catch {}
30953
+ if (index === void 0) return null;
30954
+ resolvedEntryIndexes.add(index);
30955
+ return createVirtualEntryId(index, source);
30956
+ },
30957
+ load(id) {
30958
+ if (resolved.options.generator === false) return null;
30959
+ const virtualIndex = parseVirtualEntryIndex(id);
30960
+ const normalizedId = virtualIndex === void 0 ? normalizeFsResolvedId(id.split("?")[0]) : normalizeFsResolvedId(resolved.cssEntries[virtualIndex] ?? "");
30961
+ const index = virtualIndex ?? entryIndex.get(normalizedId);
30962
+ if (index === void 0) return null;
30963
+ loadedEntryIndexes.add(index);
30964
+ const code = fs.readFileSync(normalizedId, "utf8");
30965
+ const previous = previousEntrySources.get(normalizedId);
30966
+ if (previous !== void 0 && previous !== code) resolved.options.onUpdate?.(normalizedId, previous, code);
30967
+ previousEntrySources.set(normalizedId, code);
30968
+ return createManagedTailwindcssEntryMarker(index);
30969
+ },
30970
+ transform(code, id) {
30971
+ if (resolved.options.generator === false) return null;
30972
+ const index = resolveManagedEntryIndex(id, code, entryIndex) ?? resolveAutoEntryIndex(id, code);
30973
+ if (index === void 0) return null;
30974
+ loadedEntryIndexes.add(index);
30975
+ return {
30976
+ code: createManagedTailwindcssEntryMarker(index),
30977
+ map: null
30978
+ };
30979
+ },
30980
+ async watchChange(id, change) {
30981
+ await invalidateCompilerForFile(id, change.event);
30982
+ },
30983
+ async handleHotUpdate({ file }) {
30984
+ await invalidateCompilerForFile(file, "update");
30985
+ },
30986
+ async closeWatcher() {
30987
+ await disposeCompiler();
30988
+ }
30989
+ }, {
30990
+ name: `${MANAGED_PLUGIN_NAME}:output`,
30991
+ enforce: "post",
30992
+ generateBundle: {
30993
+ order: "post",
30994
+ async handler(_options, bundle) {
30995
+ resolved.options.onStart?.();
30996
+ try {
30997
+ await transformBundle.call(this, bundle, { styles: false });
30998
+ } finally {
30999
+ resolved.options.onEnd?.();
31000
+ }
31001
+ }
31002
+ },
31003
+ async closeBundle() {
31004
+ if (!ctx.configService.isDev) await disposeCompiler();
31005
+ }
31006
+ }];
31007
+ }
31008
+ //#endregion
30575
31009
  //#region src/plugins/uniApp.ts
30576
31010
  const SUPPORTED_SOURCE_RE = /(?:\.vue|\.[cm]?[jt]sx?|\.(?:css|less|sass|scss|styl|stylus))(?:\?.*)?$/i;
30577
31011
  function resolveVirtualBlockType(id) {
@@ -32031,14 +32465,7 @@ async function finalizeTransformCompiledResult(options) {
32031
32465
  const normalizedFilename = normalizeFsResolvedId(filename);
32032
32466
  const hmr = ctx.runtimeState?.build?.hmr;
32033
32467
  const signatures = resolveVueSfcHmrSignatures(source, filename);
32034
- if (signatures.nonJsonSignature && hmr?.vueEntryNonJsonSignatures) hmr.vueEntryNonJsonSignatures.set(normalizedFilename, signatures.nonJsonSignature);
32035
- if (signatures.scriptSignature && hmr?.vueEntryScriptSignatures) hmr.vueEntryScriptSignatures.set(normalizedFilename, signatures.scriptSignature);
32036
- if (signatures.tailwindContentSignature && hmr?.vueEntryTailwindContentSignatures) hmr.vueEntryTailwindContentSignatures.set(normalizedFilename, signatures.tailwindContentSignature);
32037
- if (signatures.tailwindTemplateContentSignature && hmr?.vueEntryTailwindTemplateContentSignatures) hmr.vueEntryTailwindTemplateContentSignatures.set(normalizedFilename, signatures.tailwindTemplateContentSignature);
32038
- if (signatures.tailwindScriptContentSignature && hmr?.vueEntryTailwindScriptContentSignatures) hmr.vueEntryTailwindScriptContentSignatures.set(normalizedFilename, signatures.tailwindScriptContentSignature);
32039
- const nextStyleIndependentSignature = styleIndependentSignature ?? signatures.styleIndependentSignature;
32040
- if (nextStyleIndependentSignature && hmr?.vueEntryStyleIndependentSignatures) hmr.vueEntryStyleIndependentSignatures.set(normalizedFilename, nextStyleIndependentSignature);
32041
- if (signatures.hasTemplate !== void 0 && hmr?.vueEntryHasTemplate) hmr.vueEntryHasTemplate.set(normalizedFilename, signatures.hasTemplate);
32468
+ if (hmr) storeVueSfcHmrSignatures(hmr, normalizedFilename, signatures);
32042
32469
  }
32043
32470
  const relativeBase = resolveVueOutputBase(configService, filename);
32044
32471
  if (relativeBase) emitScopedSlotChunks(pluginCtx, relativeBase, result, scopedSlotModules, emittedScopedSlotChunks, configService.outputExtensions);
@@ -32136,6 +32563,8 @@ async function compileVueLikeFile(options) {
32136
32563
  await registerResolvedPageLayoutDependencies(ctx, filename, resolvedLayoutPlan.layouts);
32137
32564
  }
32138
32565
  }
32566
+ const hmr = ctx.runtimeState?.build?.hmr;
32567
+ if (configService.isDev && hmr) storeVueSfcHmrSignatures(hmr, normalizeFsResolvedId(filename), resolveVueSfcHmrSignatures(source, filename));
32139
32568
  return result;
32140
32569
  }
32141
32570
  const result = await compileJsxFile(source, filename, compileOptions);
@@ -32221,7 +32650,7 @@ async function refreshCompiledVueEntryCacheInDev(options) {
32221
32650
  cached.source = source;
32222
32651
  cached.styleIndependentSignature = currentStyleIndependentSignature;
32223
32652
  cached.refreshToken = 0;
32224
- ctx.runtimeState?.build?.hmr?.vueEntryStyleIndependentSignatures?.set(filename, currentStyleIndependentSignature);
32653
+ storeVueSfcHmrSignatures(ctx.runtimeState.build.hmr, filename, resolveVueSfcHmrSignatures(source, filename));
32225
32654
  dirtyVueEntryIds?.delete(dirtyEntryId);
32226
32655
  return cached.result;
32227
32656
  }
@@ -32241,7 +32670,6 @@ async function refreshCompiledVueEntryCacheInDev(options) {
32241
32670
  cached.autoRoutesSignature = transformed.signature;
32242
32671
  cached.styleIndependentSignature = nextStyleIndependentSignature;
32243
32672
  cached.refreshToken = 0;
32244
- if (nextStyleIndependentSignature) ctx.runtimeState?.build?.hmr?.vueEntryStyleIndependentSignatures?.set(filename, nextStyleIndependentSignature);
32245
32673
  if (dirtyEntryId) dirtyVueEntryIds?.delete(dirtyEntryId);
32246
32674
  cached.result = compiled;
32247
32675
  return compiled;
@@ -33714,8 +34142,12 @@ function vitePluginWeapp(ctx, subPackageMeta) {
33714
34142
  if (autoRoutesEnabled && !libModeEnabled) groups.push(autoRoutes(ctx));
33715
34143
  groups.push(autoImport(ctx));
33716
34144
  }
33717
- groups.push(i18n(ctx, subPackageMeta), weappVite(ctx, subPackageMeta), wxs(ctx), css(ctx));
34145
+ const tailwindcssPlugins = createTailwindcssPlugin(ctx);
34146
+ groups.push(i18n(ctx, subPackageMeta), weappVite(ctx, subPackageMeta), wxs(ctx));
34147
+ if (tailwindcssPlugins.length > 0) groups.push([tailwindcssPlugins[0]]);
34148
+ groups.push(css(ctx));
33718
34149
  groups.push([createOutputFinalizerPlugin(ctx, subPackageMeta)]);
34150
+ if (tailwindcssPlugins.length > 1) groups.push([tailwindcssPlugins[1]]);
33719
34151
  const assembled = attachRuntimePlugins(ctx, flatten(groups));
33720
34152
  if (subPackageMeta) return assembled;
33721
34153
  return applyInspect(ctx, assembled);
@@ -33785,7 +34217,7 @@ function createAbsolutePathPattern(value) {
33785
34217
  function hasTsconfigReference(tsconfig, target) {
33786
34218
  if (!existsSync(tsconfig)) return false;
33787
34219
  try {
33788
- const parsed = parse$2(readFileSync(tsconfig, "utf8"), void 0, true);
34220
+ const parsed = parse(readFileSync(tsconfig, "utf8"), void 0, true);
33789
34221
  const references = Array.isArray(parsed.references) ? parsed.references : [];
33790
34222
  const tsconfigDir = path.dirname(tsconfig);
33791
34223
  return references.some((reference) => {
@@ -34738,7 +35170,7 @@ async function loadAppEntry(ctx, scanState) {
34738
35170
  const { path: appEntryPath } = appEntry;
34739
35171
  let configFromVue;
34740
35172
  if (!appConfigFile && vueAppPath) {
34741
- const { extractConfigFromVue } = await import("./file-DWR7zIBT.mjs");
35173
+ const { extractConfigFromVue } = await import("./file-XlRiJP3-.mjs");
34742
35174
  configFromVue = await extractConfigFromVue(vueAppPath);
34743
35175
  if (configFromVue) appConfigFile = vueAppPath;
34744
35176
  }
@@ -35754,4 +36186,4 @@ async function createCompilerContext(options) {
35754
36186
  return ctx;
35755
36187
  }
35756
36188
  //#endregion
35757
- export { getDefaultIdeProjectRoot as A, collectPreloadPages as C, loadViteConfigFile as D, suggestPreloadRules as E, isPathInside as M, parseCommentJson as O, getProjectConfigFileName as S, resolvePreloadPackageIdentifier as T, SHARED_CHUNK_VIRTUAL_PREFIX as _, createGlassEaselAnalyzeResult as a, resolveWeappConfigFile as b, getSupportedWeappVitePlatforms as c, resolveWeappViteTarget as d, getBackendForCapability as f, createSharedBuildConfig as g, syncManagedTsconfigBootstrapFiles as h, setActiveCompilerContextKey as i, shouldPassPlatformArgToIdeOpen as j, createCjsConfigLoadError as k, getSupportedWeappViteTargetDescriptors as l, syncProjectSupportFiles as m, getCompilerContext as n, formatBytes as o, resolveBackendExecution as p, resetCompilerContext as r, WEB_PLATFORM_ALIASES as s, createCompilerContext as t, isWebPlatform as u, resolveHmrProfileJsonPath as v, findPreloadRuleKey as w, checkRuntime as x, getRouteRuntimeGlobalKeys as y };
36189
+ export { getDefaultIdeProjectRoot as A, collectPreloadPages as C, loadViteConfigFile as D, suggestPreloadRules as E, isPathInside as M, createCjsConfigLoadError as O, getProjectConfigFileName as S, resolvePreloadPackageIdentifier as T, SHARED_CHUNK_VIRTUAL_PREFIX as _, createGlassEaselAnalyzeResult as a, resolveWeappConfigFile as b, getSupportedWeappVitePlatforms as c, resolveWeappViteTarget as d, getBackendForCapability as f, createSharedBuildConfig as g, syncManagedTsconfigBootstrapFiles as h, setActiveCompilerContextKey as i, shouldPassPlatformArgToIdeOpen as j, parseCommentJson as k, getSupportedWeappViteTargetDescriptors as l, syncProjectSupportFiles as m, getCompilerContext as n, formatBytes as o, resolveBackendExecution as p, resetCompilerContext as r, WEB_PLATFORM_ALIASES as s, createCompilerContext as t, isWebPlatform as u, resolveHmrProfileJsonPath as v, findPreloadRuleKey as w, checkRuntime as x, getRouteRuntimeGlobalKeys as y };