weapp-vite 6.20.5 → 6.21.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,4 +1,4 @@
1
- import { n as getCompilerContext, v as getRouteRuntimeGlobalKeys } from "./createContext-Ryo4nfbU.mjs";
1
+ import { n as getCompilerContext, v as getRouteRuntimeGlobalKeys } from "./createContext-BE57_Xi7.mjs";
2
2
  //#region src/auto-routes.ts
3
3
  const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
4
4
  function createGetter(resolver) {
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { A as isPathInside, C as findPreloadRuleKey, D as createCjsConfigLoadError, E as parseCommentJson, O as getDefaultIdeProjectRoot, S as collectPreloadPages, T as loadViteConfigFile, _ as resolveHmrProfileJsonPath, a as formatBytes, b as checkRuntime, d as getBackendForCapability, f as resolveBackendExecution, g as SHARED_CHUNK_VIRTUAL_PREFIX, h as createSharedBuildConfig, k as shouldPassPlatformArgToIdeOpen, m as syncManagedTsconfigBootstrapFiles, p as syncProjectSupportFiles, t as createCompilerContext, w as suggestPreloadRules, x as getProjectConfigFileName, y as resolveWeappConfigFile } from "./createContext-Ryo4nfbU.mjs";
1
+ import { A as shouldPassPlatformArgToIdeOpen, C as findPreloadRuleKey, D as parseCommentJson, E as loadViteConfigFile, O as createCjsConfigLoadError, S as collectPreloadPages, T as suggestPreloadRules, _ as resolveHmrProfileJsonPath, a as formatBytes, b as checkRuntime, d as getBackendForCapability, f as resolveBackendExecution, g as SHARED_CHUNK_VIRTUAL_PREFIX, h as createSharedBuildConfig, j as isPathInside, k as getDefaultIdeProjectRoot, m as syncManagedTsconfigBootstrapFiles, p as syncProjectSupportFiles, t as createCompilerContext, w as resolvePreloadPackageIdentifier, x as getProjectConfigFileName, y as resolveWeappConfigFile } from "./createContext-BE57_Xi7.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
3
- import { h as VERSION, i as findJsEntry, o as findTemplateEntry, s as findVueEntry } from "./file-CWbsTVPm.mjs";
3
+ import { h as VERSION, i as findJsEntry, o as findTemplateEntry, s as findVueEntry } from "./file-Byldwig4.mjs";
4
4
  import { c as startWeappViteMcpServer, l as detectAiDevelopmentEnvironment, s as resolveWeappMcpConfig } from "./mcp-BG6TliEg.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import fs from "node:fs";
@@ -1070,7 +1070,83 @@ async function analyzeHmrProfile(options) {
1070
1070
  };
1071
1071
  }
1072
1072
  //#endregion
1073
- //#region src/analyze/preload.ts
1073
+ //#region src/analyze/preload/budget.ts
1074
+ const PRELOAD_LIMIT_BYTES = 2097152;
1075
+ function createPackageSizeMap$1(result) {
1076
+ return new Map((result?.packages ?? []).map((pkg) => [pkg.id, pkg.files.reduce((total, file) => total + (file.size ?? 0), 0)]));
1077
+ }
1078
+ function getConfiguredPackages(rule, appJson) {
1079
+ if (!rule || typeof rule !== "object" || !("packages" in rule)) return [];
1080
+ const packages = rule.packages;
1081
+ if (!Array.isArray(packages)) return [];
1082
+ return packages.flatMap((item) => typeof item === "string" ? [resolvePreloadPackageIdentifier(item, appJson)] : []).filter((item) => Boolean(item));
1083
+ }
1084
+ function createPreloadBudgets(appJson, result, configuredRules, packageAnalysis) {
1085
+ const packageSizes = createPackageSizeMap$1(packageAnalysis);
1086
+ const bySourcePackage = /* @__PURE__ */ new Map();
1087
+ const ensureSourcePackage = (page) => {
1088
+ const sourcePackage = page.packageRoot ?? "__main__";
1089
+ let entry = bySourcePackage.get(sourcePackage);
1090
+ if (!entry) {
1091
+ entry = {
1092
+ sourceType: page.packageRoot ? page.independent ? "independent" : "subpackage" : "main",
1093
+ targets: /* @__PURE__ */ new Map()
1094
+ };
1095
+ bySourcePackage.set(sourcePackage, entry);
1096
+ }
1097
+ return entry;
1098
+ };
1099
+ for (const page of result.pages) {
1100
+ const configuredKey = findPreloadRuleKey(page.route, configuredRules);
1101
+ if (configuredKey === void 0) continue;
1102
+ const entry = ensureSourcePackage(page);
1103
+ for (const packageRoot of getConfiguredPackages(configuredRules[configuredKey], appJson)) {
1104
+ const target = entry.targets.get(packageRoot) ?? {
1105
+ configured: false,
1106
+ suggested: false
1107
+ };
1108
+ target.configured = true;
1109
+ entry.targets.set(packageRoot, target);
1110
+ }
1111
+ }
1112
+ const pageByRoute = new Map(result.pages.map((page) => [page.route, page]));
1113
+ for (const suggestion of result.suggestions) {
1114
+ const page = pageByRoute.get(suggestion.page);
1115
+ if (!page) continue;
1116
+ const entry = ensureSourcePackage(page);
1117
+ const target = entry.targets.get(suggestion.packageRoot) ?? {
1118
+ configured: false,
1119
+ suggested: false
1120
+ };
1121
+ target.suggested = true;
1122
+ entry.targets.set(suggestion.packageRoot, target);
1123
+ }
1124
+ return [...bySourcePackage.entries()].map(([sourcePackage, entry]) => {
1125
+ const targets = [...entry.targets.entries()].map(([packageRoot, state]) => {
1126
+ const packageId = packageRoot === "__APP__" ? "__main__" : packageRoot;
1127
+ return {
1128
+ packageRoot,
1129
+ bytes: packageSizes.get(packageId),
1130
+ ...state
1131
+ };
1132
+ }).sort((left, right) => left.packageRoot.localeCompare(right.packageRoot));
1133
+ const unknownPackages = targets.filter((target) => target.bytes === void 0).map((target) => target.packageRoot);
1134
+ const estimatedBytes = targets.reduce((total, target) => total + (target.bytes ?? 0), 0);
1135
+ const status = estimatedBytes > PRELOAD_LIMIT_BYTES ? "exceeded" : unknownPackages.length > 0 ? "unknown" : "ok";
1136
+ return {
1137
+ sourcePackage,
1138
+ sourceType: entry.sourceType,
1139
+ limitBytes: PRELOAD_LIMIT_BYTES,
1140
+ estimatedBytes,
1141
+ remainingBytes: unknownPackages.length === 0 ? Math.max(0, PRELOAD_LIMIT_BYTES - estimatedBytes) : void 0,
1142
+ status,
1143
+ targets,
1144
+ unknownPackages
1145
+ };
1146
+ }).sort((left, right) => left.sourcePackage.localeCompare(right.sourcePackage));
1147
+ }
1148
+ //#endregion
1149
+ //#region src/analyze/preload/index.ts
1074
1150
  async function readFileIfExists(filePath) {
1075
1151
  if (!filePath) return;
1076
1152
  try {
@@ -1110,7 +1186,7 @@ async function collectPageSources(ctx, route) {
1110
1186
  script
1111
1187
  };
1112
1188
  }
1113
- function aggregateSuggestions(result, configuredRules) {
1189
+ function aggregateSuggestions(result, configuredRules, appJson) {
1114
1190
  const byPage = /* @__PURE__ */ new Map();
1115
1191
  for (const suggestion of result.suggestions) {
1116
1192
  const current = byPage.get(suggestion.page) ?? {
@@ -1128,7 +1204,7 @@ function aggregateSuggestions(result, configuredRules) {
1128
1204
  const configuredKey = findPreloadRuleKey(suggestion.page, configuredRules);
1129
1205
  const existingRule = configuredKey === void 0 ? void 0 : configuredRules[configuredKey];
1130
1206
  const existingPackages = existingRule && typeof existingRule === "object" && "packages" in existingRule ? existingRule.packages : void 0;
1131
- if (Array.isArray(existingPackages) && existingPackages.includes(suggestion.packageRoot)) current.alreadyConfigured.push(suggestion.packageRoot);
1207
+ if ((Array.isArray(existingPackages) ? existingPackages.flatMap((item) => typeof item === "string" ? [resolvePreloadPackageIdentifier(item, appJson)] : []) : []).includes(suggestion.packageRoot)) current.alreadyConfigured.push(suggestion.packageRoot);
1132
1208
  byPage.set(suggestion.page, current);
1133
1209
  }
1134
1210
  return [...byPage.values()].map((suggestion) => ({
@@ -1138,7 +1214,7 @@ function aggregateSuggestions(result, configuredRules) {
1138
1214
  evidence: suggestion.evidence.sort((left, right) => left.target.localeCompare(right.target))
1139
1215
  }));
1140
1216
  }
1141
- async function analyzePreloadRules(ctx, now = /* @__PURE__ */ new Date()) {
1217
+ async function analyzePreloadRules(ctx, options = {}) {
1142
1218
  const appJson = (await ctx.scanService.loadAppEntry()).json;
1143
1219
  const pages = collectPreloadPages(appJson);
1144
1220
  const pageSources = /* @__PURE__ */ new Map();
@@ -1149,15 +1225,17 @@ async function analyzePreloadRules(ctx, now = /* @__PURE__ */ new Date()) {
1149
1225
  return {
1150
1226
  runtime: "mini",
1151
1227
  kind: "preload",
1152
- generatedAt: now.toISOString(),
1228
+ generatedAt: (options.now ?? /* @__PURE__ */ new Date()).toISOString(),
1153
1229
  platform: ctx.configService.platform,
1154
1230
  pages: pages.map((page) => page.route),
1155
1231
  configuredRules,
1156
- suggestions: aggregateSuggestions(suggestions, configuredRules),
1232
+ suggestions: aggregateSuggestions(suggestions, configuredRules, appJson),
1233
+ budgets: createPreloadBudgets(appJson, suggestions, configuredRules, options.packageAnalysis),
1157
1234
  uncoveredPages: suggestions.uncovered,
1158
1235
  limitations: [
1159
1236
  "仅分析静态路由字面量;动态路由、后端配置和运行时守卫不会被推断。",
1160
- "建议使用分包 root 作为 packages 值,正式启用前仍需结合业务访问频率和 2 MB 预下载额度复核。",
1237
+ "建议使用分包 root 作为 packages 值;预算按触发页所属包聚合,未知体积目标仍需人工复核。",
1238
+ "静态跳转只能证明可达性,不能代表真实访问频率,正式启用前仍需结合业务数据确认。",
1161
1239
  "该命令只提供可审计建议,不会自动修改源码或覆盖手写的 app.json.preloadRule。"
1162
1240
  ]
1163
1241
  };
@@ -2563,6 +2641,23 @@ async function startAnalyzeDashboard(result, options) {
2563
2641
  await waitPromise;
2564
2642
  }
2565
2643
  //#endregion
2644
+ //#region src/cli/processCleanup.ts
2645
+ function isSassEmbeddedChild(handle) {
2646
+ if (!handle || typeof handle !== "object") return false;
2647
+ const child = handle;
2648
+ const spawnfile = typeof child.spawnfile === "string" ? child.spawnfile : "";
2649
+ const spawnargs = Array.isArray(child.spawnargs) ? child.spawnargs : [];
2650
+ return Boolean("kill" in handle && "spawnfile" in handle && (spawnfile.includes("sass-embedded") || spawnfile.includes("dart-sass") && spawnargs.includes("--embedded")));
2651
+ }
2652
+ function terminateStaleSassEmbeddedProcess() {
2653
+ const getHandles = process._getActiveHandles;
2654
+ const handles = typeof getHandles === "function" ? getHandles() : void 0;
2655
+ if (!Array.isArray(handles)) return;
2656
+ for (const handle of handles) if (isSassEmbeddedChild(handle)) try {
2657
+ handle.kill();
2658
+ } catch {}
2659
+ }
2660
+ //#endregion
2566
2661
  //#region src/cli/commands/analyze.ts
2567
2662
  function normalizeDisplayPath(value) {
2568
2663
  return value || ".";
@@ -2687,6 +2782,15 @@ function printPreloadAnalysisSummary(result) {
2687
2782
  for (const evidence of suggestion.evidence.slice(0, 5)) logger_default.info(` - ${evidence.source}:${evidence.target}`);
2688
2783
  }
2689
2784
  if (result.uncoveredPages.length > 0) logger_default.warn(`- 未找到可扫描源码的页面:${result.uncoveredPages.join("、")}`);
2785
+ if (result.budgets.length > 0) {
2786
+ logger_default.info("预下载额度:");
2787
+ for (const budget of result.budgets) {
2788
+ const size = `${formatAnalyzeBytes(budget.estimatedBytes)} / ${formatAnalyzeBytes(budget.limitBytes)}`;
2789
+ const unknown = budget.unknownPackages.length > 0 ? `,未知:${budget.unknownPackages.join("、")}` : "";
2790
+ const status = budget.status === "exceeded" ? "超限" : budget.status === "unknown" ? "待确认" : "正常";
2791
+ logger_default.info(`- ${budget.sourcePackage}:${size},${status}${unknown}`);
2792
+ }
2793
+ }
2690
2794
  for (const limitation of result.limitations) logger_default.warn(`- 限制:${limitation}`);
2691
2795
  }
2692
2796
  async function writeAnalyzeResult(result, outputOption, configService, format = "json", previousResult) {
@@ -2809,7 +2913,7 @@ function printHmrProfileAnalysisSummary(result, configService) {
2809
2913
  }
2810
2914
  }
2811
2915
  function registerAnalyzeCommand(cli) {
2812
- cli.command("analyze [root]", "analyze 两端包体与源码映射").option("--hmr-profile [file]", `[string | boolean] 分析 HMR JSONL profile,省略值时优先读取配置,否则回退到默认路径`).option("--json", `[boolean] 输出 JSON 结果`).option("--markdown", `[boolean] 输出 Markdown 报告`).option("--report <type>", `[string] 输出指定报告类型(pr)`).option("--budget-check", `[boolean] 检查 analyze 预算,超过预算时返回非 0 退出码`).option("--preload", `[boolean] 分析静态页面跳转并输出 preloadRule 建议`).option("--output <file>", `[string] 将分析结果写入指定文件(JSON 或 Markdown)`).option("-p, --platform <platform>", `[string] target platform (weapp | web)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).action(async (root, options) => {
2916
+ cli.command("analyze [root]", "analyze 两端包体与源码映射").option("--hmr-profile [file]", `[string | boolean] 分析 HMR JSONL profile,省略值时优先读取配置,否则回退到默认路径`).option("--json", `[boolean] 输出 JSON 结果`).option("--markdown", `[boolean] 输出 Markdown 报告`).option("--report <type>", `[string] 输出指定报告类型(pr)`).option("--budget-check", `[boolean] 检查 analyze 预算,超过预算时返回非 0 退出码`).option("--preload", `[boolean] 分析静态页面跳转、实际分包体积和 preloadRule 额度`).option("--output <file>", `[string] 将分析结果写入指定文件(JSON 或 Markdown)`).option("-p, --platform <platform>", `[string] target platform (weapp | web)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).action(async (root, options) => {
2813
2917
  filterDuplicateOptions(options);
2814
2918
  const configFile = resolveConfigFile(options);
2815
2919
  const outputJson = coerceBooleanOption(options.json);
@@ -2820,8 +2924,9 @@ function registerAnalyzeCommand(cli) {
2820
2924
  const budgetCheck = coerceBooleanOption(options.budgetCheck);
2821
2925
  const targets = resolveRuntimeTargets(options);
2822
2926
  const inlineConfig = createInlineConfig(targets);
2927
+ let ctx;
2823
2928
  try {
2824
- const ctx = await createCompilerContext({
2929
+ ctx = await createCompilerContext({
2825
2930
  cwd: root,
2826
2931
  mode: options.mode ?? "production",
2827
2932
  configFile,
@@ -2851,7 +2956,8 @@ function registerAnalyzeCommand(cli) {
2851
2956
  }
2852
2957
  if (coerceBooleanOption(options.preload)) {
2853
2958
  if (targets.kind !== "miniprogram" || ctx.configService.platform !== "weapp") throw new Error("preloadRule 分析目前仅支持微信小程序平台。");
2854
- const preloadResult = await analyzePreloadRules(ctx);
2959
+ const packageAnalysis = await analyzeSubpackages(ctx);
2960
+ const preloadResult = await analyzePreloadRules(ctx, { packageAnalysis });
2855
2961
  const writtenPath = await writeAnalyzeResult(preloadResult, outputOption, ctx.configService);
2856
2962
  if (outputJson && !writtenPath) process.stdout.write(`${JSON.stringify(preloadResult, null, 2)}\n`);
2857
2963
  if (!outputJson && !writtenPath) printPreloadAnalysisSummary(preloadResult);
@@ -2894,6 +3000,11 @@ function registerAnalyzeCommand(cli) {
2894
3000
  } catch (error) {
2895
3001
  logger_default.error(error);
2896
3002
  process.exitCode = 1;
3003
+ } finally {
3004
+ if (ctx) {
3005
+ for (const backend of [...targets.entries].reverse()) if (backend.descriptor.capabilities.analyze) await backend.driver?.close?.(ctx);
3006
+ }
3007
+ terminateStaleSassEmbeddedProcess();
2897
3008
  }
2898
3009
  });
2899
3010
  }
@@ -2995,17 +3106,6 @@ function setCommandNodeEnv(nodeEnv) {
2995
3106
  }
2996
3107
  //#endregion
2997
3108
  //#region src/cli/commands/build.ts
2998
- function isSassEmbeddedChild(handle) {
2999
- return Boolean(handle && typeof handle === "object" && "kill" in handle && "spawnfile" in handle && typeof handle.spawnfile === "string" && handle.spawnfile?.includes("sass-embedded"));
3000
- }
3001
- function terminateStaleSassEmbeddedProcess() {
3002
- const getHandles = process._getActiveHandles;
3003
- const handles = typeof getHandles === "function" ? getHandles() : void 0;
3004
- if (!Array.isArray(handles)) return;
3005
- for (const handle of handles) if (isSassEmbeddedChild(handle)) try {
3006
- handle.kill();
3007
- } catch {}
3008
- }
3009
3109
  function emitDashboardEvents$1(handle, events) {
3010
3110
  handle?.emitRuntimeEvents(events);
3011
3111
  }
@@ -4845,7 +4945,7 @@ function resolveRunnableHotkeyDefinition(input) {
4845
4945
  }
4846
4946
  //#endregion
4847
4947
  //#region package.json
4848
- var version = "6.20.5";
4948
+ var version = "6.21.0";
4849
4949
  //#endregion
4850
4950
  //#region src/cli/devHotkeys/format.ts
4851
4951
  const FULLWIDTH_ASCII_START = 65281;
@@ -151,29 +151,36 @@ interface SubPackage {
151
151
  */
152
152
  inlineConfig?: Partial<InlineConfig>;
153
153
  }
154
- type SubPackageStyleScope = 'all' | 'pages' | 'components';
155
- interface SubPackageStyleConfigObject {
156
- /** 样式文件路径,可以是相对分包 root、相对 `srcRoot` 或绝对路径 */
154
+ type StyleScope = 'all' | 'pages' | 'components';
155
+ interface StyleConfigObject {
156
+ /** 样式文件路径,可以是相对当前包 root、相对 `srcRoot` 或绝对路径 */
157
157
  source: string;
158
158
  /**
159
159
  * @description 作用范围快捷配置
160
160
  */
161
- scope?: SubPackageStyleScope;
162
- /** 自定义包含路径,支持传入单个 glob 或数组,默认覆盖分包内所有文件 */
161
+ scope?: StyleScope;
162
+ /** 自定义包含路径,支持传入单个 glob 或数组,默认覆盖当前包内所有文件 */
163
163
  include?: string | string[];
164
164
  /** 自定义排除路径,支持传入单个 glob 或数组 */
165
165
  exclude?: string | string[];
166
+ /** 是否自动向命中的页面或组件样式注入 `@import`,关闭后只生成独立样式文件 */
167
+ inject?: boolean;
166
168
  }
167
- type SubPackageStyleConfigEntry = string | SubPackageStyleConfigObject;
168
- interface SubPackageStyleEntry {
169
+ type StyleConfigEntry = string | StyleConfigObject;
170
+ interface StyleEntry {
169
171
  source: string;
170
172
  absolutePath: string;
171
173
  outputRelativePath: string;
172
174
  inputExtension: string;
173
- scope: SubPackageStyleScope;
175
+ scope: StyleScope;
174
176
  include: string[];
175
177
  exclude: string[];
178
+ inject?: boolean;
176
179
  }
180
+ type SubPackageStyleScope = StyleScope;
181
+ type SubPackageStyleConfigObject = StyleConfigObject;
182
+ type SubPackageStyleConfigEntry = StyleConfigEntry;
183
+ type SubPackageStyleEntry = StyleEntry;
177
184
  type GenerateExtensionsOptions = Partial<{
178
185
  js: 'js' | 'ts' | (string & {});
179
186
  json: 'js' | 'ts' | 'json' | (string & {});
@@ -342,6 +349,10 @@ interface ChunksConfig {
342
349
  sharedMode?: SharedChunkMode;
343
350
  sharedOverrides?: SharedChunkOverride[];
344
351
  sharedPathRoot?: string;
352
+ /**
353
+ * @description 按 srcRoot 相对路径保留匹配源码模块的独立输出边界
354
+ */
355
+ preserveModules?: (string | RegExp)[];
345
356
  dynamicImports?: SharedChunkDynamicImports;
346
357
  logOptimization?: boolean;
347
358
  forceDuplicatePatterns?: (string | RegExp)[];
@@ -562,7 +573,7 @@ interface WeappSubPackageConfig {
562
573
  inlineConfig?: Partial<InlineConfig>;
563
574
  autoImportComponents?: AutoImportComponentsOption;
564
575
  watchSharedStyles?: boolean;
565
- styles?: SubPackageStyleConfigEntry | SubPackageStyleConfigEntry[];
576
+ styles?: StyleConfigEntry | StyleConfigEntry[];
566
577
  }
567
578
  /**
568
579
  * @description HMR 配置
@@ -678,7 +689,7 @@ interface SubPackageMetaValue {
678
689
  entries: string[];
679
690
  subPackage: SubPackage;
680
691
  autoImportComponents?: AutoImportComponentsOption;
681
- styleEntries?: SubPackageStyleEntry[];
692
+ styleEntries?: StyleEntry[];
682
693
  watchSharedStyles?: boolean;
683
694
  }
684
695
  /**
@@ -821,6 +832,10 @@ interface WeappViteConfig {
821
832
  npm?: WeappNpmConfig;
822
833
  generate?: GenerateOptions;
823
834
  tsconfigPaths?: boolean | PluginOptions;
835
+ /**
836
+ * 主包共享样式入口。生成独立样式文件,并按配置注入主包与普通分包页面或组件。
837
+ */
838
+ styles?: StyleConfigEntry | StyleConfigEntry[];
824
839
  subPackages?: Record<string, WeappSubPackageConfig>;
825
840
  copy?: CopyOptions;
826
841
  web?: WeappWebConfig;
@@ -1826,6 +1841,7 @@ interface RuntimeState {
1826
1841
  emittedCode: Map<string, string>;
1827
1842
  };
1828
1843
  scan: {
1844
+ mainPackageStyleEntries?: StyleEntry[];
1829
1845
  subPackageMap: Map<string, SubPackageMetaValue>;
1830
1846
  independentSubPackageMap: Map<string, SubPackageMetaValue>;
1831
1847
  warnedMessages: Set<string>;
@@ -1853,6 +1869,7 @@ interface ScanService {
1853
1869
  appEntry?: AppEntry;
1854
1870
  pluginJson?: Plugin;
1855
1871
  pluginJsonPath?: string;
1872
+ readonly mainPackageStyleEntries: StyleEntry[] | undefined;
1856
1873
  subPackageMap: Map<string, SubPackageMetaValue>;
1857
1874
  independentSubPackageMap: Map<string, SubPackageMetaValue>;
1858
1875
  loadAppEntry: () => Promise<AppEntry>;
@@ -2042,4 +2059,4 @@ declare module 'vite' {
2042
2059
  */
2043
2060
  declare function defineConfig<T extends UserConfigExport>(config: T): T;
2044
2061
  //#endregion
2045
- export { WeappAnalyzeBudgetConfig as $, WEB_PLATFORM_ALIASES as $n, GenerateFilenamesOptions as $t, Ref as A, SubPackageStyleEntry as An, WeappReactCompilerConfig as At, BindingErrorLike as B, WeappManagedNodeTsconfigConfig as Bn, WeappWevuConfig as Bt, LoadConfigOptions as C, SharedChunkDynamicImports as Cn, WeappInjectWeapiConfig as Ct, MethodDefinitions$1 as D, SubPackage as Dn, WeappNpmConfig as Dt, InlineConfig$1 as E, SharedChunkStrategy as En, WeappMcpConfig as Et, RolldownPlugin as F, WeappLibEntryContext as Fn, WeappSubPackageConfig as Ft, EntryJsonFragment as G, WEAPP_VITE_HOST_NAME as Gn, BuildNpmPackageMeta as Gt, BaseEntry as H, WeappManagedSharedTsconfigConfig as Hn, Alias as Ht, RolldownPluginOption as I, WeappLibFileName as In, WeappUniAppConfig as It, ScanComponentItem as J, createWeappViteHostMeta as Jn, CopyOptions as Jt, PageEntry as K, WeappViteHostMeta as Kn, ChunksConfig as Kt, RolldownWatchOptions as L, WeappLibInternalDtsOptions as Ln, WeappVueConfig as Lt, RolldownBuild as M, WeappLibComponentJson as Mn, WeappRequestRuntimeConfig as Mt, RolldownOptions as N, WeappLibConfig as Nn, WeappRouteRule as Nt, Plugin$1 as O, SubPackageStyleConfigEntry as On, WeappPreloadNetwork as Ot, RolldownOutput$1 as P, WeappLibDtsOptions as Pn, WeappRouteRules as Pt, UserConfig$2 as Q, ResolvedWeappViteTarget as Qn, GenerateFileType as Qt, RolldownWatcher$1 as R, WeappLibVueTscOptions as Rn, WeappVueTemplateConfig as Rt, CompilerContext as S, ResolvedAlias as Sn, WeappInjectRequestGlobalsTarget as St, ConfigEnv$1 as T, SharedChunkOverride as Tn, WeappInjectWebRuntimeGlobalsTarget as Tt, ComponentEntry as U, WeappManagedTypeScriptConfig as Un, AliasOptions as Ut, AppEntry as V, WeappManagedServerTsconfigConfig as Vn, WeappWorkerConfig as Vt, Entry as W, WeappWebConfig as Wn, AlipayNpmMode as Wt, ProjectConfig as X, resolveWeappViteHostMeta as Xn, GenerateDirsOptions as Xt, WxmlDep as Y, isWeappViteHost as Yn, DeprecatedInlineDynamicImports as Yt, SubPackageMetaValue as Z, ResolveWeappViteTargetOptions as Zn, GenerateExtensionsOptions as Zt, definePageJson as _, NpmDependencyPattern as _n, WeappAutoRoutesIncludePattern as _t, UserConfigFnNoEnvPlain as a, GenerateTemplateFileSource as an, WebPlatform as ar, WeappViteConfig as at, ChangeEvent as b, NpmStrategy as bn, WeappHmrConfig as bt, UserConfigFnPromise as c, GenerateTemplatesConfig as cn, isWebPlatform as cr, EnhanceOptions as ct, Component$1 as d, JsonMergeContext as dn, MultiPlatformConfig as dt, GenerateOptions as en, WeappVitePlatform as er, WeappAnalyzeConfig as et, Page$1 as f, JsonMergeFunction as fn, ScanWxmlOptions as ft, defineComponentJson as g, NpmBuildOptions as gn, WeappAutoRoutesInclude as gt, defineAppJson as h, MpPlatform$1 as hn, WeappAutoRoutesConfig as ht, UserConfigFnNoEnv as i, GenerateTemplateFactory as in, WeappViteTargetKind as ir, WeappForwardConsoleLogLevel as it, ResolvedConfig as j, SubPackageStyleScope as jn, WeappReactConfig as jt, PluginOption as k, SubPackageStyleConfigObject as kn, WeappPreloadRule as kt, defineConfig as l, JsFormat as ln, resolveWeappViteTarget as lr, EnhanceWxmlOptions as lt, Theme$1 as m, JsonMergeStrategy as mn, WeappAppPreludeMode as mt, UserConfigExport as n, GenerateTemplateContext as nn, WeappViteTargetDescriptor as nr, WeappDebugConfig as nt, UserConfigFnObject as o, GenerateTemplateInlineSource as on, getSupportedWeappVitePlatforms as or, AutoImportComponents as ot, Sitemap$1 as p, JsonMergeStage as pn, WeappAppPreludeConfig as pt, ComponentsMap as q, applyWeappViteHostMeta as qn, CopyGlobs as qt, UserConfigFn as r, GenerateTemplateEntry as rn, WeappViteTargetInput as rr, WeappForwardConsoleConfig as rt, UserConfigFnObjectPlain as s, GenerateTemplateScope as sn, getSupportedWeappViteTargetDescriptors as sr, AutoImportComponentsOption as st, UserConfig$1 as t, GenerateTemplate as tn, WeappViteRuntime as tr, WeappAnalyzeHistoryConfig as tt, App$1 as u, JsonConfig as un, HandleWxmlOptions as ut, defineSitemapJson as v, NpmMainPackageConfig as vn, WeappBuildScopeConfig as vt, ComputedDefinitions$1 as w, SharedChunkMode as wn, WeappInjectWebRuntimeGlobalsConfig as wt, WeappVitePluginApi as x, NpmSubPackageConfig as xn, WeappInjectRequestGlobalsConfig as xt, defineThemeJson as y, NpmPluginPackageConfig as yn, WeappBuildScopeObjectConfig as yt, ViteDevServer$1 as z, WeappManagedAppTsconfigConfig as zn, WeappWebRuntimeConfig as zt };
2062
+ export { WeappAnalyzeBudgetConfig as $, isWeappViteHost as $n, GenerateFilenamesOptions as $t, Ref as A, StyleScope as An, WeappReactCompilerConfig as At, BindingErrorLike as B, WeappLibFileName as Bn, WeappWevuConfig as Bt, LoadConfigOptions as C, SharedChunkDynamicImports as Cn, WeappInjectWeapiConfig as Ct, MethodDefinitions$1 as D, StyleConfigEntry as Dn, WeappNpmConfig as Dt, InlineConfig$1 as E, SharedChunkStrategy as En, WeappMcpConfig as Et, RolldownPlugin as F, SubPackageStyleScope as Fn, WeappSubPackageConfig as Ft, EntryJsonFragment as G, WeappManagedServerTsconfigConfig as Gn, BuildNpmPackageMeta as Gt, BaseEntry as H, WeappLibVueTscOptions as Hn, Alias as Ht, RolldownPluginOption as I, WeappLibComponentJson as In, WeappUniAppConfig as It, ScanComponentItem as J, WeappWebConfig as Jn, CopyOptions as Jt, PageEntry as K, WeappManagedSharedTsconfigConfig as Kn, ChunksConfig as Kt, RolldownWatchOptions as L, WeappLibConfig as Ln, WeappVueConfig as Lt, RolldownBuild as M, SubPackageStyleConfigEntry as Mn, WeappRequestRuntimeConfig as Mt, RolldownOptions as N, SubPackageStyleConfigObject as Nn, WeappRouteRule as Nt, Plugin$1 as O, StyleConfigObject as On, WeappPreloadNetwork as Ot, RolldownOutput$1 as P, SubPackageStyleEntry as Pn, WeappRouteRules as Pt, UserConfig$2 as Q, createWeappViteHostMeta as Qn, GenerateFileType as Qt, RolldownWatcher$1 as R, WeappLibDtsOptions as Rn, WeappVueTemplateConfig as Rt, CompilerContext as S, ResolvedAlias as Sn, WeappInjectRequestGlobalsTarget as St, ConfigEnv$1 as T, SharedChunkOverride as Tn, WeappInjectWebRuntimeGlobalsTarget as Tt, ComponentEntry as U, WeappManagedAppTsconfigConfig as Un, AliasOptions as Ut, AppEntry as V, WeappLibInternalDtsOptions as Vn, WeappWorkerConfig as Vt, Entry as W, WeappManagedNodeTsconfigConfig as Wn, AlipayNpmMode as Wt, ProjectConfig as X, WeappViteHostMeta as Xn, GenerateDirsOptions as Xt, WxmlDep as Y, WEAPP_VITE_HOST_NAME as Yn, DeprecatedInlineDynamicImports as Yt, SubPackageMetaValue as Z, applyWeappViteHostMeta as Zn, GenerateExtensionsOptions as Zt, definePageJson as _, NpmDependencyPattern as _n, WeappAutoRoutesIncludePattern as _t, UserConfigFnNoEnvPlain as a, GenerateTemplateFileSource as an, WeappViteRuntime as ar, WeappViteConfig as at, ChangeEvent as b, NpmStrategy as bn, WeappHmrConfig as bt, UserConfigFnPromise as c, GenerateTemplatesConfig as cn, WeappViteTargetKind as cr, EnhanceOptions as ct, Component$1 as d, JsonMergeContext as dn, getSupportedWeappViteTargetDescriptors as dr, MultiPlatformConfig as dt, GenerateOptions as en, resolveWeappViteHostMeta as er, WeappAnalyzeConfig as et, Page$1 as f, JsonMergeFunction as fn, isWebPlatform as fr, ScanWxmlOptions as ft, defineComponentJson as g, NpmBuildOptions as gn, WeappAutoRoutesInclude as gt, defineAppJson as h, MpPlatform$1 as hn, WeappAutoRoutesConfig as ht, UserConfigFnNoEnv as i, GenerateTemplateFactory as in, WeappVitePlatform as ir, WeappForwardConsoleLogLevel as it, ResolvedConfig as j, SubPackage as jn, WeappReactConfig as jt, PluginOption as k, StyleEntry as kn, WeappPreloadRule as kt, defineConfig as l, JsFormat as ln, WebPlatform as lr, EnhanceWxmlOptions as lt, Theme$1 as m, JsonMergeStrategy as mn, WeappAppPreludeMode as mt, UserConfigExport as n, GenerateTemplateContext as nn, ResolvedWeappViteTarget as nr, WeappDebugConfig as nt, UserConfigFnObject as o, GenerateTemplateInlineSource as on, WeappViteTargetDescriptor as or, AutoImportComponents as ot, Sitemap$1 as p, JsonMergeStage as pn, resolveWeappViteTarget as pr, WeappAppPreludeConfig as pt, ComponentsMap as q, WeappManagedTypeScriptConfig as qn, CopyGlobs as qt, UserConfigFn as r, GenerateTemplateEntry as rn, WEB_PLATFORM_ALIASES as rr, WeappForwardConsoleConfig as rt, UserConfigFnObjectPlain as s, GenerateTemplateScope as sn, WeappViteTargetInput as sr, AutoImportComponentsOption as st, UserConfig$1 as t, GenerateTemplate as tn, ResolveWeappViteTargetOptions as tr, WeappAnalyzeHistoryConfig as tt, App$1 as u, JsonConfig as un, getSupportedWeappVitePlatforms as ur, HandleWxmlOptions as ut, defineSitemapJson as v, NpmMainPackageConfig as vn, WeappBuildScopeConfig as vt, ComputedDefinitions$1 as w, SharedChunkMode as wn, WeappInjectWebRuntimeGlobalsConfig as wt, WeappVitePluginApi as x, NpmSubPackageConfig as xn, WeappInjectRequestGlobalsConfig as xt, defineThemeJson as y, NpmPluginPackageConfig as yn, WeappBuildScopeObjectConfig as yt, ViteDevServer$1 as z, WeappLibEntryContext as zn, WeappWebRuntimeConfig as zt };
package/dist/config.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { Gn as WEAPP_VITE_HOST_NAME, Jn as createWeappViteHostMeta, Kn as WeappViteHostMeta, Xn as resolveWeappViteHostMeta, Yn as isWeappViteHost, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, l as defineConfig, m as Theme, n as UserConfigExport, o as UserConfigFnObject, p as Sitemap, qn as applyWeappViteHostMeta, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, tr as WeappViteRuntime, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-B1H1OqnR.mjs";
1
+ import { $n as isWeappViteHost, Qn as createWeappViteHostMeta, Xn as WeappViteHostMeta, Yn as WEAPP_VITE_HOST_NAME, Zn as applyWeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, ar as WeappViteRuntime, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, er as resolveWeappViteHostMeta, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, l as defineConfig, m as Theme, n as UserConfigExport, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-Pi3hdn_g.mjs";
2
2
  export { type App, type Component, type Page, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, type WeappViteConfig, WeappViteHostMeta, type WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
@@ -1,6 +1,6 @@
1
1
  import { n as applyWeappViteHostMeta } from "./pluginHost--CaeyWpA.mjs";
2
2
  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-CWbsTVPm.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-Byldwig4.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";
@@ -192,7 +192,11 @@ function normalizeViteId(id, options) {
192
192
  if (stripQuery) clean = clean.split("?", 1)[0];
193
193
  if (fileProtocolToPathEnabled && clean.startsWith("file://")) try {
194
194
  clean = fileURLToPath(clean);
195
- } catch {}
195
+ } catch {
196
+ try {
197
+ clean = decodeURIComponent(new URL(clean).pathname);
198
+ } catch {}
199
+ }
196
200
  if (stripAtFsPrefix) clean = stripViteAtFsPrefix(clean);
197
201
  if (stripLeadingNullByte && clean.startsWith("\0")) clean = clean.slice(1);
198
202
  if (clean.includes("\\")) clean = clean.replace(BACKSLASH_RE$1, "/");
@@ -5311,13 +5315,22 @@ async function loadViteConfigFile(configEnv, configFile, configRoot, configFileD
5311
5315
  }
5312
5316
  //#endregion
5313
5317
  //#region src/utils/preloadScan.ts
5314
- const ROUTER_METHODS = /* @__PURE__ */ new Set([
5318
+ const HOST_ROUTER_METHODS = /* @__PURE__ */ new Set([
5315
5319
  "navigateTo",
5316
5320
  "redirectTo",
5317
5321
  "reLaunch",
5318
- "switchTab",
5319
- "push",
5320
- "replace"
5322
+ "switchTab"
5323
+ ]);
5324
+ const ROUTER_METHODS = /* @__PURE__ */ new Set(["push", "replace"]);
5325
+ const ROUTER_MODULES = /* @__PURE__ */ new Set([
5326
+ "vue-router",
5327
+ "wevu",
5328
+ "wevu/router"
5329
+ ]);
5330
+ const ROUTER_FACTORY_METHODS = /* @__PURE__ */ new Map([
5331
+ ["createRouter", ROUTER_METHODS],
5332
+ ["useNativeRouter", HOST_ROUTER_METHODS],
5333
+ ["useRouter", ROUTER_METHODS]
5321
5334
  ]);
5322
5335
  const TEMPLATE_NAVIGATOR_RE = /<navigator(?=\s|>)[^>]*?\surl\s*=\s*(["'])([^"'{}\s]+)\1/gi;
5323
5336
  function normalizePagePath$1(value) {
@@ -5346,14 +5359,72 @@ function getRouteFromObject(argument) {
5346
5359
  if (value) return value;
5347
5360
  }
5348
5361
  }
5362
+ function getIdentifierName(node) {
5363
+ return node?.type === "Identifier" ? node.name : void 0;
5364
+ }
5365
+ function collectRouterBindings(ast) {
5366
+ const importedFactories = /* @__PURE__ */ new Map();
5367
+ const routerObjects = /* @__PURE__ */ new Map();
5368
+ const routerFunctions = /* @__PURE__ */ new Map();
5369
+ traverse(ast, { ImportDeclaration(importPath) {
5370
+ if (!ROUTER_MODULES.has(importPath.node.source?.value)) return;
5371
+ for (const specifier of importPath.node.specifiers ?? []) {
5372
+ if (specifier.type !== "ImportSpecifier") continue;
5373
+ const imported = getIdentifierName(specifier.imported) ?? getStaticString(specifier.imported);
5374
+ const local = getIdentifierName(specifier.local);
5375
+ const methods = imported ? ROUTER_FACTORY_METHODS.get(imported) : void 0;
5376
+ const binding = local ? importPath.scope.getBinding(local) : void 0;
5377
+ if (methods && binding) importedFactories.set(binding, methods);
5378
+ }
5379
+ } });
5380
+ traverse(ast, { VariableDeclarator(declaratorPath) {
5381
+ const init = declaratorPath.node.init;
5382
+ const factory = init?.type === "CallExpression" ? getIdentifierName(init.callee) : void 0;
5383
+ if (!factory) return;
5384
+ const factoryBinding = declaratorPath.scope.getBinding(factory);
5385
+ const methods = factoryBinding ? importedFactories.get(factoryBinding) : ROUTER_FACTORY_METHODS.get(factory);
5386
+ if (!methods) return;
5387
+ const id = declaratorPath.node.id;
5388
+ const objectName = getIdentifierName(id);
5389
+ if (objectName) {
5390
+ const binding = declaratorPath.scope.getBinding(objectName);
5391
+ if (binding?.constant) routerObjects.set(binding, methods);
5392
+ return;
5393
+ }
5394
+ if (id?.type !== "ObjectPattern") return;
5395
+ for (const property of id.properties ?? []) {
5396
+ if (property.type !== "ObjectProperty" && property.type !== "Property") continue;
5397
+ const importedMethod = getPropertyName(property.key);
5398
+ const local = getIdentifierName(property.value);
5399
+ const binding = local ? declaratorPath.scope.getBinding(local) : void 0;
5400
+ if (importedMethod && methods.has(importedMethod) && binding?.constant) routerFunctions.set(binding, importedMethod);
5401
+ }
5402
+ } });
5403
+ return {
5404
+ routerFunctions,
5405
+ routerObjects
5406
+ };
5407
+ }
5408
+ function getNavigationMethod(callPath, bindings) {
5409
+ const callee = callPath.node.callee;
5410
+ const directName = getIdentifierName(callee);
5411
+ const directMethod = directName ? bindings.routerFunctions.get(callPath.scope.getBinding(directName)) : void 0;
5412
+ if (directMethod) return directMethod;
5413
+ if (callee?.type !== "MemberExpression" && callee?.type !== "OptionalMemberExpression") return;
5414
+ const objectName = getIdentifierName(callee.object);
5415
+ const method = getPropertyName(callee.property);
5416
+ if (objectName === "wx" && !callPath.scope.getBinding("wx") && method && HOST_ROUTER_METHODS.has(method)) return method;
5417
+ if (objectName && method) {
5418
+ if (bindings.routerObjects.get(callPath.scope.getBinding(objectName))?.has(method)) return method;
5419
+ }
5420
+ }
5349
5421
  function collectScriptTargets(source, sourcePage) {
5350
5422
  const targets = [];
5351
5423
  try {
5352
5424
  const ast = parseJsLike(source);
5425
+ const bindings = collectRouterBindings(ast);
5353
5426
  traverse(ast, { CallExpression(callPath) {
5354
- const callee = callPath.node.callee;
5355
- const method = callee?.type === "Identifier" ? callee.name : callee?.type === "MemberExpression" ? getPropertyName(callee.property) : void 0;
5356
- if (!ROUTER_METHODS.has(method)) return;
5427
+ if (!getNavigationMethod(callPath, bindings)) return;
5357
5428
  const argument = callPath.node.arguments?.[0];
5358
5429
  const target = getStaticString(argument) ?? getRouteFromObject(argument);
5359
5430
  if (target) targets.push(normalizeStaticTarget(target, sourcePage));
@@ -5458,7 +5529,8 @@ function collectSubPackages(appJson) {
5458
5529
  const root = normalizePackageRoot(item.root);
5459
5530
  return (Array.isArray(item.pages) ? item.pages.filter((page) => typeof page === "string" && page.trim().length > 0) : []).map((page) => ({
5460
5531
  route: normalizePagePath(path.posix.join(root, page)),
5461
- packageRoot: root
5532
+ packageRoot: root,
5533
+ ...item.independent === true ? { independent: true } : {}
5462
5534
  }));
5463
5535
  });
5464
5536
  }
@@ -5469,6 +5541,17 @@ function findPreloadRuleKey(page, preloadRule) {
5469
5541
  const candidates = pageCandidates(page);
5470
5542
  return Object.keys(preloadRule).find((candidate) => candidates.includes(normalizePagePath(candidate)));
5471
5543
  }
5544
+ function resolvePreloadPackageIdentifier(value, appJson) {
5545
+ const normalized = value === "__APP__" ? value : normalizePackageRoot(value);
5546
+ if (!normalized || normalized === "__APP__") return normalized || void 0;
5547
+ const source = Array.isArray(appJson.subPackages) ? appJson.subPackages : Array.isArray(appJson.subpackages) ? appJson.subpackages : [];
5548
+ for (const item of source) {
5549
+ if (!isObject(item) || typeof item.root !== "string") continue;
5550
+ const root = normalizePackageRoot(item.root);
5551
+ if (root === normalized || typeof item.name === "string" && item.name === value) return root;
5552
+ }
5553
+ return normalized;
5554
+ }
5472
5555
  function cloneRule(rule) {
5473
5556
  if (!isObject(rule)) return rule;
5474
5557
  const packages = Array.isArray(rule.packages) ? rule.packages.filter((item) => typeof item === "string") : [];
@@ -5495,13 +5578,15 @@ function applyPreloadRulesToAppJson(appJson, routeRules, platform) {
5495
5578
  }
5496
5579
  function suggestPreloadRules(appJson, pageSources) {
5497
5580
  const pages = collectPreloadPages(appJson);
5498
- const packageByRoute = new Map(pages.map((page) => [page.route, page.packageRoot]));
5581
+ const pageByRoute = new Map(pages.map((page) => [page.route, page]));
5499
5582
  const suggestions = [];
5500
5583
  const uncovered = /* @__PURE__ */ new Set();
5501
5584
  for (const page of pages) {
5502
5585
  const source = pageSources.get(page.route);
5503
5586
  for (const kind of ["template", "script"]) for (const target of collectStaticRouteTargets(source?.[kind] ?? "", kind, page.route)) {
5504
- const packageRoot = packageByRoute.get(target);
5587
+ const targetPage = pageByRoute.get(target);
5588
+ if (!targetPage) continue;
5589
+ const packageRoot = targetPage.packageRoot ?? (page.independent ? "__APP__" : void 0);
5505
5590
  if (!packageRoot || packageRoot === page.packageRoot) continue;
5506
5591
  const suggestion = {
5507
5592
  page: page.route,
@@ -9223,6 +9308,7 @@ function createRuntimeState() {
9223
9308
  emittedCode: /* @__PURE__ */ new Map()
9224
9309
  },
9225
9310
  scan: {
9311
+ mainPackageStyleEntries: void 0,
9226
9312
  subPackageMap: /* @__PURE__ */ new Map(),
9227
9313
  independentSubPackageMap: /* @__PURE__ */ new Map(),
9228
9314
  warnedMessages: /* @__PURE__ */ new Set(),
@@ -9292,6 +9378,7 @@ function resetRuntimeStateForFreshBuild(runtimeState) {
9292
9378
  wxml.cache.signatureMap.clear();
9293
9379
  wxml.emittedCode.clear();
9294
9380
  const scan = runtimeState.scan;
9381
+ scan.mainPackageStyleEntries = void 0;
9295
9382
  scan.subPackageMap.clear();
9296
9383
  scan.independentSubPackageMap.clear();
9297
9384
  scan.warnedMessages.clear();
@@ -10766,6 +10853,83 @@ function createAdvancedChunkNameResolver(options) {
10766
10853
  };
10767
10854
  }
10768
10855
  //#endregion
10856
+ //#region src/runtime/preserveModules.ts
10857
+ const PRESERVED_MODULE_GROUP_PRIORITY = 100;
10858
+ function createPatternMatcher(pattern) {
10859
+ if (typeof pattern === "string") {
10860
+ const matcher = picomatch(pattern, { dot: true });
10861
+ return (value) => matcher(value);
10862
+ }
10863
+ if (isRegexp(pattern)) return (value) => {
10864
+ pattern.lastIndex = 0;
10865
+ return pattern.test(value);
10866
+ };
10867
+ }
10868
+ function createPreserveModuleMatcher(patterns) {
10869
+ const matchers = patterns?.map((pattern) => createPatternMatcher(pattern)).filter((matcher) => typeof matcher === "function");
10870
+ if (!matchers?.length) return;
10871
+ return (relativeId, absoluteId) => {
10872
+ return matchers.some((matcher) => matcher(relativeId) || matcher(absoluteId));
10873
+ };
10874
+ }
10875
+ function normalizePreservedSourceId(id) {
10876
+ return normalizeViteId(id, {
10877
+ stripQuery: true,
10878
+ fileProtocolToPath: true,
10879
+ stripAtFsPrefix: true,
10880
+ stripLeadingNullByte: true
10881
+ });
10882
+ }
10883
+ function normalizePreserveModulesRolldownOptions(configService, rolldownOptions) {
10884
+ if (configService.weappViteConfig?.chunks?.preserveModules?.length && (rolldownOptions.preserveEntrySignatures === void 0 || rolldownOptions.preserveEntrySignatures === "exports-only")) rolldownOptions.preserveEntrySignatures = "allow-extension";
10885
+ return rolldownOptions;
10886
+ }
10887
+ function resolvePreservedModuleName(options) {
10888
+ const { configService, ctx, getSubPackageRoots, id } = options;
10889
+ if (parseSidecarSourceRequest(id)) return;
10890
+ const absoluteId = normalizePreservedSourceId(id);
10891
+ if (!path.isAbsolute(absoluteId) || !isPathInside(configService.absoluteSrcRoot, absoluteId)) return;
10892
+ const moduleInfo = ctx.getModuleInfo(id);
10893
+ if (moduleInfo?.importers?.some((importer) => {
10894
+ return parseLogicalEntryId(importer)?.sourceId === absoluteId;
10895
+ })) return;
10896
+ const relativeId = normalizeRelativePath$1(path.relative(configService.absoluteSrcRoot, absoluteId));
10897
+ if (!relativeId || relativeId.startsWith("..")) return;
10898
+ const subPackageRoots = Array.from(getSubPackageRoots());
10899
+ const moduleRoot = resolveSubPackagePrefix(relativeId, subPackageRoots);
10900
+ if (moduleRoot) assertModuleScopedToRoot({
10901
+ moduleInfo,
10902
+ moduleRoot,
10903
+ relativeAbsoluteSrcRoot: configService.relativeAbsoluteSrcRoot,
10904
+ subPackageRoots,
10905
+ moduleId: id
10906
+ });
10907
+ const name = removeExtensionDeep(relativeId);
10908
+ return name && name !== "." ? name : void 0;
10909
+ }
10910
+ function createPreserveModulesGroup(configService, getSubPackageRoots) {
10911
+ const matches = createPreserveModuleMatcher(configService.weappViteConfig?.chunks?.preserveModules);
10912
+ if (!matches) return;
10913
+ return {
10914
+ name: (id, ctx) => resolvePreservedModuleName({
10915
+ configService,
10916
+ ctx,
10917
+ getSubPackageRoots,
10918
+ id
10919
+ }),
10920
+ test: (id) => {
10921
+ const absoluteId = normalizePreservedSourceId(id);
10922
+ const relativeId = configService.relativeAbsoluteSrcRoot(absoluteId);
10923
+ return matches(relativeId, absoluteId);
10924
+ },
10925
+ priority: PRESERVED_MODULE_GROUP_PRIORITY,
10926
+ minShareCount: 1,
10927
+ minSize: 0,
10928
+ minModuleSize: 0,
10929
+ includeDependenciesRecursively: false
10930
+ };
10931
+ }
10932
+ //#endregion
10769
10933
  //#region src/runtime/wevuModules.ts
10770
10934
  const WEVU_RUNTIME_MODULE_IDS = [
10771
10935
  "wevu",
@@ -11077,15 +11241,20 @@ function createSharedBuildResolver(configService, getSubPackageRoots) {
11077
11241
  return { resolveAdvancedChunkName: resolveSharedBuildChunkName };
11078
11242
  }
11079
11243
  function createSharedBuildOutput(configService, getSubPackageRoots, options = {}) {
11244
+ const preserveModulesGroup = createPreserveModulesGroup(configService, getSubPackageRoots);
11080
11245
  const { resolveAdvancedChunkName } = createSharedBuildResolver(configService, getSubPackageRoots);
11081
11246
  return {
11082
- codeSplitting: { groups: [...configService.isDev ? [{
11083
- test: isStableHashedDistChunkModule,
11084
- minShareCount: 1,
11085
- minSize: 0,
11086
- minModuleSize: 0,
11087
- name: (id) => resolveStableHashedDistChunkName({ facadeModuleId: id })
11088
- }] : [], { name: (id, ctx) => resolveAdvancedChunkName(id, ctx) }] },
11247
+ codeSplitting: { groups: [
11248
+ ...preserveModulesGroup ? [preserveModulesGroup] : [],
11249
+ ...configService.isDev ? [{
11250
+ test: isStableHashedDistChunkModule,
11251
+ minShareCount: 1,
11252
+ minSize: 0,
11253
+ minModuleSize: 0,
11254
+ name: (id) => resolveStableHashedDistChunkName({ facadeModuleId: id })
11255
+ }] : [],
11256
+ { name: (id, ctx) => resolveAdvancedChunkName(id, ctx) }
11257
+ ] },
11089
11258
  minifyInternalExports: false,
11090
11259
  chunkFileNames: (chunk) => {
11091
11260
  if (isRequestGlobalsRuntimeChunk(chunk)) return REQUEST_GLOBAL_RUNTIME_CHUNK_FILE_BASENAME;
@@ -11100,7 +11269,12 @@ function createSharedBuildOutput(configService, getSubPackageRoots, options = {}
11100
11269
  };
11101
11270
  }
11102
11271
  function createSharedBuildConfig(configService, scanService) {
11103
- return { build: { rolldownOptions: { output: createSharedBuildOutput(configService, () => scanService.subPackageMap.keys()) } } };
11272
+ const output = createSharedBuildOutput(configService, () => scanService.subPackageMap.keys());
11273
+ const preserveEntrySignatures = configService.weappViteConfig?.chunks?.preserveModules?.length ? "allow-extension" : void 0;
11274
+ return { build: { rolldownOptions: {
11275
+ ...preserveEntrySignatures ? { preserveEntrySignatures } : {},
11276
+ output
11277
+ } } };
11104
11278
  }
11105
11279
  //#endregion
11106
11280
  //#region src/runtime/statefulHmr/runtimeSource.ts
@@ -17614,7 +17788,8 @@ function configureBuildAndPlugins(options) {
17614
17788
  const rdTransform = rdOptions.transform ?? {};
17615
17789
  if (!Object.prototype.hasOwnProperty.call(rdTransform, "tsconfig")) rdTransform.tsconfig = false;
17616
17790
  rdOptions.transform = rdTransform;
17617
- rdOptions.preserveEntrySignatures ??= "exports-only";
17791
+ if (config.weapp?.chunks?.preserveModules?.length && (rdOptions.preserveEntrySignatures === void 0 || rdOptions.preserveEntrySignatures === "exports-only")) rdOptions.preserveEntrySignatures = "allow-extension";
17792
+ else rdOptions.preserveEntrySignatures ??= "exports-only";
17618
17793
  if (Array.isArray(rdOptions.output)) rdOptions.output = rdOptions.output.map((output) => ({
17619
17794
  ...output,
17620
17795
  format: jsFormat
@@ -25743,9 +25918,11 @@ function invalidateSharedStyleCache() {
25743
25918
  const styleMatcherCache = /* @__PURE__ */ new WeakMap();
25744
25919
  function collectSharedStyleEntries(ctx, configService) {
25745
25920
  const map = /* @__PURE__ */ new Map();
25921
+ const mainPackageEntries = ctx.scanService?.mainPackageStyleEntries;
25922
+ const currentRoot = configService.currentSubPackageRoot;
25923
+ if (!currentRoot && mainPackageEntries?.length) map.set("", mainPackageEntries);
25746
25924
  const registry = ctx.scanService?.subPackageMap;
25747
25925
  if (!registry?.size) return map;
25748
- const currentRoot = configService.currentSubPackageRoot;
25749
25926
  for (const [root, meta] of registry.entries()) {
25750
25927
  if (!meta.styleEntries?.length) continue;
25751
25928
  if (currentRoot && root !== currentRoot) continue;
@@ -25768,6 +25945,9 @@ function relativeToRoot(pathname, root) {
25768
25945
  if (pathname === root) return "";
25769
25946
  if (pathname.startsWith(`${root}/`)) return pathname.slice(root.length + 1);
25770
25947
  }
25948
+ function isMainAppStyleFile(fileName) {
25949
+ return !fileName.includes("/") && path.posix.basename(fileName, path.posix.extname(fileName)) === "app";
25950
+ }
25771
25951
  function getStyleMatcher(entry) {
25772
25952
  const cached = styleMatcherCache.get(entry);
25773
25953
  if (cached) return cached;
@@ -25794,11 +25974,15 @@ function findSharedStylesForModule(modulePath, fileName, sharedStyles) {
25794
25974
  const matched = [];
25795
25975
  for (const [root, entries] of sharedStyles.entries()) {
25796
25976
  const normalizedRoot = normalizeRoot(root);
25797
- if (!normalizedRoot) continue;
25977
+ if (root && !normalizedRoot) continue;
25978
+ if (!normalizedRoot && isMainAppStyleFile(sanitizedFile)) continue;
25798
25979
  if (!isWithinRoot(sanitizedFile, normalizedRoot)) continue;
25799
25980
  const relativeModule = relativeToRoot(sanitizedModule, normalizedRoot);
25800
25981
  const relativeFile = relativeToRoot(sanitizedFile, normalizedRoot);
25801
- for (const entry of entries) if (matchesStyleEntry(entry, relativeModule, relativeFile)) matched.push(entry);
25982
+ for (const entry of entries) {
25983
+ if (entry.inject === false) continue;
25984
+ if (matchesStyleEntry(entry, relativeModule, relativeFile)) matched.push(entry);
25985
+ }
25802
25986
  }
25803
25987
  return matched;
25804
25988
  }
@@ -26074,9 +26258,10 @@ async function handleBundleEntry(ctx, bundle, bundleKey, asset, configService, s
26074
26258
  const cssWithImports = injectSharedStyleImportsCached(processedCss, owner, fileName, sharedStyles, configService, sharedStyleImportCache);
26075
26259
  emitCssAssetIfChanged(ctx, this, bundle, fileName, cssWithImports);
26076
26260
  emitted.add(normalizedFileName);
26261
+ return normalizedFileName;
26077
26262
  };
26078
- const isFinalStyleAsset = bundleKey.endsWith(`.${configService.outputExtensions.wxss}`);
26079
26263
  const isCssAsset = bundleKey.endsWith(".css");
26264
+ const isFinalStyleAsset = bundleKey.endsWith(`.${configService.outputExtensions.wxss}`) && (!isCssAsset || path.posix.basename(bundleKey, ".css") === "app");
26080
26265
  const isSourceStyleAssetKey = isSourceStyleAsset(bundleKey);
26081
26266
  if (isFinalStyleAsset) {
26082
26267
  const absOriginal = resolveOriginalStylePath();
@@ -26116,10 +26301,11 @@ async function handleBundleEntry(ctx, bundle, bundleKey, asset, configService, s
26116
26301
  delete bundle[bundleKey];
26117
26302
  return;
26118
26303
  }
26119
- await Promise.all(Array.from(owners).map(async (owner) => {
26120
- await emitStyleAssetForOwner(owner, resolveOriginalStylePath(), !isCssAsset);
26304
+ const emittedOwners = await Promise.all(Array.from(owners).map(async (owner) => {
26305
+ return await emitStyleAssetForOwner(owner, resolveOriginalStylePath(), !isCssAsset);
26121
26306
  }));
26122
- delete bundle[bundleKey];
26307
+ const normalizedBundleKey = toPosixPath(bundleKey);
26308
+ if (!isCssAsset || !emittedOwners.includes(normalizedBundleKey)) delete bundle[bundleKey];
26123
26309
  }
26124
26310
  async function emitSharedStyleEntries(ctx, sharedStyles, emitted, configService, bundle, resolvedConfig) {
26125
26311
  if (!sharedStyles.size) return;
@@ -33081,6 +33267,7 @@ function normalizeInlineConfigAfterDefu(inline, options) {
33081
33267
  ...userRolldownOptions?.output ?? {}
33082
33268
  }
33083
33269
  };
33270
+ if (ctx.configService) normalizePreserveModulesRolldownOptions(ctx.configService, mergedRolldownOptions);
33084
33271
  const defaultTsconfig = resolveDefaultRolldownTsconfig(cwd, configFilePath);
33085
33272
  const resolveOptions = mergedRolldownOptions.resolve;
33086
33273
  if (defaultTsconfig) {
@@ -33257,6 +33444,7 @@ function mergeWeb(options, ...configs) {
33257
33444
  }
33258
33445
  });
33259
33446
  stripRollupOptions(inline);
33447
+ if (options.configService) normalizePreserveModulesRolldownOptions(options.configService, inline.build?.rolldownOptions ?? (inline.build.rolldownOptions = {}));
33260
33448
  inline.root = web.root;
33261
33449
  inline.configFile = false;
33262
33450
  const runtimeProvider = resolveRuntimeProvider("web", "web");
@@ -33314,6 +33502,7 @@ function mergeWorkers(options, ...configs) {
33314
33502
  });
33315
33503
  applyWeappViteHostMeta(inline, "miniprogram", platform);
33316
33504
  stripRollupOptions(inline);
33505
+ normalizePreserveModulesRolldownOptions(ctx.configService, inline.build?.rolldownOptions ?? (inline.build.rolldownOptions = {}));
33317
33506
  injectBuiltinAliases(inline);
33318
33507
  return inline;
33319
33508
  }
@@ -33327,6 +33516,7 @@ function mergeWorkers(options, ...configs) {
33327
33516
  applyWeappViteHostMeta(inlineConfig, "miniprogram", platform);
33328
33517
  stripRollupOptions(inlineConfig);
33329
33518
  inlineConfig.logLevel = "info";
33519
+ normalizePreserveModulesRolldownOptions(ctx.configService, inlineConfig.build?.rolldownOptions ?? (inlineConfig.build.rolldownOptions = {}));
33330
33520
  injectBuiltinAliases(inlineConfig);
33331
33521
  return inlineConfig;
33332
33522
  }
@@ -33385,6 +33575,7 @@ function createMergeFactories(options) {
33385
33575
  const subPackageRoots = Object.keys(configService.weappViteConfig?.subPackages ?? {});
33386
33576
  const sharedOutput = configService.options.chunksConfigured ? createSharedBuildOutput(configService, () => subPackageRoots, { runtime: "web" }) : void 0;
33387
33577
  return backend.driver.mergeConfig({ merge: (...backendConfigs) => mergeWeb({
33578
+ configService,
33388
33579
  config: currentOptions.config,
33389
33580
  web: currentOptions.weappWeb,
33390
33581
  mode: currentOptions.mode,
@@ -33997,7 +34188,7 @@ async function loadAppEntry(ctx, scanState) {
33997
34188
  const { path: appEntryPath } = appEntry;
33998
34189
  let configFromVue;
33999
34190
  if (!appConfigFile && vueAppPath) {
34000
- const { extractConfigFromVue } = await import("./file-BjrPjC70.mjs");
34191
+ const { extractConfigFromVue } = await import("./file-C-jjrMsb.mjs");
34001
34192
  configFromVue = await extractConfigFromVue(vueAppPath);
34002
34193
  if (configFromVue) appConfigFile = vueAppPath;
34003
34194
  }
@@ -34099,6 +34290,7 @@ function coerceStyleConfig(entry) {
34099
34290
  return {
34100
34291
  source,
34101
34292
  scope: "all",
34293
+ inject: true,
34102
34294
  explicitScope: false
34103
34295
  };
34104
34296
  }
@@ -34111,6 +34303,7 @@ function coerceStyleConfig(entry) {
34111
34303
  scope: hasExplicitScope ? coerceScope(entry.scope) : "all",
34112
34304
  include: entry.include,
34113
34305
  exclude: entry.exclude,
34306
+ inject: entry.inject !== false,
34114
34307
  explicitScope: hasExplicitScope
34115
34308
  };
34116
34309
  }
@@ -34157,11 +34350,12 @@ function resolveExcludePatterns(descriptor, normalizedRoot) {
34157
34350
  }
34158
34351
  //#endregion
34159
34352
  //#region src/runtime/scanPlugin/styleEntries/entries.ts
34160
- function createStyleEntryDedupeKey(posixOutput, include, exclude) {
34353
+ function createStyleEntryDedupeKey(posixOutput, include, exclude, inject) {
34161
34354
  return JSON.stringify({
34162
34355
  file: posixOutput,
34163
34356
  include,
34164
- exclude
34357
+ exclude,
34358
+ inject
34165
34359
  });
34166
34360
  }
34167
34361
  function resolveDefaultScopedStyleEntryCandidates(absoluteSrcRoot, root) {
@@ -34173,7 +34367,7 @@ function resolveDefaultScopedStyleEntryCandidates(absoluteSrcRoot, root) {
34173
34367
  absolutePath: path.resolve(absoluteSubRoot, `${base}${ext}`)
34174
34368
  })));
34175
34369
  }
34176
- function addStyleEntry(descriptor, absolutePath, posixOutput, root, normalizedRoot, dedupe, normalized) {
34370
+ function addStyleEntry(descriptor, absolutePath, posixOutput, normalizedRoot, warningPrefix, dedupe, normalized) {
34177
34371
  const include = resolveIncludePatterns({
34178
34372
  scope: descriptor.scope,
34179
34373
  include: descriptor.include
@@ -34182,10 +34376,10 @@ function addStyleEntry(descriptor, absolutePath, posixOutput, root, normalizedRo
34182
34376
  include.sort();
34183
34377
  exclude.sort();
34184
34378
  if (!include.length) {
34185
- logger_default.warn(`[分包] 分包 ${root} 样式入口 \`${descriptor.source}\` 缺少有效作用范围,已按 \`**/*\` 处理。`);
34379
+ logger_default.warn(`${warningPrefix}样式入口 \`${descriptor.source}\` 缺少有效作用范围,已按 \`**/*\` 处理。`);
34186
34380
  include.push("**/*");
34187
34381
  }
34188
- const key = createStyleEntryDedupeKey(posixOutput, include, exclude);
34382
+ const key = createStyleEntryDedupeKey(posixOutput, include, exclude, descriptor.inject);
34189
34383
  if (dedupe.has(key)) return;
34190
34384
  dedupe.add(key);
34191
34385
  normalized.push({
@@ -34195,7 +34389,8 @@ function addStyleEntry(descriptor, absolutePath, posixOutput, root, normalizedRo
34195
34389
  inputExtension: path.extname(absolutePath).toLowerCase(),
34196
34390
  scope: descriptor.scope,
34197
34391
  include,
34198
- exclude
34392
+ exclude,
34393
+ inject: descriptor.inject
34199
34394
  });
34200
34395
  }
34201
34396
  function appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe, normalized) {
@@ -34212,13 +34407,14 @@ function appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe,
34212
34407
  scope: candidate.scope,
34213
34408
  include: void 0,
34214
34409
  exclude: void 0,
34410
+ inject: true,
34215
34411
  explicitScope: true
34216
34412
  };
34217
34413
  const outputAbsolutePath = changeFileExtension(candidate.absolutePath, service.outputExtensions.wxss);
34218
34414
  const outputRelativePath = service.relativeOutputPath(outputAbsolutePath);
34219
34415
  if (!outputRelativePath) continue;
34220
34416
  const posixOutput = toPosixPath(outputRelativePath);
34221
- addStyleEntry(descriptor, candidate.absolutePath, posixOutput, root, normalizedRoot, dedupe, normalized);
34417
+ addStyleEntry(descriptor, candidate.absolutePath, posixOutput, normalizedRoot, `[分包] 分包 ${root} `, dedupe, normalized);
34222
34418
  matchedCurrentBase = true;
34223
34419
  }
34224
34420
  }
@@ -34271,11 +34467,9 @@ function resolveStyleEntryScope(descriptor, posixOutput, normalizedRoot) {
34271
34467
  if (descriptor.explicitScope) return descriptor.scope;
34272
34468
  return inferScopeFromRelativePath(getRelativePathWithinSubPackage(posixOutput, normalizedRoot)) ?? descriptor.scope;
34273
34469
  }
34274
- function normalizeSubPackageStyleEntries(styles, subPackage, configService) {
34470
+ function normalizeStyleEntries(styles, root, configService, options) {
34275
34471
  const service = configService;
34276
34472
  if (!service) return;
34277
- const root = subPackage.root?.trim();
34278
- if (!root) return;
34279
34473
  const list = styles === void 0 ? [] : Array.isArray(styles) ? styles : [styles];
34280
34474
  const normalizedRoot = normalizeRoot(root);
34281
34475
  const normalized = [];
@@ -34283,37 +34477,52 @@ function normalizeSubPackageStyleEntries(styles, subPackage, configService) {
34283
34477
  for (const entry of list) {
34284
34478
  const descriptor = coerceStyleConfig(entry);
34285
34479
  if (!descriptor) {
34286
- logger_default.warn(`[分包] 分包 ${root} 样式入口配置无效,已忽略。`);
34480
+ logger_default.warn(`${options.warningPrefix}样式入口配置无效,已忽略。`);
34287
34481
  continue;
34288
34482
  }
34289
34483
  const absolutePath = resolveStyleEntryAbsolutePath(descriptor.source, root, service);
34290
34484
  if (!absolutePath) {
34291
- logger_default.warn(`[分包] 分包 ${root} 样式入口 \`${descriptor.source}\` 解析失败,已忽略。`);
34485
+ logger_default.warn(`${options.warningPrefix}样式入口 \`${descriptor.source}\` 解析失败,已忽略。`);
34292
34486
  continue;
34293
34487
  }
34294
34488
  if (!fs.existsSync(absolutePath)) {
34295
- logger_default.warn(`[分包] 分包 ${root} 样式入口 \`${descriptor.source}\` 对应文件不存在,已忽略。`);
34489
+ logger_default.warn(`${options.warningPrefix}样式入口 \`${descriptor.source}\` 对应文件不存在,已忽略。`);
34296
34490
  continue;
34297
34491
  }
34298
34492
  if (!isSupportedSharedStyleExtension(absolutePath)) {
34299
- logger_default.warn(`[分包] 分包 ${root} 样式入口 \`${descriptor.source}\` 当前仅支持以下格式:${SUPPORTED_SHARED_STYLE_EXTENSIONS.join(", ")},已忽略。`);
34493
+ logger_default.warn(`${options.warningPrefix}样式入口 \`${descriptor.source}\` 当前仅支持以下格式:${SUPPORTED_SHARED_STYLE_EXTENSIONS.join(", ")},已忽略。`);
34300
34494
  continue;
34301
34495
  }
34302
34496
  const outputAbsolutePath = changeFileExtension(absolutePath, service.outputExtensions.wxss);
34303
34497
  const outputRelativePath = service.relativeOutputPath(outputAbsolutePath);
34304
34498
  if (!outputRelativePath) {
34305
- logger_default.warn(`[分包] 分包 ${root} 样式入口 \`${descriptor.source}\` 不在项目源码目录内,已忽略。`);
34499
+ logger_default.warn(`${options.warningPrefix}样式入口 \`${descriptor.source}\` 不在项目源码目录内,已忽略。`);
34306
34500
  continue;
34307
34501
  }
34308
34502
  const posixOutput = toPosixPath(outputRelativePath);
34309
34503
  addStyleEntry({
34310
34504
  ...descriptor,
34311
34505
  scope: resolveStyleEntryScope(descriptor, posixOutput, normalizedRoot)
34312
- }, absolutePath, posixOutput, root, normalizedRoot, dedupe, normalized);
34506
+ }, absolutePath, posixOutput, normalizedRoot, options.warningPrefix, dedupe, normalized);
34313
34507
  }
34314
- appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe, normalized);
34508
+ if (options.appendDefaultEntries) appendDefaultScopedStyleEntries(root, normalizedRoot, service, dedupe, normalized);
34315
34509
  return normalized.length ? normalized : void 0;
34316
34510
  }
34511
+ function normalizeSubPackageStyleEntries(styles, subPackage, configService) {
34512
+ const root = subPackage.root?.trim();
34513
+ if (!root) return;
34514
+ return normalizeStyleEntries(styles, root, configService, {
34515
+ warningPrefix: `[分包] 分包 ${root} `,
34516
+ appendDefaultEntries: true
34517
+ });
34518
+ }
34519
+ function normalizeMainPackageStyleEntries(styles, configService) {
34520
+ if (styles === void 0) return;
34521
+ return normalizeStyleEntries(styles, "", configService, {
34522
+ warningPrefix: "[样式] 主包 ",
34523
+ appendDefaultEntries: false
34524
+ });
34525
+ }
34317
34526
  //#endregion
34318
34527
  //#region src/runtime/scanPlugin/subpackages.ts
34319
34528
  function resolveSubPackageEntries(subPackage) {
@@ -34334,6 +34543,7 @@ function loadSubPackages(ctx) {
34334
34543
  if (scanState.isDirty || subPackageMap.size === 0) {
34335
34544
  subPackageMap.clear();
34336
34545
  independentSubPackageMap.clear();
34546
+ scanState.mainPackageStyleEntries = normalizeMainPackageStyleEntries(configService.weappViteConfig?.styles, configService);
34337
34547
  if (scanState.isDirty) independentDirtyRoots.clear();
34338
34548
  if (json) {
34339
34549
  const independentSubPackages = [...json.subPackages ?? [], ...json.subpackages ?? []];
@@ -34392,6 +34602,9 @@ function createScanService(ctx) {
34392
34602
  set pluginJsonPath(value) {
34393
34603
  scanState.pluginJsonPath = value;
34394
34604
  },
34605
+ get mainPackageStyleEntries() {
34606
+ return scanState.mainPackageStyleEntries;
34607
+ },
34395
34608
  subPackageMap,
34396
34609
  independentSubPackageMap,
34397
34610
  async loadAppEntry() {
@@ -34413,6 +34626,7 @@ function createScanService(ctx) {
34413
34626
  markDirty() {
34414
34627
  scanState.isDirty = true;
34415
34628
  scanState.appEntry = void 0;
34629
+ scanState.mainPackageStyleEntries = void 0;
34416
34630
  scanState.pluginJson = void 0;
34417
34631
  scanState.pluginJsonPath = void 0;
34418
34632
  },
@@ -34978,4 +35192,4 @@ async function createCompilerContext(options) {
34978
35192
  return ctx;
34979
35193
  }
34980
35194
  //#endregion
34981
- export { isPathInside as A, findPreloadRuleKey as C, createCjsConfigLoadError as D, parseCommentJson as E, getDefaultIdeProjectRoot as O, collectPreloadPages as S, loadViteConfigFile as T, resolveHmrProfileJsonPath as _, formatBytes as a, checkRuntime as b, getSupportedWeappViteTargetDescriptors as c, getBackendForCapability as d, resolveBackendExecution as f, SHARED_CHUNK_VIRTUAL_PREFIX as g, createSharedBuildConfig as h, setActiveCompilerContextKey as i, shouldPassPlatformArgToIdeOpen as k, isWebPlatform as l, syncManagedTsconfigBootstrapFiles as m, getCompilerContext as n, WEB_PLATFORM_ALIASES as o, syncProjectSupportFiles as p, resetCompilerContext as r, getSupportedWeappVitePlatforms as s, createCompilerContext as t, resolveWeappViteTarget as u, getRouteRuntimeGlobalKeys as v, suggestPreloadRules as w, getProjectConfigFileName as x, resolveWeappConfigFile as y };
35195
+ export { shouldPassPlatformArgToIdeOpen as A, findPreloadRuleKey as C, parseCommentJson as D, loadViteConfigFile as E, createCjsConfigLoadError as O, collectPreloadPages as S, suggestPreloadRules as T, resolveHmrProfileJsonPath as _, formatBytes as a, checkRuntime as b, getSupportedWeappViteTargetDescriptors as c, getBackendForCapability as d, resolveBackendExecution as f, SHARED_CHUNK_VIRTUAL_PREFIX as g, createSharedBuildConfig as h, setActiveCompilerContextKey as i, isPathInside as j, getDefaultIdeProjectRoot as k, isWebPlatform as l, syncManagedTsconfigBootstrapFiles as m, getCompilerContext as n, WEB_PLATFORM_ALIASES as o, syncProjectSupportFiles as p, resetCompilerContext as r, getSupportedWeappVitePlatforms as s, createCompilerContext as t, resolveWeappViteTarget as u, getRouteRuntimeGlobalKeys as v, resolvePreloadPackageIdentifier as w, getProjectConfigFileName as x, resolveWeappConfigFile as y };
@@ -65,6 +65,8 @@ wv mcp init codex
65
65
  wv mcp doctor codex
66
66
  ```
67
67
 
68
+ `wv analyze --preload` 会识别宿主导航 API 与由 `useRouter()` / `createRouter()` 创建的路由 binding,输出静态跨分包跳转证据,并通过不写盘的分析构建按触发包汇总实际体积和 2 MB 预下载额度。它不会把普通对象的同名 `push` / `replace` 当作路由,也不会根据静态可达性自动改写业务配置。
69
+
68
70
  `wv mcp` 既可以启动服务,也可以管理 AI 客户端配置:
69
71
 
70
72
  - `wv mcp init <codex|claude-code|cursor>`:写入客户端配置。
@@ -48,7 +48,7 @@ wv analyze --preload
48
48
  wv analyze --preload --json --output reports/preload.json
49
49
  ```
50
50
 
51
- 该命令只读扫描原生模板、Vue SFC 和路由调用,不会修改源码;动态路由、业务守卫和微信预下载额度仍需人工确认。构建时的显式规则见 `weapp-config.md` 中的 `weapp.routeRules.<pattern>.preload`。
51
+ 该命令只读扫描原生模板、Vue SFC 和可证明来源的路由调用,不会修改源码;同时通过不写盘的分析构建读取实际分包体积,按触发页所属包汇总共享的 2 MB 额度。动态路由、业务守卫和真实访问频率仍需人工确认。构建时的显式规则见 `weapp-config.md` 中的 `weapp.routeRules.<pattern>.preload`。
52
52
 
53
53
  ### Web 预览与构建
54
54
 
@@ -13,7 +13,9 @@ export default defineConfig({
13
13
  })
14
14
  ```
15
15
 
16
- 该入口只编译并执行 SFC script,不渲染模板、WXML、CSS DOM;`app.vue` 和页面组件也不属于测试对象。完整编译产物、WXML 查询、组件树、宿主 mock 和用户交互仍使用 `@mpcore/test`。
16
+ 每次 `mountComponent()` 都会创建独立的 Wevu app context,因此 `global.provide`、插件、mocks、全局属性和卸载状态不会在 wrapper 之间共享。
17
+
18
+ 该入口只编译并执行 SFC script,不渲染模板、WXML、CSS 或 DOM;`app.vue` 和页面组件也不属于测试对象。默认页面判定允许 `pages/**/components/**` 中的普通组件;使用自定义页面目录时,可通过 `wevuSfc({ isPage: filename => boolean })` 提供同步或异步判定。完整编译产物、WXML 查询、组件树、宿主 mock 和用户交互仍使用 `@mpcore/test`。
17
19
 
18
20
  ## 接入
19
21
 
@@ -48,6 +48,22 @@ export default defineConfig({
48
48
 
49
49
  `main` 表示主包,`packages/order` 匹配 `app.json.subPackages[].root`。启用后,产物 `app.json.subPackages` 只保留参与 scope 的分包,`preloadRule`、`tabBar`、`entryPagePath`、自动路由和 typed router 也会按同一注册图裁剪。`preloadRule.packages` 支持分包 `root`、`name` 和主包标记 `__APP__`;`tabBar.list` 不足微信要求的 2 项时会删除整个 `tabBar`。发布前建议再跑不带 scope 的完整构建。
50
50
 
51
+ ### `chunks.preserveModules`
52
+
53
+ 按 `srcRoot` 相对路径匹配源码模块,并为命中的模块保留独立输出文件和目录边界:
54
+
55
+ ```ts
56
+ export default defineConfig({
57
+ weapp: {
58
+ chunks: {
59
+ preserveModules: ['utils/**', 'services/**'],
60
+ },
61
+ },
62
+ })
63
+ ```
64
+
65
+ 例如 `src/utils/request.ts` 会输出到 `utils/request.js`,引用方会保留对该文件的引用;barrel 模块的静态依赖也会保持独立。该配置用于调试定位和产物审计,不保证减少总包体积或提升冷启动;构建会自动选择兼容的 entry signature。
66
+
51
67
  ### 分包异步模块
52
68
 
53
69
  跨分包 JS 使用微信官方 callback 或 Promise API:
@@ -81,6 +97,29 @@ const moduleExport = await import('../../packages/order/modules/price.ts')
81
97
 
82
98
  适合用目录扫描自动注册组件的项目。组件重名时要先解决命名冲突,不要让自动引入规则长期处于歧义状态。
83
99
 
100
+ ### `styles`
101
+
102
+ 用于生成主包独立样式入口,并按规则向主包与普通分包的页面或组件样式注入相对 `@import`,不会把内容合并进 `app.wxss`:
103
+
104
+ ```ts
105
+ export default defineConfig({
106
+ weapp: {
107
+ styles: [
108
+ {
109
+ source: 'styles/theme.scss',
110
+ include: ['pages/**', 'components/**', 'packages/*/**'],
111
+ },
112
+ {
113
+ source: 'styles/manual.less',
114
+ inject: false,
115
+ },
116
+ ],
117
+ },
118
+ })
119
+ ```
120
+
121
+ `inject: false` 只生成目标平台样式文件,适合由源码手动 `@import`。独立分包不能依赖主包资源,不会收到 `weapp.styles` 的自动注入;需要在 `weapp.subPackages.<root>.styles` 中声明分包自己的入口。
122
+
84
123
  ### `routeRules`
85
124
 
86
125
  用于给页面路由追加规则,例如 layout、微信分包预下载等。它属于项目级编排,而不是组件内部语义。
@@ -100,7 +139,7 @@ export default defineConfig({
100
139
  })
101
140
  ```
102
141
 
103
- 微信构建会把 `preload` 合成为 `app.json.preloadRule`;手写的同一路由规则优先,其他平台不会生成微信专属字段。多条 glob 命中时选择具体程度最高的一条。需要检查静态跨分包跳转时,运行 `wv analyze --preload`,它只输出建议,不修改源码。
142
+ 微信构建会把 `preload` 合成为 `app.json.preloadRule`;手写的同一路由规则优先,其他平台不会生成微信专属字段。多条 glob 命中时选择具体程度最高的一条。需要检查静态跨分包跳转时,运行 `wv analyze --preload`;它只输出建议,不修改源码,并按触发页所属包汇总实际分包体积与共享的 2 MB 额度。
104
143
 
105
144
  ### `vue.template.htmlTagToWxml`
106
145
 
@@ -134,7 +134,7 @@ function resolveAutoRoutesMacroImportPath() {
134
134
  }
135
135
  async function resolveAutoRoutesInlineSnapshot() {
136
136
  try {
137
- const { getCompilerContext } = await import("./getInstance-CJAXp9db.mjs");
137
+ const { getCompilerContext } = await import("./getInstance-yJ2CpeL9.mjs");
138
138
  const compilerContext = getCompilerContext();
139
139
  const service = compilerContext.autoRoutesService;
140
140
  const reference = service?.getReference?.();
@@ -0,0 +1,2 @@
1
+ import { t as extractConfigFromVue } from "./file-Byldwig4.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { n as getCompilerContext } from "./createContext-BE57_Xi7.mjs";
2
+ export { getCompilerContext };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $n as WEB_PLATFORM_ALIASES, A as Ref, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Gn as WEAPP_VITE_HOST_NAME, I as RolldownPluginOption, Jn as createWeappViteHostMeta, Kn as WeappViteHostMeta, L as RolldownWatchOptions, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Qn as ResolvedWeappViteTarget, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, Xn as resolveWeappViteHostMeta, Yn as isWeappViteHost, Zn as ResolveWeappViteTargetOptions, _ as definePageJson, a as UserConfigFnNoEnvPlain, ar as WebPlatform, at as WeappViteConfig, c as UserConfigFnPromise, cr as isWebPlatform, d as Component, er as WeappVitePlatform, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, ir as WeappViteTargetKind, j as ResolvedConfig, k as PluginOption, l as defineConfig, lr as resolveWeappViteTarget, m as Theme, n as UserConfigExport, nr as WeappViteTargetDescriptor, o as UserConfigFnObject, or as getSupportedWeappVitePlatforms, p as Sitemap, qn as applyWeappViteHostMeta, r as UserConfigFn, rr as WeappViteTargetInput, s as UserConfigFnObjectPlain, sr as getSupportedWeappViteTargetDescriptors, t as UserConfig, tr as WeappViteRuntime, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-B1H1OqnR.mjs";
1
+ import { $n as isWeappViteHost, A as Ref, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, I as RolldownPluginOption, L as RolldownWatchOptions, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Qn as createWeappViteHostMeta, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, Xn as WeappViteHostMeta, Yn as WEAPP_VITE_HOST_NAME, Zn as applyWeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, ar as WeappViteRuntime, at as WeappViteConfig, c as UserConfigFnPromise, cr as WeappViteTargetKind, d as Component, dr as getSupportedWeappViteTargetDescriptors, er as resolveWeappViteHostMeta, f as Page, fr as isWebPlatform, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, ir as WeappVitePlatform, j as ResolvedConfig, k as PluginOption, l as defineConfig, lr as WebPlatform, m as Theme, n as UserConfigExport, nr as ResolvedWeappViteTarget, o as UserConfigFnObject, or as WeappViteTargetDescriptor, p as Sitemap, pr as resolveWeappViteTarget, r as UserConfigFn, rr as WEB_PLATFORM_ALIASES, s as UserConfigFnObjectPlain, sr as WeappViteTargetInput, t as UserConfig, tr as ResolveWeappViteTargetOptions, u as App, ur as getSupportedWeappVitePlatforms, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-Pi3hdn_g.mjs";
2
2
  import { a as LayoutHostContext, c as LayoutHostResolver, d as unregisterLayoutHosts, f as waitForLayoutHost, i as LayoutHostBridge, l as registerLayoutHosts, m as createWevuComponent, n as defineProps, o as LayoutHostEntry, p as WevuComponentOptions, r as setPageLayout, s as LayoutHostResolveOptions, t as defineEmits, u as resolveLayoutHost } from "./runtime-Ee2HY6gR.mjs";
3
3
  //#region src/createContext.d.ts
4
4
  interface CreateCompilerContextOptions extends Partial<LoadConfigOptions> {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-BL8Dhhk6.mjs";
2
2
  import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost--CaeyWpA.mjs";
3
3
  import { t as defineConfig } from "./config-DRGcCi3h.mjs";
4
- import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-Ryo4nfbU.mjs";
4
+ import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-BE57_Xi7.mjs";
5
5
  import { a as resolveLayoutHost, c as createWevuComponent, i as registerLayoutHosts, n as defineProps, o as unregisterLayoutHosts, r as setPageLayout, s as waitForLayoutHost, t as defineEmits } from "./runtime-D6VCNhNY.mjs";
6
6
  export { WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, registerLayoutHosts, resolveLayoutHost, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
package/dist/json.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-B1H1OqnR.mjs";
1
+ import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-Pi3hdn_g.mjs";
2
2
  export { type App, type Component, type Page, type Sitemap, type Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Et as WeappMcpConfig } from "./config-B1H1OqnR.mjs";
1
+ import { Et as WeappMcpConfig } from "./config-Pi3hdn_g.mjs";
2
2
  import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
3
3
  //#region src/mcp.d.ts
4
4
  interface ResolvedWeappMcpConfig {
package/dist/test.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createCompilerContext } from "./createContext-Ryo4nfbU.mjs";
1
+ import { t as createCompilerContext } from "./createContext-BE57_Xi7.mjs";
2
2
  import path from "node:path";
3
3
  import process from "node:process";
4
4
  import chokidar from "chokidar";
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { f as Resolver } from "./index-CaXAtb9e.mjs";
2
2
  import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-C7fCmf92.mjs";
3
- import { $ as WeappAnalyzeBudgetConfig, $t as GenerateFilenamesOptions, A as Ref, An as SubPackageStyleEntry, At as WeappReactCompilerConfig, B as BindingErrorLike, Bn as WeappManagedNodeTsconfigConfig, Bt as WeappWevuConfig, Cn as SharedChunkDynamicImports, Ct as WeappInjectWeapiConfig, D as MethodDefinitions, Dn as SubPackage, Dt as WeappNpmConfig, E as InlineConfig, En as SharedChunkStrategy, Et as WeappMcpConfig, F as RolldownPlugin, Fn as WeappLibEntryContext, Ft as WeappSubPackageConfig, G as EntryJsonFragment, Gt as BuildNpmPackageMeta, H as BaseEntry, Hn as WeappManagedSharedTsconfigConfig, Ht as Alias, I as RolldownPluginOption, In as WeappLibFileName, It as WeappUniAppConfig, J as ScanComponentItem, Jt as CopyOptions, K as PageEntry, Kn as WeappViteHostMeta, Kt as ChunksConfig, L as RolldownWatchOptions, Ln as WeappLibInternalDtsOptions, Lt as WeappVueConfig, M as RolldownBuild, Mn as WeappLibComponentJson, Mt as WeappRequestRuntimeConfig, N as RolldownOptions, Nn as WeappLibConfig, Nt as WeappRouteRule, O as Plugin, On as SubPackageStyleConfigEntry, Ot as WeappPreloadNetwork, P as RolldownOutput, Pn as WeappLibDtsOptions, Pt as WeappRouteRules, Q as UserConfig, Qt as GenerateFileType, R as RolldownWatcher, Rn as WeappLibVueTscOptions, Rt as WeappVueTemplateConfig, Sn as ResolvedAlias, St as WeappInjectRequestGlobalsTarget, T as ConfigEnv, Tn as SharedChunkOverride, Tt as WeappInjectWebRuntimeGlobalsTarget, U as ComponentEntry, Un as WeappManagedTypeScriptConfig, Ut as AliasOptions, V as AppEntry, Vn as WeappManagedServerTsconfigConfig, Vt as WeappWorkerConfig, W as Entry, Wn as WeappWebConfig, Wt as AlipayNpmMode, X as ProjectConfig, Xt as GenerateDirsOptions, Y as WxmlDep, Yt as DeprecatedInlineDynamicImports, Z as SubPackageMetaValue, Zt as GenerateExtensionsOptions, _n as NpmDependencyPattern, _t as WeappAutoRoutesIncludePattern, an as GenerateTemplateFileSource, at as WeappViteConfig, b as ChangeEvent, bn as NpmStrategy, bt as WeappHmrConfig, cn as GenerateTemplatesConfig, ct as EnhanceOptions, dn as JsonMergeContext, dt as MultiPlatformConfig, en as GenerateOptions, et as WeappAnalyzeConfig, fn as JsonMergeFunction, ft as ScanWxmlOptions, gn as NpmBuildOptions, gt as WeappAutoRoutesInclude, hn as MpPlatform, ht as WeappAutoRoutesConfig, in as GenerateTemplateFactory, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as SubPackageStyleScope, jt as WeappReactConfig, k as PluginOption, kn as SubPackageStyleConfigObject, kt as WeappPreloadRule, ln as JsFormat, lt as EnhanceWxmlOptions, mn as JsonMergeStrategy, mt as WeappAppPreludeMode, nn as GenerateTemplateContext, nt as WeappDebugConfig, on as GenerateTemplateInlineSource, ot as AutoImportComponents, pn as JsonMergeStage, pt as WeappAppPreludeConfig, q as ComponentsMap, qt as CopyGlobs, rn as GenerateTemplateEntry, rt as WeappForwardConsoleConfig, sn as GenerateTemplateScope, st as AutoImportComponentsOption, tn as GenerateTemplate, tr as WeappViteRuntime, tt as WeappAnalyzeHistoryConfig, un as JsonConfig, ut as HandleWxmlOptions, vn as NpmMainPackageConfig, vt as WeappBuildScopeConfig, w as ComputedDefinitions, wn as SharedChunkMode, wt as WeappInjectWebRuntimeGlobalsConfig, x as WeappVitePluginApi, xn as NpmSubPackageConfig, xt as WeappInjectRequestGlobalsConfig, yn as NpmPluginPackageConfig, yt as WeappBuildScopeObjectConfig, z as ViteDevServer, zn as WeappManagedAppTsconfigConfig, zt as WeappWebRuntimeConfig } from "./config-B1H1OqnR.mjs";
4
- export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, type ComputedDefinitions, type ConfigEnv, CopyGlobs, CopyOptions, DeprecatedInlineDynamicImports, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, type InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, type MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, type Plugin, type PluginOption, ProjectConfig, type Ref, ResolvedAlias, type ResolvedConfig, type Resolver, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, type ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappBuildScopeConfig, WeappBuildScopeObjectConfig, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappPreloadNetwork, WeappPreloadRule, WeappReactCompilerConfig, WeappReactConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappUniAppConfig, WeappViteConfig, type WeappViteHostMeta, WeappVitePluginApi, type WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
3
+ import { $ as WeappAnalyzeBudgetConfig, $t as GenerateFilenamesOptions, A as Ref, An as StyleScope, At as WeappReactCompilerConfig, B as BindingErrorLike, Bn as WeappLibFileName, Bt as WeappWevuConfig, Cn as SharedChunkDynamicImports, Ct as WeappInjectWeapiConfig, D as MethodDefinitions, Dn as StyleConfigEntry, Dt as WeappNpmConfig, E as InlineConfig, En as SharedChunkStrategy, Et as WeappMcpConfig, F as RolldownPlugin, Fn as SubPackageStyleScope, Ft as WeappSubPackageConfig, G as EntryJsonFragment, Gn as WeappManagedServerTsconfigConfig, Gt as BuildNpmPackageMeta, H as BaseEntry, Hn as WeappLibVueTscOptions, Ht as Alias, I as RolldownPluginOption, In as WeappLibComponentJson, It as WeappUniAppConfig, J as ScanComponentItem, Jn as WeappWebConfig, Jt as CopyOptions, K as PageEntry, Kn as WeappManagedSharedTsconfigConfig, Kt as ChunksConfig, L as RolldownWatchOptions, Ln as WeappLibConfig, Lt as WeappVueConfig, M as RolldownBuild, Mn as SubPackageStyleConfigEntry, Mt as WeappRequestRuntimeConfig, N as RolldownOptions, Nn as SubPackageStyleConfigObject, Nt as WeappRouteRule, O as Plugin, On as StyleConfigObject, Ot as WeappPreloadNetwork, P as RolldownOutput, Pn as SubPackageStyleEntry, Pt as WeappRouteRules, Q as UserConfig, Qt as GenerateFileType, R as RolldownWatcher, Rn as WeappLibDtsOptions, Rt as WeappVueTemplateConfig, Sn as ResolvedAlias, St as WeappInjectRequestGlobalsTarget, T as ConfigEnv, Tn as SharedChunkOverride, Tt as WeappInjectWebRuntimeGlobalsTarget, U as ComponentEntry, Un as WeappManagedAppTsconfigConfig, Ut as AliasOptions, V as AppEntry, Vn as WeappLibInternalDtsOptions, Vt as WeappWorkerConfig, W as Entry, Wn as WeappManagedNodeTsconfigConfig, Wt as AlipayNpmMode, X as ProjectConfig, Xn as WeappViteHostMeta, Xt as GenerateDirsOptions, Y as WxmlDep, Yt as DeprecatedInlineDynamicImports, Z as SubPackageMetaValue, Zt as GenerateExtensionsOptions, _n as NpmDependencyPattern, _t as WeappAutoRoutesIncludePattern, an as GenerateTemplateFileSource, ar as WeappViteRuntime, at as WeappViteConfig, b as ChangeEvent, bn as NpmStrategy, bt as WeappHmrConfig, cn as GenerateTemplatesConfig, ct as EnhanceOptions, dn as JsonMergeContext, dt as MultiPlatformConfig, en as GenerateOptions, et as WeappAnalyzeConfig, fn as JsonMergeFunction, ft as ScanWxmlOptions, gn as NpmBuildOptions, gt as WeappAutoRoutesInclude, hn as MpPlatform, ht as WeappAutoRoutesConfig, in as GenerateTemplateFactory, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as SubPackage, jt as WeappReactConfig, k as PluginOption, kn as StyleEntry, kt as WeappPreloadRule, ln as JsFormat, lt as EnhanceWxmlOptions, mn as JsonMergeStrategy, mt as WeappAppPreludeMode, nn as GenerateTemplateContext, nt as WeappDebugConfig, on as GenerateTemplateInlineSource, ot as AutoImportComponents, pn as JsonMergeStage, pt as WeappAppPreludeConfig, q as ComponentsMap, qn as WeappManagedTypeScriptConfig, qt as CopyGlobs, rn as GenerateTemplateEntry, rt as WeappForwardConsoleConfig, sn as GenerateTemplateScope, st as AutoImportComponentsOption, tn as GenerateTemplate, tt as WeappAnalyzeHistoryConfig, un as JsonConfig, ut as HandleWxmlOptions, vn as NpmMainPackageConfig, vt as WeappBuildScopeConfig, w as ComputedDefinitions, wn as SharedChunkMode, wt as WeappInjectWebRuntimeGlobalsConfig, x as WeappVitePluginApi, xn as NpmSubPackageConfig, xt as WeappInjectRequestGlobalsConfig, yn as NpmPluginPackageConfig, yt as WeappBuildScopeObjectConfig, z as ViteDevServer, zn as WeappLibEntryContext, zt as WeappWebRuntimeConfig } from "./config-Pi3hdn_g.mjs";
4
+ export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, type ComputedDefinitions, type ConfigEnv, CopyGlobs, CopyOptions, DeprecatedInlineDynamicImports, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, type InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, type MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, type Plugin, type PluginOption, ProjectConfig, type Ref, ResolvedAlias, type ResolvedConfig, type Resolver, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, StyleConfigEntry, StyleConfigObject, StyleEntry, StyleScope, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, type ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappBuildScopeConfig, WeappBuildScopeObjectConfig, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappPreloadNetwork, WeappPreloadRule, WeappReactCompilerConfig, WeappReactConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappUniAppConfig, WeappViteConfig, type WeappViteHostMeta, WeappVitePluginApi, type WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.20.5",
4
+ "version": "6.21.0",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -103,7 +103,7 @@
103
103
  "@jridgewell/remapping": "^2.3.5",
104
104
  "@vercel/detect-agent": "^1.2.5",
105
105
  "@volar/typescript": "^2.4.28",
106
- "@vue/language-core": "^3.3.10",
106
+ "@vue/language-core": "^3.3.11",
107
107
  "cac": "^7.0.0",
108
108
  "chokidar": "^5.0.0",
109
109
  "comment-json": "^5.0.0",
@@ -126,23 +126,23 @@
126
126
  "vite": "8.2.2",
127
127
  "vite-tsconfig-paths": "^6.1.1",
128
128
  "vue": "^3.5.41",
129
- "vue-tsc": "^3.3.10",
129
+ "vue-tsc": "^3.3.11",
130
130
  "@weapp-core/init": "6.0.14",
131
131
  "@weapp-core/schematics": "6.1.0",
132
132
  "@weapp-core/logger": "3.1.1",
133
+ "@weapp-vite/ast": "6.21.0",
133
134
  "@weapp-core/shared": "3.1.1",
134
135
  "@weapp-vite/mcp": "1.4.15",
135
136
  "@weapp-vite/miniprogram-automator": "1.2.14",
137
+ "@weapp-vite/web": "1.4.11",
138
+ "@wevu/api": "0.2.16",
136
139
  "@weapp-vite/volar": "2.1.3",
137
140
  "@weapp-core/constants": "0.1.17",
138
141
  "@wevu/web-apis": "1.2.34",
139
- "@weapp-vite/web": "1.4.10",
140
- "@weapp-vite/ast": "6.20.5",
141
- "@wevu/api": "0.2.16",
142
- "rolldown-require": "2.0.26",
143
142
  "weapp-ide-cli": "6.0.7",
143
+ "rolldown-require": "2.0.26",
144
144
  "vite-plugin-performance": "2.0.1",
145
- "wevu": "6.20.5"
145
+ "wevu": "6.21.0"
146
146
  },
147
147
  "publishConfig": {
148
148
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-CWbsTVPm.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { n as getCompilerContext } from "./createContext-Ryo4nfbU.mjs";
2
- export { getCompilerContext };