weapp-vite 6.19.2 → 6.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,7 +47,7 @@ export default defineConfig({
47
47
  })
48
48
  ```
49
49
 
50
- 未配置 `weapp.hmr.runtime` 时,`wv dev` 会在启动时读取 `project.private.config.json.setting.compileHotReLoad`:开启时使用 `stateful-experimental`,关闭或无法确认时使用 `classic`。启动日志会显示最终 HMR 模式、选择来源和切换到另一模式的方法。显式设置 `classic` 或 `stateful-experimental` 会覆盖自动选择。修改 DevTools 设置后请重启 `wv dev`;CSS、资源、配置和不兼容更新会自动回退完整构建与当前路由重载。
50
+ 未配置 `weapp.hmr.runtime` 时,`wv dev` 会在启动时读取 `project.private.config.json.setting.compileHotReLoad`:开启时使用 `stateful-experimental`,关闭或无法确认时使用 `classic`。启动日志会以 `HMR 模式` `HMR 切换` 两行显示最终模式、选择来源和切换方法。显式设置 `classic` 或 `stateful-experimental` 会覆盖自动选择。修改 DevTools 设置后请重启 `wv dev`;CSS、资源、配置和不兼容更新会自动回退完整构建与当前路由重载。
51
51
 
52
52
  > 说明:CLI 同时支持完整命令 `weapp-vite` 与简写命令 `wv`,两者等价。下面的示例默认使用 `weapp-vite`,你也可以按个人习惯替换成 `wv`。
53
53
 
@@ -1,4 +1,4 @@
1
- import { n as getCompilerContext, v as getRouteRuntimeGlobalKeys } from "./createContext-D9HCnUmH.mjs";
1
+ import { n as getCompilerContext, v as getRouteRuntimeGlobalKeys } from "./createContext-BovlKdUA.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 parseCommentJson, D as isPathInside, E as shouldPassPlatformArgToIdeOpen, S as loadViteConfigFile, T as getDefaultIdeProjectRoot, _ as resolveHmrProfileJsonPath, a as formatBytes, b as checkRuntime, d as getBackendForCapability, f as resolveBackendExecution, g as SHARED_CHUNK_VIRTUAL_PREFIX, h as createSharedBuildConfig, m as syncManagedTsconfigBootstrapFiles, p as syncProjectSupportFiles, t as createCompilerContext, w as createCjsConfigLoadError, x as getProjectConfigFileName, y as resolveWeappConfigFile } from "./createContext-D9HCnUmH.mjs";
1
+ import { C as parseCommentJson, D as isPathInside, E as shouldPassPlatformArgToIdeOpen, S as loadViteConfigFile, T as getDefaultIdeProjectRoot, _ as resolveHmrProfileJsonPath, a as formatBytes, b as checkRuntime, d as getBackendForCapability, f as resolveBackendExecution, g as SHARED_CHUNK_VIRTUAL_PREFIX, h as createSharedBuildConfig, m as syncManagedTsconfigBootstrapFiles, p as syncProjectSupportFiles, t as createCompilerContext, w as createCjsConfigLoadError, x as getProjectConfigFileName, y as resolveWeappConfigFile } from "./createContext-BovlKdUA.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
3
- import { h as VERSION } from "./file-CFQYYS_3.mjs";
3
+ import { h as VERSION } from "./file-K76qLAmU.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";
@@ -4540,7 +4540,7 @@ function resolveRunnableHotkeyDefinition(input) {
4540
4540
  }
4541
4541
  //#endregion
4542
4542
  //#region package.json
4543
- var version = "6.19.2";
4543
+ var version = "6.19.3";
4544
4544
  //#endregion
4545
4545
  //#region src/cli/devHotkeys/format.ts
4546
4546
  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-CFQYYS_3.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-K76qLAmU.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";
@@ -7872,11 +7872,11 @@ function resolveHmrRuntime(options) {
7872
7872
  function formatHmrRuntimeStartupMessages(options) {
7873
7873
  if (options.configured === "classic" || options.configured === "stateful-experimental") {
7874
7874
  const alternative = options.runtime === "classic" ? "stateful-experimental" : "classic";
7875
- return [`HMR 模式:${options.runtime}(weapp.hmr.runtime 显式配置)`, `切换模式:将 weapp.hmr.runtime 改为 auto 或 ${alternative},并重启 wv dev。`];
7875
+ return [`HMR 模式:${options.runtime}(显式配置)`, `HMR 切换:修改 weapp.hmr.runtime auto 或 ${alternative} 后重启 wv dev。`];
7876
7876
  }
7877
- if (options.platform !== "weapp") return ["HMR 模式:classic(auto:stateful-experimental 仅支持微信小程序)", "切换模式:可通过 weapp.hmr.runtime 显式锁定 classic;stateful-experimental 仅支持微信小程序。"];
7878
- if (options.compileHotReLoad === true) return ["HMR 模式:stateful-experimental(auto:微信开发者工具热重载已开启)", "切换模式:在微信开发者工具中关闭“热重载”并重启 wv dev,可切换为 classic;也可通过 weapp.hmr.runtime 显式锁定模式。"];
7879
- return ["HMR 模式:classic(auto:微信开发者工具热重载未开启或无法确认)", "切换模式:在微信开发者工具中开启“热重载”并重启 wv dev,可切换为 stateful-experimental;也可通过 weapp.hmr.runtime 显式锁定模式。"];
7877
+ if (options.platform !== "weapp") return ["HMR 模式:classic(自动检测:仅微信小程序支持 stateful-experimental", "HMR 切换:可通过 weapp.hmr.runtime 显式配置 classic"];
7878
+ if (options.compileHotReLoad === true) return ["HMR 模式:stateful-experimental(自动检测:微信开发者工具热重载已开启)", "HMR 切换:关闭微信开发者工具“热重载”后重启 wv dev,或通过 weapp.hmr.runtime 显式配置。"];
7879
+ return ["HMR 模式:classic(自动检测:微信开发者工具热重载未开启或无法确认)", "HMR 切换:开启微信开发者工具“热重载”后重启 wv dev,或通过 weapp.hmr.runtime 显式配置。"];
7880
7880
  }
7881
7881
  //#endregion
7882
7882
  //#region src/runtime/lib.ts
@@ -11205,6 +11205,74 @@ function createStatefulHmrSidecarPlugin() {
11205
11205
  };
11206
11206
  }
11207
11207
  //#endregion
11208
+ //#region src/runtime/statefulHmr/snapshotScheduler.ts
11209
+ const DEFAULT_SNAPSHOT_DEBOUNCE_MS = 40;
11210
+ var StatefulHmrSnapshotScheduler = class {
11211
+ closed = false;
11212
+ debounceMs;
11213
+ execute;
11214
+ onError;
11215
+ pendingFiles = /* @__PURE__ */ new Set();
11216
+ pendingMode;
11217
+ revision = 0;
11218
+ runningPromise;
11219
+ timer;
11220
+ constructor(options) {
11221
+ this.debounceMs = options.debounceMs ?? DEFAULT_SNAPSHOT_DEBOUNCE_MS;
11222
+ this.execute = options.execute;
11223
+ this.onError = options.onError;
11224
+ }
11225
+ request(mode, files = []) {
11226
+ if (this.closed) return;
11227
+ for (const file of files) this.pendingFiles.add(file);
11228
+ this.pendingMode = this.pendingMode === "full" || mode === "full" ? "full" : "refresh";
11229
+ this.revision += 1;
11230
+ if (!this.runningPromise) this.schedule();
11231
+ }
11232
+ isPending() {
11233
+ return Boolean(this.timer || this.runningPromise || this.pendingMode);
11234
+ }
11235
+ async close() {
11236
+ this.closed = true;
11237
+ if (this.timer) {
11238
+ clearTimeout(this.timer);
11239
+ this.timer = void 0;
11240
+ }
11241
+ this.pendingFiles.clear();
11242
+ this.pendingMode = void 0;
11243
+ await this.runningPromise;
11244
+ }
11245
+ schedule() {
11246
+ if (this.closed) return;
11247
+ if (this.timer) clearTimeout(this.timer);
11248
+ this.timer = setTimeout(() => {
11249
+ this.timer = void 0;
11250
+ this.startPendingBatch();
11251
+ }, this.debounceMs);
11252
+ }
11253
+ startPendingBatch() {
11254
+ if (this.closed || this.runningPromise || !this.pendingMode) return;
11255
+ const batchRevision = this.revision;
11256
+ const batchFiles = [...this.pendingFiles];
11257
+ const batchMode = this.pendingMode;
11258
+ this.pendingFiles.clear();
11259
+ this.pendingMode = void 0;
11260
+ const isSuperseded = () => this.closed || this.revision !== batchRevision;
11261
+ this.runningPromise = this.execute({
11262
+ files: batchFiles,
11263
+ isSuperseded,
11264
+ mode: batchMode
11265
+ }).catch((error) => this.onError?.(error)).finally(() => {
11266
+ if (!this.closed && isSuperseded()) {
11267
+ for (const file of batchFiles) this.pendingFiles.add(file);
11268
+ this.pendingMode = this.pendingMode === "full" || batchMode === "full" ? "full" : "refresh";
11269
+ }
11270
+ this.runningPromise = void 0;
11271
+ if (this.pendingMode) this.schedule();
11272
+ });
11273
+ }
11274
+ };
11275
+ //#endregion
11208
11276
  //#region src/runtime/statefulHmr/serverState.ts
11209
11277
  function createStatefulHmrServerState(buildId) {
11210
11278
  return {
@@ -11760,14 +11828,13 @@ var StatefulHmrSession = class {
11760
11828
  server;
11761
11829
  restart;
11762
11830
  snapshots;
11831
+ activeSnapshotBatch;
11763
11832
  adapter;
11764
11833
  initialBundle = Promise.withResolvers();
11834
+ snapshotScheduler;
11765
11835
  transport;
11766
- fullBuildTimer;
11767
11836
  outputChain = Promise.resolve();
11768
11837
  restartTimer;
11769
- snapshotTimer;
11770
- snapshotFiles = /* @__PURE__ */ new Set();
11771
11838
  snapshotAssets = /* @__PURE__ */ new Map();
11772
11839
  sourceChangeListener = (file, dirtyReasonSummary) => {
11773
11840
  this.handleSourceUpdate(file, dirtyReasonSummary);
@@ -11794,6 +11861,10 @@ var StatefulHmrSession = class {
11794
11861
  onPatch: (files, output) => this.handlePatch(files, output),
11795
11862
  waitForInitialBundle: () => this.waitForInitialBundle()
11796
11863
  });
11864
+ this.snapshotScheduler = new StatefulHmrSnapshotScheduler({
11865
+ execute: (batch) => this.executeSnapshotBatch(batch),
11866
+ onError: (error) => this.server.config.logger.error("[weapp-vite] stateful HMR snapshot refresh failed", { error: error instanceof Error ? error : new Error(String(error)) })
11867
+ });
11797
11868
  }
11798
11869
  install() {
11799
11870
  this.transport.install();
@@ -11801,11 +11872,10 @@ var StatefulHmrSession = class {
11801
11872
  this.ctx.onStatefulHmrSourceChange = this.sourceChangeListener;
11802
11873
  }
11803
11874
  async close() {
11804
- if (this.fullBuildTimer) clearTimeout(this.fullBuildTimer);
11805
- if (this.snapshotTimer) clearTimeout(this.snapshotTimer);
11806
11875
  if (this.restartTimer) clearTimeout(this.restartTimer);
11807
11876
  if (this.ctx.onStatefulHmrSourceChange === this.sourceChangeListener) this.ctx.onStatefulHmrSourceChange = void 0;
11808
11877
  this.transport.close();
11878
+ await this.snapshotScheduler.close();
11809
11879
  await this.outputChain;
11810
11880
  }
11811
11881
  async refreshControl() {
@@ -11826,12 +11896,14 @@ var StatefulHmrSession = class {
11826
11896
  return;
11827
11897
  }
11828
11898
  if (requiresStatefulHmrSnapshot(normalizedFile, dirtyReasonSummary)) {
11829
- if (!this.snapshotTimer && !this.fullBuildTimer) logger_default.info("微信状态保持 HMR 正在刷新模板、样式与静态资源产物...");
11899
+ if (!this.snapshotScheduler.isPending()) logger_default.info("HMR 更新:正在同步模板、样式与静态资源...");
11830
11900
  this.requestSnapshotRefresh([normalizedFile]);
11831
11901
  }
11832
11902
  }
11833
11903
  handleOutput(output) {
11904
+ const snapshotBatch = this.activeSnapshotBatch;
11834
11905
  this.enqueueOutput(async () => {
11906
+ if (snapshotBatch?.isSuperseded()) return;
11835
11907
  const compatibleOutput = await transformOutput(output);
11836
11908
  const fullBuild = compatibleOutput.some((item) => item.fileName === "app.js");
11837
11909
  if (fullBuild) {
@@ -11858,7 +11930,9 @@ var StatefulHmrSession = class {
11858
11930
  if (output.type === "Noop") return false;
11859
11931
  if (!isSafeJavaScriptPatch(files, output, this.ctx.runtimeState.build.hmr.profile.dirtyReasonSummary, this.ctx.runtimeState.build.hmr.resolvedEntryMap.keys(), this.server.config.root)) {
11860
11932
  if (shouldRestartStatefulHmrServer(files, this.ctx.configService?.configFileDependencies)) this.requestServerRestart();
11861
- else this.requestFullBuild(files);
11933
+ else if (files.length > 0 && files.every(isStatefulHmrAssetFile) || shouldUseStatefulHmrSnapshotOnly(this.ctx.runtimeState.build.hmr.profile.dirtyReasonSummary ?? [])) {
11934
+ if (!this.snapshotScheduler.isPending()) this.requestSnapshotRefresh(files);
11935
+ } else this.requestFullBuild(files);
11862
11936
  return false;
11863
11937
  }
11864
11938
  this.adapter.registerPatchModules(output.code).then(async () => {
@@ -11876,30 +11950,10 @@ var StatefulHmrSession = class {
11876
11950
  return true;
11877
11951
  }
11878
11952
  requestFullBuild(files = []) {
11879
- for (const file of files) this.snapshotFiles.add(file);
11880
- if (this.snapshotTimer) {
11881
- clearTimeout(this.snapshotTimer);
11882
- this.snapshotTimer = void 0;
11883
- }
11884
- if (this.fullBuildTimer) return;
11885
- this.fullBuildTimer = setTimeout(() => {
11886
- this.fullBuildTimer = void 0;
11887
- const snapshotFiles = this.takeSnapshotFiles();
11888
- this.rebuildFromSnapshot(snapshotFiles).catch((error) => {
11889
- this.server.config.logger.error("[weapp-vite] stateful HMR full rebuild failed", { error });
11890
- });
11891
- }, 100);
11953
+ this.snapshotScheduler.request("full", files);
11892
11954
  }
11893
11955
  requestSnapshotRefresh(files = []) {
11894
- for (const file of files) this.snapshotFiles.add(file);
11895
- if (this.fullBuildTimer || this.snapshotTimer) return;
11896
- this.snapshotTimer = setTimeout(() => {
11897
- this.snapshotTimer = void 0;
11898
- const snapshotFiles = this.takeSnapshotFiles();
11899
- this.refreshSnapshotAssets(snapshotFiles).catch((error) => {
11900
- this.server.config.logger.error("[weapp-vite] stateful HMR snapshot refresh failed", { error });
11901
- });
11902
- }, 100);
11956
+ this.snapshotScheduler.request("refresh", files);
11903
11957
  }
11904
11958
  requestServerRestart() {
11905
11959
  if (this.restartTimer) return;
@@ -11916,19 +11970,26 @@ var StatefulHmrSession = class {
11916
11970
  });
11917
11971
  return this.outputChain;
11918
11972
  }
11919
- async rebuildFromSnapshot(files) {
11920
- await this.adapter.rebuild(async () => {
11921
- this.replaceSnapshotAssets(await this.snapshots.rebuild(files));
11973
+ async executeSnapshotBatch(batch) {
11974
+ const output = await this.snapshots.rebuild(batch.files);
11975
+ if (batch.isSuperseded()) return;
11976
+ if (batch.mode === "full") {
11977
+ this.replaceSnapshotAssets(output);
11978
+ this.activeSnapshotBatch = batch;
11979
+ try {
11980
+ await this.adapter.rebuild();
11981
+ await this.outputChain;
11982
+ } finally {
11983
+ if (this.activeSnapshotBatch === batch) this.activeSnapshotBatch = void 0;
11984
+ }
11985
+ return;
11986
+ }
11987
+ const changedOutput = getChangedStatefulHmrSnapshotAssets(this.snapshotAssets.values(), output);
11988
+ this.replaceSnapshotAssets(output);
11989
+ await this.enqueueOutput(async () => {
11990
+ if (!batch.isSuperseded()) await writeStatefulHmrOutput(this.ctx.configService.outDir, changedOutput);
11922
11991
  });
11923
11992
  }
11924
- async refreshSnapshotAssets(files) {
11925
- this.replaceSnapshotAssets(await this.snapshots.rebuild(files));
11926
- }
11927
- takeSnapshotFiles() {
11928
- const files = [...this.snapshotFiles];
11929
- this.snapshotFiles.clear();
11930
- return files;
11931
- }
11932
11993
  replaceSnapshotAssets(output) {
11933
11994
  this.snapshotAssets = new Map(output.filter((item) => item.type === "asset").map((item) => [item.fileName, item]));
11934
11995
  }
@@ -11949,6 +12010,20 @@ function mergeStatefulHmrSnapshotAssets(output, snapshotAssets) {
11949
12010
  else output.push(asset);
11950
12011
  }
11951
12012
  }
12013
+ function getChangedStatefulHmrSnapshotAssets(previous, next) {
12014
+ const previousAssets = new Map(Array.from(previous).flatMap((item) => item.type === "asset" ? [[item.fileName, item.source]] : []));
12015
+ return Array.from(next).filter((item) => {
12016
+ if (item.type !== "asset") return true;
12017
+ const previousSource = previousAssets.get(item.fileName);
12018
+ return previousSource === void 0 || !statefulHmrAssetSourcesEqual(previousSource, item.source);
12019
+ });
12020
+ }
12021
+ function statefulHmrAssetSourcesEqual(left, right) {
12022
+ if (left === right) return true;
12023
+ const leftBuffer = Buffer.isBuffer(left) ? left : Buffer.from(left);
12024
+ const rightBuffer = Buffer.isBuffer(right) ? right : Buffer.from(right);
12025
+ return leftBuffer.equals(rightBuffer);
12026
+ }
11952
12027
  function createWatcherAdapter(server, session) {
11953
12028
  return {
11954
12029
  close: async () => {
@@ -11994,9 +12069,15 @@ function isSafeJavaScriptPatch(files, output, dirtyReasonSummary = [], entryIds,
11994
12069
  function requiresStatefulHmrSnapshot(file, dirtyReasonSummary = []) {
11995
12070
  return !/\.(?:[cm]?[jt]sx?|vue)$/.test(file) || dirtyReasonSummary.some(isUnsafeStatefulHmrReason);
11996
12071
  }
12072
+ function isStatefulHmrAssetFile(file) {
12073
+ return !/\.(?:[cm]?[jt]sx?|vue)$/.test(file);
12074
+ }
11997
12075
  function isUnsafeStatefulHmrReason(reason) {
11998
12076
  return /^(?:entry-json-only|entry-local-asset|entry-style-only|tailwind-content):/.test(reason);
11999
12077
  }
12078
+ function shouldUseStatefulHmrSnapshotOnly(dirtyReasonSummary) {
12079
+ return dirtyReasonSummary.some((reason) => /^(?:entry-json-only|entry-local-asset|entry-style-only):/.test(reason)) && dirtyReasonSummary.every((reason) => /^(?:entry-json-only|entry-local-asset|entry-style-only|tailwind-content):/.test(reason));
12080
+ }
12000
12081
  function isNonJavaScriptSidecarId(id) {
12001
12082
  const sidecar = parseSidecarSourceRequest(id) ?? parseSidecarModuleId(id);
12002
12083
  return sidecar !== void 0 && sidecar.kind !== "script";
@@ -14988,7 +15069,8 @@ function createBuildService(ctx) {
14988
15069
  ...buildOptions,
14989
15070
  build: {
14990
15071
  ...buildOptions.build ?? {},
14991
- watch: void 0
15072
+ watch: void 0,
15073
+ write: false
14992
15074
  }
14993
15075
  };
14994
15076
  const initialSnapshot = toStatefulHmrOutput(await build(snapshotBuildOptions));
@@ -15025,7 +15107,7 @@ function createBuildService(ctx) {
15025
15107
  ...snapshotOptions.build ?? {},
15026
15108
  emptyOutDir: false,
15027
15109
  watch: void 0,
15028
- write: true
15110
+ write: false
15029
15111
  };
15030
15112
  snapshotOptions.plugins = [...snapshotOptions.plugins ?? [], {
15031
15113
  name: "weapp-vite:stateful-hmr-snapshot-assets",
@@ -15044,7 +15126,7 @@ function createBuildService(ctx) {
15044
15126
  if (configuredHmrRuntime !== "auto" || !isStatefulHmrRuntimeCompatibilityError(error)) throw error;
15045
15127
  devHmrRuntime = "classic";
15046
15128
  logger_default.warn(`微信状态保持 HMR 运行时不可用,已自动降级为 classic:${error instanceof Error ? error.message : String(error)}`);
15047
- logger_default.info("HMR 模式:classic(auto fallback:stateful runtime compatibility check failed)");
15129
+ logger_default.info("HMR 模式:classic(自动降级:stateful HMR 运行时兼容性检查失败)");
15048
15130
  resetRuntimeStateForFreshBuild(ctx.runtimeState);
15049
15131
  await configService.load(configService.loadOptions);
15050
15132
  await scanService.loadAppEntry();
@@ -32537,7 +32619,7 @@ async function loadAppEntry(ctx, scanState) {
32537
32619
  const { path: appEntryPath } = appEntry;
32538
32620
  let configFromVue;
32539
32621
  if (!appConfigFile && vueAppPath) {
32540
- const { extractConfigFromVue } = await import("./file-BTZg_nyD.mjs");
32622
+ const { extractConfigFromVue } = await import("./file-DHCIIIYD.mjs");
32541
32623
  configFromVue = await extractConfigFromVue(vueAppPath);
32542
32624
  if (configFromVue) appConfigFile = vueAppPath;
32543
32625
  }
@@ -47,7 +47,7 @@ export default defineConfig({
47
47
  })
48
48
  ```
49
49
 
50
- 未配置 `weapp.hmr.runtime` 时,`wv dev` 会在启动时读取 `project.private.config.json.setting.compileHotReLoad`:开启时使用 `stateful-experimental`,关闭或无法确认时使用 `classic`。启动日志会显示最终 HMR 模式、选择来源和切换到另一模式的方法。显式设置 `classic` 或 `stateful-experimental` 会覆盖自动选择。修改 DevTools 设置后请重启 `wv dev`;CSS、资源、配置和不兼容更新会自动回退完整构建与当前路由重载。
50
+ 未配置 `weapp.hmr.runtime` 时,`wv dev` 会在启动时读取 `project.private.config.json.setting.compileHotReLoad`:开启时使用 `stateful-experimental`,关闭或无法确认时使用 `classic`。启动日志会以 `HMR 模式` `HMR 切换` 两行显示最终模式、选择来源和切换方法。显式设置 `classic` 或 `stateful-experimental` 会覆盖自动选择。修改 DevTools 设置后请重启 `wv dev`;CSS、资源、配置和不兼容更新会自动回退完整构建与当前路由重载。
51
51
 
52
52
  > 说明:CLI 同时支持完整命令 `weapp-vite` 与简写命令 `wv`,两者等价。下面的示例默认使用 `weapp-vite`,你也可以按个人习惯替换成 `wv`。
53
53
 
@@ -327,7 +327,7 @@ export default defineConfig({
327
327
 
328
328
  安全的 JavaScript/Vue 更新会保留当前 Page/Component 实例、route/query、输入和可序列化 data/setup ref,并替换原生 Page、原生 Component 与 wevu 方法。CSS、资源、JSON/配置、不兼容模块图或补丁失败会回退完整构建与当前路由重载。
329
329
 
330
- `auto` 在 `project.private.config.json` 的 `setting.compileHotReLoad` 严格为 `true` 时选择 `stateful-experimental`,否则选择 `classic`;非微信平台也会回退到 `classic`。该判断只在启动时执行,修改开发者工具设置后需要重启 `wv dev`。启动日志会显示最终模式、选择来源,以及通过 DevTools 热重载开关或 `weapp.hmr.runtime` 切换模式的方法。显式配置 `classic` 或 `stateful-experimental` 始终优先。
330
+ `auto` 在 `project.private.config.json` 的 `setting.compileHotReLoad` 严格为 `true` 时选择 `stateful-experimental`,否则选择 `classic`;非微信平台也会回退到 `classic`。该判断只在启动时执行,修改开发者工具设置后需要重启 `wv dev`。启动日志会以 `HMR 模式` 和 `HMR 切换` 两行显示最终模式、选择来源,以及通过 DevTools 热重载开关或 `weapp.hmr.runtime` 切换模式的方法。显式配置 `classic` 或 `stateful-experimental` 始终优先。
331
331
 
332
332
  状态保持模式目前只支持微信小程序,需要微信开发者工具开启服务端口和热重载。需要既有写盘/刷新行为时显式配置 `classic`。
333
333
 
@@ -0,0 +1,2 @@
1
+ import { t as extractConfigFromVue } from "./file-K76qLAmU.mjs";
2
+ export { extractConfigFromVue };
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-BPQWdhpZ.mjs");
87
+ const { getCompilerContext } = await import("./getInstance-CKba6wgV.mjs");
88
88
  const compilerContext = getCompilerContext();
89
89
  const service = compilerContext.autoRoutesService;
90
90
  const reference = service?.getReference?.();
@@ -0,0 +1,2 @@
1
+ import { n as getCompilerContext } from "./createContext-BovlKdUA.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-D9HCnUmH.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-BovlKdUA.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/test.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createCompilerContext } from "./createContext-D9HCnUmH.mjs";
1
+ import { t as createCompilerContext } from "./createContext-BovlKdUA.mjs";
2
2
  import path from "node:path";
3
3
  import process from "node:process";
4
4
  import chokidar from "chokidar";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.19.2",
4
+ "version": "6.19.3",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -128,21 +128,21 @@
128
128
  "vue": "^3.5.41",
129
129
  "vue-tsc": "^3.3.9",
130
130
  "@weapp-core/constants": "0.1.16",
131
- "@weapp-core/init": "6.0.13",
132
131
  "@weapp-core/logger": "3.1.1",
133
- "@weapp-core/schematics": "6.0.4",
132
+ "@weapp-core/schematics": "6.1.0",
133
+ "@weapp-vite/ast": "6.19.3",
134
134
  "@weapp-core/shared": "3.1.0",
135
- "@weapp-vite/ast": "6.19.2",
136
- "@weapp-vite/mcp": "1.4.12",
137
- "@weapp-vite/miniprogram-automator": "1.2.11",
138
- "@weapp-vite/volar": "2.1.2",
139
- "@weapp-vite/web": "1.4.2",
140
- "@wevu/api": "0.2.14",
141
- "@wevu/web-apis": "1.2.31",
142
- "rolldown-require": "2.0.23",
135
+ "@weapp-vite/mcp": "1.4.13",
136
+ "@weapp-vite/miniprogram-automator": "1.2.12",
137
+ "@weapp-vite/web": "1.4.3",
138
+ "@wevu/api": "0.2.15",
139
+ "@weapp-vite/volar": "2.1.3",
140
+ "@wevu/web-apis": "1.2.32",
143
141
  "vite-plugin-performance": "2.0.1",
144
- "weapp-ide-cli": "6.0.3",
145
- "wevu": "6.19.2"
142
+ "rolldown-require": "2.0.24",
143
+ "weapp-ide-cli": "6.0.4",
144
+ "wevu": "6.19.3",
145
+ "@weapp-core/init": "6.0.13"
146
146
  },
147
147
  "publishConfig": {
148
148
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-CFQYYS_3.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { n as getCompilerContext } from "./createContext-D9HCnUmH.mjs";
2
- export { getCompilerContext };