weapp-vite 6.17.7 → 6.17.8

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 { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-DooWF5Wk.mjs";
1
+ import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-C2Rk_kcI.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 { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, a as formatBytes, b as getProjectConfigFileName, d as syncProjectSupportFiles, f as syncManagedTsconfigBootstrapFiles, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, p as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappViteTarget, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-DooWF5Wk.mjs";
1
+ import { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, a as formatBytes, b as getProjectConfigFileName, d as syncProjectSupportFiles, f as syncManagedTsconfigBootstrapFiles, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, p as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappViteTarget, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-C2Rk_kcI.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
3
- import { h as VERSION } from "./file-2ZpSECMP.mjs";
3
+ import { h as VERSION } from "./file-CuTGX59g.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 path, { posix } from "pathe";
@@ -4122,7 +4122,7 @@ function resolveRunnableHotkeyDefinition(input) {
4122
4122
  }
4123
4123
  //#endregion
4124
4124
  //#region package.json
4125
- var version = "6.17.7";
4125
+ var version = "6.17.8";
4126
4126
  //#endregion
4127
4127
  //#region src/cli/devHotkeys/format.ts
4128
4128
  const FULLWIDTH_ASCII_START = 65281;
@@ -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 { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, 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 supportedCssLangs, y as templateExtensions } from "./file-2ZpSECMP.mjs";
3
+ import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, 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 supportedCssLangs, y as templateExtensions } from "./file-CuTGX59g.mjs";
4
4
  import { createRequire, isBuiltin } from "node:module";
5
5
  import path, { posix } from "pathe";
6
6
  import path$1, { normalize, relative, win32 } from "node:path";
@@ -10458,6 +10458,19 @@ const REG_REQUEST_GLOBAL_RUNTIME_VENDOR_ID = /(?:^|[/\\])(?:@wevu[/\\]web-apis|w
10458
10458
  const REG_WEAPP_VITE_RUNTIME_VENDOR_ID = /(?:^|[/\\])weapp-vite[/\\](?:dist[/\\]runtime\.mjs|src[/\\]plugins[/\\]vue[/\\]runtime\.ts)(?:$|[?#])/;
10459
10459
  const REG_HASHED_DIST_CHUNK_ID = /(?:^|[/\\])dist[/\\](?:dev[/\\])?([^/\\-]+)-([\w-]{6,})\.(?:m?js|cjs)(?:$|[?#])/;
10460
10460
  const STABLE_HASHED_DIST_CHUNK_PRIORITY = ["src"];
10461
+ const STABLE_HASHED_DIST_CHUNK_PRIORITY_BY_PACKAGE = { wevu: [
10462
+ "index",
10463
+ "internal-runtime",
10464
+ "watch",
10465
+ "templateRef",
10466
+ "router",
10467
+ "base",
10468
+ "computed",
10469
+ "toRefs",
10470
+ "store",
10471
+ "template",
10472
+ "ref"
10473
+ ] };
10461
10474
  function resolveSharedPathRoot(configService, sharedPathRoot) {
10462
10475
  const absoluteSrcRoot = configService.absoluteSrcRoot;
10463
10476
  const configuredRoot = sharedPathRoot ? path.resolve(configService.cwd, sharedPathRoot) : absoluteSrcRoot;
@@ -10593,6 +10606,19 @@ function resolveStableHashedDistChunkFileName(chunk) {
10593
10606
  matchedChunks.push(matchedChunk);
10594
10607
  if (id === chunk.facadeModuleId) facadeMatchedChunk = matchedChunk;
10595
10608
  }
10609
+ const packageTokens = /* @__PURE__ */ new Set();
10610
+ for (const { fileName } of matchedChunks) {
10611
+ const fileNameBase = fileName.replace(/^weapp-vendors\//, "").replace(/\.js$/, "");
10612
+ const packageToken = Object.keys(STABLE_HASHED_DIST_CHUNK_PRIORITY_BY_PACKAGE).find((token) => fileNameBase.startsWith(`${token}-`));
10613
+ if (packageToken) packageTokens.add(packageToken);
10614
+ }
10615
+ for (const packageToken of packageTokens) {
10616
+ const priorityBaseNames = STABLE_HASHED_DIST_CHUNK_PRIORITY_BY_PACKAGE[packageToken];
10617
+ for (const priorityBaseName of priorityBaseNames) {
10618
+ const matched = matchedChunks.find((chunk) => chunk.fileName === `weapp-vendors/${packageToken}-${priorityBaseName}.js`);
10619
+ if (matched) return matched.fileName;
10620
+ }
10621
+ }
10596
10622
  if (facadeMatchedChunk) return facadeMatchedChunk.fileName;
10597
10623
  for (const priorityBaseName of STABLE_HASHED_DIST_CHUNK_PRIORITY) {
10598
10624
  const matched = matchedChunks.find((chunk) => chunk.baseName === priorityBaseName);
@@ -13358,6 +13384,7 @@ const PACKAGE_ALIASES = [
13358
13384
  packageName: "wevu",
13359
13385
  distEntry: "dist/internal-runtime.mjs",
13360
13386
  devDistEntry: "dist/dev/internal-runtime.mjs",
13387
+ devWorkspaceEntry: "src/internal-runtime.ts",
13361
13388
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13362
13389
  },
13363
13390
  {
@@ -13365,6 +13392,7 @@ const PACKAGE_ALIASES = [
13365
13392
  packageName: "wevu",
13366
13393
  distEntry: "dist/internal-reactivity.mjs",
13367
13394
  devDistEntry: "dist/dev/internal-reactivity.mjs",
13395
+ devWorkspaceEntry: "src/internal-reactivity.ts",
13368
13396
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13369
13397
  },
13370
13398
  {
@@ -13372,6 +13400,7 @@ const PACKAGE_ALIASES = [
13372
13400
  packageName: "wevu",
13373
13401
  distEntry: "dist/internal-template.mjs",
13374
13402
  devDistEntry: "dist/dev/internal-template.mjs",
13403
+ devWorkspaceEntry: "src/internal-template.ts",
13375
13404
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13376
13405
  },
13377
13406
  {
@@ -13424,11 +13453,11 @@ const PACKAGE_ALIASES = [
13424
13453
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13425
13454
  }
13426
13455
  ];
13427
- function resolveWevuRuntimeDistEntry(target, options) {
13428
- if (!target.devDistEntry || target.packageName !== "wevu") return target.distEntry;
13456
+ function resolveWevuRuntimeDistEntries(target, options) {
13457
+ if (!target.devDistEntry || target.packageName !== "wevu") return [target.distEntry];
13429
13458
  const mode = options.wevuRuntime ?? "auto";
13430
- if (mode === "dev" || mode === "auto" && options.isDev) return target.devDistEntry;
13431
- return target.distEntry;
13459
+ if (mode === "dev" || mode === "auto" && options.isDev) return [target.devWorkspaceEntry, target.devDistEntry].filter((entry) => Boolean(entry));
13460
+ return [target.distEntry];
13432
13461
  }
13433
13462
  function resolveRepoRoot(fromDir) {
13434
13463
  let currentDir = fromDir;
@@ -13439,23 +13468,25 @@ function resolveRepoRoot(fromDir) {
13439
13468
  currentDir = parentDir;
13440
13469
  }
13441
13470
  }
13442
- function resolvePackageEntry(packageName, distEntry, fallbackWorkspacePackagePath) {
13471
+ function resolvePackageEntry(packageName, distEntries, fallbackWorkspacePackagePath) {
13443
13472
  const packageInfo = safeGetPackageInfoSync(packageName);
13444
- if (packageInfo) {
13473
+ if (packageInfo) for (const distEntry of distEntries) {
13445
13474
  const resolvedEntry = path.resolve(packageInfo.rootPath, distEntry);
13446
13475
  if (existsSync(resolvedEntry)) return resolvedEntry;
13447
13476
  }
13448
13477
  if (!fallbackWorkspacePackagePath) return;
13449
13478
  const repoRoot = resolveRepoRoot(path.dirname(fileURLToPath(import.meta.url)));
13450
13479
  if (!repoRoot) return;
13451
- const fallbackEntry = path.resolve(repoRoot, fallbackWorkspacePackagePath, distEntry);
13452
- if (existsSync(fallbackEntry)) return fallbackEntry;
13480
+ for (const distEntry of distEntries) {
13481
+ const fallbackEntry = path.resolve(repoRoot, fallbackWorkspacePackagePath, distEntry);
13482
+ if (existsSync(fallbackEntry)) return fallbackEntry;
13483
+ }
13453
13484
  }
13454
13485
  function resolveBuiltinPackageAliases(options = {}) {
13455
13486
  const aliases = [];
13456
13487
  for (const target of PACKAGE_ALIASES) {
13457
13488
  const { find, packageName, fallbackWorkspacePackagePath } = target;
13458
- const resolvedEntry = resolvePackageEntry(packageName, resolveWevuRuntimeDistEntry(target, options), fallbackWorkspacePackagePath);
13489
+ const resolvedEntry = resolvePackageEntry(packageName, resolveWevuRuntimeDistEntries(target, options), fallbackWorkspacePackagePath);
13459
13490
  if (!resolvedEntry) continue;
13460
13491
  aliases.push({
13461
13492
  find,
@@ -15628,6 +15659,24 @@ function resolveAutoRoutesHotUpdateAction(command, options) {
15628
15659
  };
15629
15660
  }
15630
15661
  //#endregion
15662
+ //#region src/plugins/core/lifecycle/autoRoutesTopology.ts
15663
+ /**
15664
+ * 标记 app 入口依赖的 auto-routes 拓扑已变化。
15665
+ */
15666
+ function markAppEntryForAutoRoutesTopology(ctx, options) {
15667
+ const appEntryId = ctx.scanService?.appEntry?.path ? normalizeFsResolvedId(ctx.scanService.appEntry.path) : void 0;
15668
+ if (appEntryId) invalidateFileCache(appEntryId);
15669
+ invalidateFileCache("weapp-vite/auto-routes");
15670
+ invalidateFileCache("virtual:weapp-vite-auto-routes");
15671
+ invalidateFileCache("\0weapp-vite:auto-routes");
15672
+ for (const target of resolveAutoRoutesAliasTargets(ctx.configService?.packageInfo?.rootPath)) invalidateFileCache(normalizeFsResolvedId(target));
15673
+ options.loadEntry?.invalidateResolveCache?.();
15674
+ ctx.runtimeState.build.hmr.appEntryAutoRoutesSignature = void 0;
15675
+ if (!appEntryId || !options.resolvedEntryMap.has(appEntryId)) return false;
15676
+ options.markEntryDirty(appEntryId, "direct");
15677
+ return true;
15678
+ }
15679
+ //#endregion
15631
15680
  //#region src/plugins/autoRoutes.ts
15632
15681
  /**
15633
15682
  * 路由文件监听器的唯一标识,用于在 sidecarWatcherMap 中注册。
@@ -15636,7 +15685,9 @@ const ROUTE_WATCHER_KEY = "__auto-routes-vue-watcher__";
15636
15685
  function createAutoRoutesPlugin(ctx) {
15637
15686
  const service = ctx.autoRoutesService;
15638
15687
  let resolvedConfig;
15688
+ let devServer;
15639
15689
  const autoRoutesAliasTargets = /* @__PURE__ */ new Set();
15690
+ const autoRoutesTopologyDirtyEntries = /* @__PURE__ */ new Set();
15640
15691
  let routeWatcherStarted = false;
15641
15692
  const refreshAutoRoutesAliasTargets = () => {
15642
15693
  autoRoutesAliasTargets.clear();
@@ -15666,6 +15717,44 @@ function createAutoRoutesPlugin(ctx) {
15666
15717
  * 统一回收,不在 closeBundle 中销毁(build watch 模式下 closeBundle 每次
15667
15718
  * 重编译都会触发,提前销毁会导致后续文件变更无法感知)。
15668
15719
  */
15720
+ function invalidateAutoRoutesVirtualModule() {
15721
+ const virtualModule = devServer?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_ID);
15722
+ if (!virtualModule || !devServer) return;
15723
+ const seen = /* @__PURE__ */ new Set();
15724
+ const invalidateModuleWithImporters = (module) => {
15725
+ if (seen.has(module)) return;
15726
+ seen.add(module);
15727
+ devServer.moduleGraph.invalidateModule(module);
15728
+ for (const importer of module.importers) invalidateModuleWithImporters(importer);
15729
+ };
15730
+ invalidateModuleWithImporters(virtualModule);
15731
+ }
15732
+ function markAutoRoutesTopologyDirty() {
15733
+ return markAppEntryForAutoRoutesTopology(ctx, {
15734
+ resolvedEntryMap: ctx.runtimeState.build.hmr.resolvedEntryMap,
15735
+ markEntryDirty(entryId) {
15736
+ const hmr = ctx.runtimeState.build.hmr;
15737
+ autoRoutesTopologyDirtyEntries.add(entryId);
15738
+ hmr.dirtyEntrySet.add(entryId);
15739
+ hmr.dirtyEntryReasons.set(entryId, "direct");
15740
+ hmr.loadedEntrySet.delete(entryId);
15741
+ hmr.dirtyVueEntryIds ??= /* @__PURE__ */ new Set();
15742
+ hmr.dirtyVueEntryIds.add(entryId);
15743
+ }
15744
+ });
15745
+ }
15746
+ function notifyAppEntryChange() {
15747
+ const appEntryPath = ctx.scanService?.appEntry?.path;
15748
+ if (!appEntryPath || !devServer) return;
15749
+ devServer.watcher.emit("change", appEntryPath);
15750
+ }
15751
+ async function handleRouteStructureChange(filePath, event) {
15752
+ if (await service.handleFileChange(filePath, event)) {
15753
+ invalidateAutoRoutesVirtualModule();
15754
+ markAutoRoutesTopologyDirty();
15755
+ notifyAppEntryChange();
15756
+ }
15757
+ }
15669
15758
  function startRouteFileWatcher() {
15670
15759
  const configService = ctx.configService;
15671
15760
  if (!configService) return;
@@ -15691,12 +15780,12 @@ function createAutoRoutesPlugin(ctx) {
15691
15780
  watcher.on("add", (filePath) => {
15692
15781
  if (!isAutoRoutesWatchFile(filePath, allowedExtensions, isPagesRelatedPath)) return;
15693
15782
  logger_default.info(`[auto-routes:watch] 新增路由文件 ${configService.relativeCwd(filePath)}`);
15694
- service.handleFileChange(filePath, "create");
15783
+ handleRouteStructureChange(filePath, "create");
15695
15784
  });
15696
15785
  watcher.on("unlink", (filePath) => {
15697
15786
  if (!isAutoRoutesWatchFile(filePath, allowedExtensions, isPagesRelatedPath)) return;
15698
15787
  logger_default.info(`[auto-routes:watch] 删除路由文件 ${configService.relativeCwd(filePath)}`);
15699
- service.handleFileChange(filePath, "delete");
15788
+ handleRouteStructureChange(filePath, "delete");
15700
15789
  });
15701
15790
  const { sidecarWatcherMap } = ctx.runtimeState.watcher;
15702
15791
  sidecarWatcherMap.set(ROUTE_WATCHER_KEY, createAutoRoutesSidecarWatcher(watcher));
@@ -15709,6 +15798,9 @@ function createAutoRoutesPlugin(ctx) {
15709
15798
  resolvedConfig = config;
15710
15799
  refreshAutoRoutesAliasTargets();
15711
15800
  },
15801
+ configureServer(server) {
15802
+ devServer = server;
15803
+ },
15712
15804
  buildStart() {
15713
15805
  refreshAutoRoutesAliasTargets();
15714
15806
  startRouteFileWatcher();
@@ -15729,6 +15821,9 @@ function createAutoRoutesPlugin(ctx) {
15729
15821
  map: { mappings: "" }
15730
15822
  };
15731
15823
  },
15824
+ shouldTransformCachedModule({ id }) {
15825
+ return autoRoutesTopologyDirtyEntries.delete(id) || void 0;
15826
+ },
15732
15827
  async watchChange(id, change) {
15733
15828
  const event = change?.event;
15734
15829
  if (service.isRouteFile(id)) {
@@ -19843,6 +19938,7 @@ function injectRequestGlobalsIntoSfc(source, targets, options) {
19843
19938
  //#endregion
19844
19939
  //#region src/plugins/outputFinalizer.ts
19845
19940
  const PREPROCESSOR_STYLE_ASSET_RE = /\.(?:less|sass|scss|styl|stylus|pcss|postcss|sss)$/i;
19941
+ const TEMPLATE_ASSET_RE = /\.(?:wxml|axml|swan|ttml|jxml|qml|ksml|xhsml)$/i;
19846
19942
  function outputSourceToString(output) {
19847
19943
  if (output.type === "chunk") return output.code;
19848
19944
  const source = output.source;
@@ -19871,6 +19967,20 @@ function normalizePreprocessorStyleAssets(bundle, styleExtension, emitAsset) {
19871
19967
  });
19872
19968
  }
19873
19969
  }
19970
+ function normalizeTemplateAssets(ctx, bundle) {
19971
+ const { configService } = ctx;
19972
+ for (const output of Object.values(bundle)) {
19973
+ if (output?.type !== "asset" || !TEMPLATE_ASSET_RE.test(output.fileName)) continue;
19974
+ const source = output.source;
19975
+ const code = typeof source === "string" ? source : source instanceof Uint8Array ? Buffer.from(source).toString("utf8") : void 0;
19976
+ if (code === void 0) continue;
19977
+ const result = handleWxml(scanWxml(code, { platform: configService?.platform }), {
19978
+ scriptModuleExtension: configService?.outputExtensions?.wxs,
19979
+ templateExtension: configService?.outputExtensions?.wxml
19980
+ });
19981
+ if (result.code !== code) output.source = result.code;
19982
+ }
19983
+ }
19874
19984
  function pruneUneventedDevHmrChunks(ctx, bundle) {
19875
19985
  const emittedChunkFileNames = ctx.runtimeState?.build?.hmr?.lastEmittedChunkFileNames;
19876
19986
  if (!ctx.configService?.isDev || ctx.runtimeState?.build?.hmr?.profile?.event === void 0 || !emittedChunkFileNames?.size) return;
@@ -19921,6 +20031,7 @@ function createOutputFinalizerPlugin(ctx) {
19921
20031
  rewriteWevuInternalRuntimeImports(bundle, wevuRuntimeRewriteOptions);
19922
20032
  stabilizeWevuRuntimeChunkAccess(bundle);
19923
20033
  normalizePreprocessorStyleAssets(bundle, ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
20034
+ normalizeTemplateAssets(ctx, bundle);
19924
20035
  pruneUnchangedDevHmrOutputs(ctx, bundle, wevuRuntimeRewriteOptions);
19925
20036
  }
19926
20037
  };
@@ -22250,12 +22361,6 @@ function isAutoRoutesPagesRelatedChange(state, normalizedId) {
22250
22361
  subPackageRoots
22251
22362
  });
22252
22363
  }
22253
- function invalidateAutoRoutesModuleCache(state) {
22254
- invalidateFileCache("weapp-vite/auto-routes");
22255
- invalidateFileCache("virtual:weapp-vite-auto-routes");
22256
- invalidateFileCache("\0weapp-vite:auto-routes");
22257
- for (const target of resolveAutoRoutesAliasTargets(state.ctx.configService?.packageInfo?.rootPath)) invalidateFileCache(normalizeFsResolvedId(target));
22258
- }
22259
22364
  function isConfigFileDependencyChange(state, normalizedId) {
22260
22365
  return state.ctx.configService.configFileDependencies.some((dependency) => normalizeFsResolvedId(dependency) === normalizedId);
22261
22366
  }
@@ -22414,15 +22519,12 @@ async function processChangedFile(state, id, event) {
22414
22519
  }
22415
22520
  return false;
22416
22521
  };
22417
- const markAppEntryForAutoRoutesTopology = () => {
22418
- const appEntryId = scanService.appEntry?.path ? normalizeFsResolvedId(scanService.appEntry.path) : void 0;
22419
- if (!appEntryId || !resolvedEntryMap.has(appEntryId)) return false;
22420
- invalidateFileCache(appEntryId);
22421
- invalidateAutoRoutesModuleCache(state);
22422
- loadEntry?.invalidateResolveCache?.();
22423
- ctx.runtimeState.build.hmr.appEntryAutoRoutesSignature = void 0;
22424
- markEntryDirtyWithCause(appEntryId, "direct", "auto-routes-topology");
22425
- return true;
22522
+ const markAppEntryForAutoRoutesTopology$1 = () => {
22523
+ return markAppEntryForAutoRoutesTopology(ctx, {
22524
+ loadEntry,
22525
+ resolvedEntryMap,
22526
+ markEntryDirty: (entryId) => markEntryDirtyWithCause(entryId, "direct", "auto-routes-topology")
22527
+ });
22426
22528
  };
22427
22529
  const addCssImporterEntries = async (startId) => {
22428
22530
  const { importers, scripts } = await collectAffectedScriptsAndImporters(ctx, startId);
@@ -22438,12 +22540,12 @@ async function processChangedFile(state, id, event) {
22438
22540
  ctx.runtimeState.build.hmr.vueEntryScriptSignatures.delete(normalizedId);
22439
22541
  }
22440
22542
  if ((event === "create" || isDeletedMissingSelf) && isAutoRouteFile) {
22441
- if (await ctx.autoRoutesService?.handleFileChange(normalizedId, event)) markAppEntryForAutoRoutesTopology();
22543
+ if (await ctx.autoRoutesService?.handleFileChange(normalizedId, event)) markAppEntryForAutoRoutesTopology$1();
22442
22544
  } else if ((event === "create" || isDeletedMissingSelf) && isAutoRoutesPagesRelatedChange(state, normalizedId)) {
22443
22545
  const didChangeRoutes = await ctx.autoRoutesService?.handleFileChange(normalizedId, event === "create" ? "create" : "delete");
22444
22546
  const currentSignature = ctx.autoRoutesService?.getSignature?.();
22445
22547
  const appEntrySignature = ctx.runtimeState.build.hmr.appEntryAutoRoutesSignature;
22446
- if (didChangeRoutes || typeof currentSignature === "string" && typeof appEntrySignature === "string" && currentSignature !== appEntrySignature) markAppEntryForAutoRoutesTopology();
22548
+ if (didChangeRoutes || typeof currentSignature === "string" && typeof appEntrySignature === "string" && currentSignature !== appEntrySignature) markAppEntryForAutoRoutesTopology$1();
22447
22549
  }
22448
22550
  if (event === "update" && isAppVueFile(normalizedId) && resolvedEntryMap.size) {
22449
22551
  const isJsonOnlyVueEntryUpdate = await isVueEntryJsonOnlyUpdate(state, normalizedId);
@@ -24282,6 +24384,13 @@ async function compileAndFinalizeVueLikeFile(options) {
24282
24384
  isApp: options.isApp
24283
24385
  });
24284
24386
  }
24387
+ function takeDirtyVueEntryId(dirtyVueEntryIds, filename) {
24388
+ if (!dirtyVueEntryIds?.size) return;
24389
+ const normalizedFilename = normalizeFsResolvedId(filename);
24390
+ if (dirtyVueEntryIds.has(filename)) return filename;
24391
+ if (dirtyVueEntryIds.has(normalizedFilename)) return normalizedFilename;
24392
+ for (const entryId of dirtyVueEntryIds) if (normalizeFsResolvedId(entryId) === normalizedFilename) return entryId;
24393
+ }
24285
24394
  async function refreshCompiledVueEntryCacheInDev(options) {
24286
24395
  const { filename, cached, ctx, pluginCtx, configService, compileOptionsState } = options;
24287
24396
  if (!configService.isDev) return cached.result;
@@ -24297,10 +24406,9 @@ async function refreshCompiledVueEntryCacheInDev(options) {
24297
24406
  };
24298
24407
  const source = transformed.source;
24299
24408
  const dirtyVueEntryIds = ctx.runtimeState?.build?.hmr?.dirtyVueEntryIds;
24300
- const normalizedDirtyFilename = normalizeFsResolvedId(filename);
24301
- if (!(dirtyVueEntryIds?.has(normalizedDirtyFilename) === true) && source === cached.source && transformed.signature === cached.autoRoutesSignature) {
24409
+ const dirtyEntryId = takeDirtyVueEntryId(dirtyVueEntryIds, filename);
24410
+ if (!dirtyEntryId && source === cached.source && transformed.signature === cached.autoRoutesSignature) {
24302
24411
  cached.refreshToken = 0;
24303
- dirtyVueEntryIds?.delete(normalizedDirtyFilename);
24304
24412
  return cached.result;
24305
24413
  }
24306
24414
  const compiled = await compileAndFinalizeVueLikeFile({
@@ -24316,7 +24424,7 @@ async function refreshCompiledVueEntryCacheInDev(options) {
24316
24424
  cached.source = source;
24317
24425
  cached.autoRoutesSignature = transformed.signature;
24318
24426
  cached.refreshToken = 0;
24319
- dirtyVueEntryIds?.delete(normalizedDirtyFilename);
24427
+ if (dirtyEntryId) dirtyVueEntryIds?.delete(dirtyEntryId);
24320
24428
  cached.result = compiled;
24321
24429
  return compiled;
24322
24430
  } catch {
@@ -24592,12 +24700,13 @@ function shouldReplaceAppScriptBundleEntry(options) {
24592
24700
  if (!isAppVueFile(options.filename) || !options.isDev || !options.hasDevHmrEvent) return false;
24593
24701
  return true;
24594
24702
  }
24595
- function hasModuleImportDeclaration(script) {
24703
+ function hasUnresolvedModuleImportDeclaration(script) {
24596
24704
  if (!script?.includes("import")) return false;
24597
24705
  try {
24598
24706
  let hasUnresolvedImport = false;
24599
24707
  traverse(parseJsLike(script), { ImportDeclaration(path) {
24600
- if (typeof path.node.source.value === "string") {
24708
+ const source = path.node.source.value;
24709
+ if (typeof source === "string" && !(source === "wevu" || source === "wevu/router" || source === "wevu/store" || source === "wevu/api" || source === "wevu/fetch" || source === "wevu/web-apis" || source === "wevu/internal-runtime" || source === "wevu/internal-reactivity" || source === "wevu/internal-template")) {
24601
24710
  hasUnresolvedImport = true;
24602
24711
  path.stop();
24603
24712
  }
@@ -24685,7 +24794,7 @@ async function emitResolvedCompiledVueEntryAssets(options) {
24685
24794
  runtimeFileName: ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileName,
24686
24795
  runtimeFileNames: ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileNames
24687
24796
  });
24688
- if (hasModuleImportDeclaration(script)) return;
24797
+ if (hasUnresolvedModuleImportDeclaration(script)) return;
24689
24798
  emitSfcScriptAssetReplacingBundleEntry(pluginCtx, bundle, relativeBase, script, options.scriptExtension);
24690
24799
  retainReplacedDevHmrScriptChunk(state, scriptFileName);
24691
24800
  }
@@ -25149,8 +25258,10 @@ const VUE_LOAD_FILTER_RE = /^(?:\0weapp-vite:scoped-slot:|.*[?&]weapp-vite-vue(?
25149
25258
  const SCOPED_SLOT_VIRTUAL_ID_RE = /^\0weapp-vite:scoped-slot:/;
25150
25259
  function invalidateDirtyVueEntryCaches(dirtyVueEntryIds, compilationCache) {
25151
25260
  if (!dirtyVueEntryIds?.size) return;
25261
+ const cachedEntriesByNormalizedId = /* @__PURE__ */ new Map();
25262
+ for (const [cachedId, cached] of compilationCache.entries()) cachedEntriesByNormalizedId.set(normalizeFsResolvedId(cachedId), cached);
25152
25263
  for (const entryId of dirtyVueEntryIds) {
25153
- const cached = compilationCache.get(entryId);
25264
+ const cached = compilationCache.get(entryId) ?? cachedEntriesByNormalizedId.get(normalizeFsResolvedId(entryId));
25154
25265
  if (!cached) continue;
25155
25266
  cached.source = void 0;
25156
25267
  cached.refreshToken = (cached.refreshToken ?? 0) + 1;
@@ -26472,7 +26583,7 @@ async function loadAppEntry(ctx, scanState) {
26472
26583
  const vueAppPath = await findVueEntry(appBasename);
26473
26584
  let configFromVue;
26474
26585
  if (!appConfigFile && vueAppPath) {
26475
- const { extractConfigFromVue } = await import("./file-8RU-zw8X.mjs");
26586
+ const { extractConfigFromVue } = await import("./file-DdqbRF9E.mjs");
26476
26587
  configFromVue = await extractConfigFromVue(vueAppPath);
26477
26588
  if (configFromVue) appConfigFile = vueAppPath;
26478
26589
  }
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-CcEF8k1Z.mjs");
87
+ const { getCompilerContext } = await import("./getInstance-DTOa17Qa.mjs");
88
88
  const compilerContext = getCompilerContext();
89
89
  const service = compilerContext.autoRoutesService;
90
90
  const reference = service?.getReference?.();
@@ -0,0 +1,2 @@
1
+ import { t as extractConfigFromVue } from "./file-CuTGX59g.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { n as getCompilerContext } from "./createContext-C2Rk_kcI.mjs";
2
+ export { getCompilerContext };
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-DooWF5Wk.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-C2Rk_kcI.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-CRoKWQZn.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.17.7",
4
+ "version": "6.17.8",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -110,7 +110,7 @@
110
110
  "package-manager-detector": "^1.6.0",
111
111
  "pathe": "^2.0.3",
112
112
  "picomatch": "^4.0.4",
113
- "postcss": "^8.5.15",
113
+ "postcss": "^8.5.16",
114
114
  "rolldown": "1.1.3",
115
115
  "rolldown-plugin-dts": "0.26.0",
116
116
  "semver": "^7.8.5",
@@ -124,7 +124,7 @@
124
124
  "@weapp-core/logger": "3.1.1",
125
125
  "@weapp-core/schematics": "6.0.4",
126
126
  "@weapp-core/shared": "3.0.5",
127
- "@weapp-vite/ast": "6.17.7",
127
+ "@weapp-vite/ast": "6.17.8",
128
128
  "@weapp-vite/mcp": "1.4.6",
129
129
  "@weapp-vite/miniprogram-automator": "1.2.5",
130
130
  "@weapp-vite/volar": "2.1.0",
@@ -134,7 +134,7 @@
134
134
  "rolldown-require": "2.0.19",
135
135
  "vite-plugin-performance": "2.0.1",
136
136
  "weapp-ide-cli": "5.4.10",
137
- "wevu": "6.17.7"
137
+ "wevu": "6.17.8"
138
138
  },
139
139
  "publishConfig": {
140
140
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-2ZpSECMP.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { n as getCompilerContext } from "./createContext-DooWF5Wk.mjs";
2
- export { getCompilerContext };