weapp-vite 6.19.2 → 6.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/{createContext-D9HCnUmH.mjs → createContext-r2rcHex1.mjs} +204 -129
- package/dist/docs/README.md +1 -1
- package/dist/docs/weapp-config.md +1 -1
- package/dist/{file-CFQYYS_3.mjs → file-C-T36DmG.mjs} +1 -1
- package/dist/file-CV6ZWiTX.mjs +2 -0
- package/dist/getInstance-HvLRUAtA.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/test.mjs +1 -1
- package/package.json +12 -12
- package/dist/file-BTZg_nyD.mjs +0 -2
- package/dist/getInstance-BPQWdhpZ.mjs +0 -2
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
|
|
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
|
|
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getCompilerContext, v as getRouteRuntimeGlobalKeys } from "./createContext-
|
|
1
|
+
import { n as getCompilerContext, v as getRouteRuntimeGlobalKeys } from "./createContext-r2rcHex1.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-
|
|
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-r2rcHex1.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
3
|
+
import { h as VERSION } from "./file-C-T36DmG.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.
|
|
4543
|
+
var version = "6.19.4";
|
|
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-
|
|
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-C-T36DmG.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";
|
|
@@ -10,7 +10,7 @@ import { fileURLToPath } from "node:url";
|
|
|
10
10
|
import path$1, { normalize, relative, win32 } from "node:path";
|
|
11
11
|
import { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, MINI_PROGRAM_PLATFORM_DESCRIPTORS as MINI_PROGRAM_PLATFORM_ADAPTERS, addExtension, defu, escapeStringRegexp, get, getDefaultMiniProgramPlatform, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, isEmptyObject, isObject, normalizeMiniProgramPlatform, removeExtension, removeExtensionDeep, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle } from "@weapp-core/shared";
|
|
12
12
|
import { fs as fs$1 } from "@weapp-core/shared/fs";
|
|
13
|
-
import { analyzeScript, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate,
|
|
13
|
+
import { analyzeScript, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
|
|
14
14
|
import { collectOnPageScrollPerformanceWarnings } from "@weapp-vite/ast/operations/onPageScroll";
|
|
15
15
|
import { collectSetDataPickKeysFromTemplateCode } from "@weapp-vite/ast/operations/setDataPick";
|
|
16
16
|
import { compileScript, parse } from "vue/compiler-sfc";
|
|
@@ -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}
|
|
7875
|
+
return [`HMR 模式:${options.runtime}(显式配置)`, `HMR 切换:修改 weapp.hmr.runtime 为 auto 或 ${alternative} 后重启 wv dev。`];
|
|
7876
7876
|
}
|
|
7877
|
-
if (options.platform !== "weapp") return ["HMR 模式:classic
|
|
7878
|
-
if (options.compileHotReLoad === true) return ["HMR 模式:stateful-experimental
|
|
7879
|
-
return ["HMR 模式:classic
|
|
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.
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
11920
|
-
await this.
|
|
11921
|
-
|
|
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:
|
|
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
|
|
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();
|
|
@@ -25287,17 +25369,6 @@ function getRequireImportLiteral(node) {
|
|
|
25287
25369
|
function getStaticStringLiteral(node) {
|
|
25288
25370
|
return getRequireImportLiteral(node);
|
|
25289
25371
|
}
|
|
25290
|
-
function setRequireImportLiteral(node, nextValue) {
|
|
25291
|
-
if (!node) return;
|
|
25292
|
-
if (node.type === "StringLiteral" || node.type === "Literal") {
|
|
25293
|
-
node.value = nextValue;
|
|
25294
|
-
return;
|
|
25295
|
-
}
|
|
25296
|
-
if (node.type === "TemplateLiteral" && node.expressions?.length === 0 && node.quasis?.length === 1) {
|
|
25297
|
-
node.quasis[0].value.raw = nextValue;
|
|
25298
|
-
node.quasis[0].value.cooked = nextValue;
|
|
25299
|
-
}
|
|
25300
|
-
}
|
|
25301
25372
|
function normalizeRelativeChunkImport(fileName, importee) {
|
|
25302
25373
|
return toPosixPath(path.normalize(path.join(path.dirname(fileName), importee)));
|
|
25303
25374
|
}
|
|
@@ -25335,10 +25406,11 @@ function createWeapiAccessExpression(globalName) {
|
|
|
25335
25406
|
}
|
|
25336
25407
|
//#endregion
|
|
25337
25408
|
//#region src/plugins/core/lifecycle/platformApiRewrite.ts
|
|
25338
|
-
function
|
|
25409
|
+
function createMiniProgramPlatformApiRewrite(code, globalName, _options) {
|
|
25339
25410
|
const injectedApiIdentifier = WEAPP_VITE_INJECTED_API_IDENTIFIER;
|
|
25340
25411
|
try {
|
|
25341
25412
|
const ast = parseJsLike(code);
|
|
25413
|
+
const magicString = new MagicString(code);
|
|
25342
25414
|
let mutated = false;
|
|
25343
25415
|
const rewritePath = (path) => {
|
|
25344
25416
|
const object = path.node?.object;
|
|
@@ -25346,22 +25418,60 @@ function rewriteMiniProgramPlatformApiAccess(code, globalName, _options) {
|
|
|
25346
25418
|
const identifierName = object.name;
|
|
25347
25419
|
if (!platformApiIdentifiers.has(identifierName)) return;
|
|
25348
25420
|
if (path.scope?.hasBinding?.(identifierName)) return;
|
|
25349
|
-
|
|
25350
|
-
|
|
25351
|
-
name: injectedApiIdentifier
|
|
25352
|
-
};
|
|
25421
|
+
if (typeof object.start !== "number" || typeof object.end !== "number" || object.start < 0 || object.end < object.start) return;
|
|
25422
|
+
magicString.update(object.start, object.end, injectedApiIdentifier);
|
|
25353
25423
|
mutated = true;
|
|
25354
25424
|
};
|
|
25355
25425
|
traverse(ast, {
|
|
25356
25426
|
MemberExpression: rewritePath,
|
|
25357
25427
|
OptionalMemberExpression: rewritePath
|
|
25358
25428
|
});
|
|
25359
|
-
if (
|
|
25360
|
-
|
|
25361
|
-
|
|
25362
|
-
|
|
25363
|
-
|
|
25364
|
-
}
|
|
25429
|
+
if (mutated) {
|
|
25430
|
+
const aliasCode = `var ${injectedApiIdentifier} = ${createWeapiAccessExpression(globalName)};`;
|
|
25431
|
+
magicString.prepend(`${aliasCode}\n`);
|
|
25432
|
+
return magicString;
|
|
25433
|
+
}
|
|
25434
|
+
} catch {}
|
|
25435
|
+
}
|
|
25436
|
+
function rewriteMiniProgramPlatformApiAccess(code, globalName, options) {
|
|
25437
|
+
return createMiniProgramPlatformApiRewrite(code, globalName, options)?.toString() ?? code;
|
|
25438
|
+
}
|
|
25439
|
+
//#endregion
|
|
25440
|
+
//#region src/utils/sourcemap.ts
|
|
25441
|
+
function isEncodedSourceMapLike(value) {
|
|
25442
|
+
return Boolean(value && typeof value === "object" && "version" in value && typeof value.version === "number" && "mappings" in value && "names" in value && "sources" in value);
|
|
25443
|
+
}
|
|
25444
|
+
function normalizeEncodedSourceMapLike(value) {
|
|
25445
|
+
if (!value || typeof value !== "object") return null;
|
|
25446
|
+
const sourceMap = value;
|
|
25447
|
+
const numericVersion = typeof sourceMap.version === "number" ? sourceMap.version : typeof sourceMap.version === "string" ? Number(sourceMap.version) : NaN;
|
|
25448
|
+
if (!Number.isFinite(numericVersion)) return null;
|
|
25449
|
+
const normalized = {
|
|
25450
|
+
...sourceMap,
|
|
25451
|
+
version: numericVersion
|
|
25452
|
+
};
|
|
25453
|
+
return isEncodedSourceMapLike(normalized) ? normalized : null;
|
|
25454
|
+
}
|
|
25455
|
+
function composeSourceMaps(transformedMap, originalMap) {
|
|
25456
|
+
if (isEncodedSourceMapLike(transformedMap) && isEncodedSourceMapLike(originalMap)) return remapping([transformedMap, originalMap], () => null);
|
|
25457
|
+
if (isEncodedSourceMapLike(transformedMap)) return transformedMap;
|
|
25458
|
+
if (isEncodedSourceMapLike(originalMap)) return originalMap;
|
|
25459
|
+
return null;
|
|
25460
|
+
}
|
|
25461
|
+
//#endregion
|
|
25462
|
+
//#region src/plugins/core/lifecycle/emit/rewrite/sourcemap.ts
|
|
25463
|
+
function applyMagicStringChunkRewrite(chunk, magicString, options) {
|
|
25464
|
+
const previousCode = chunk.code;
|
|
25465
|
+
const nextCode = magicString.toString();
|
|
25466
|
+
if (nextCode === previousCode) return false;
|
|
25467
|
+
const previousMap = normalizeEncodedSourceMapLike(chunk.map);
|
|
25468
|
+
chunk.code = nextCode;
|
|
25469
|
+
if (previousMap) chunk.map = composeSourceMaps(magicString.generateMap({
|
|
25470
|
+
hires: options?.hires ?? "boundary",
|
|
25471
|
+
includeContent: true,
|
|
25472
|
+
source: chunk.fileName
|
|
25473
|
+
}), previousMap);
|
|
25474
|
+
return true;
|
|
25365
25475
|
}
|
|
25366
25476
|
//#endregion
|
|
25367
25477
|
//#region src/plugins/core/lifecycle/emit/rewrite/platform.ts
|
|
@@ -25416,10 +25526,6 @@ function warmupBundleScriptAnalysis(bundle, options) {
|
|
|
25416
25526
|
rememberChunkScriptAnalysis(chunk, analysis, options);
|
|
25417
25527
|
}
|
|
25418
25528
|
}
|
|
25419
|
-
function replacePlatformApiAccess$2(code, globalName, options) {
|
|
25420
|
-
if (!(options?.analysis?.hasPlatformApiAccess ?? mayContainPlatformApiAccess(code, { engine: options?.astEngine }))) return code;
|
|
25421
|
-
return rewriteMiniProgramPlatformApiAccess(code, globalName, { engine: options?.astEngine });
|
|
25422
|
-
}
|
|
25423
25529
|
function normalizeNpmImportByPlatform(platform, importee, dependencies, mode) {
|
|
25424
25530
|
return normalizeNpmImportPathByPlatform(importee, {
|
|
25425
25531
|
platform,
|
|
@@ -25427,10 +25533,11 @@ function normalizeNpmImportByPlatform(platform, importee, dependencies, mode) {
|
|
|
25427
25533
|
alipayNpmMode: mode
|
|
25428
25534
|
});
|
|
25429
25535
|
}
|
|
25430
|
-
function
|
|
25431
|
-
if (!(options?.analysis?.hasStaticRequireLiteral ?? mayContainStaticRequireLiteral(code, { engine: options?.astEngine }))) return
|
|
25536
|
+
function createPlatformNpmImportRewrite(platform, code, dependencies, mode, options) {
|
|
25537
|
+
if (!(options?.analysis?.hasStaticRequireLiteral ?? mayContainStaticRequireLiteral(code, { engine: options?.astEngine }))) return;
|
|
25432
25538
|
try {
|
|
25433
25539
|
const ast = parseJsLike(code);
|
|
25540
|
+
const magicString = new MagicString(code);
|
|
25434
25541
|
let mutated = false;
|
|
25435
25542
|
traverse(ast, { CallExpression(path) {
|
|
25436
25543
|
const callee = path.node?.callee;
|
|
@@ -25443,14 +25550,12 @@ function rewriteChunkNpmImportsByPlatform(platform, code, dependencies, mode, op
|
|
|
25443
25550
|
if (typeof currentValue !== "string") return;
|
|
25444
25551
|
const nextValue = normalizeNpmImportByPlatform(platform, currentValue, dependencies, mode);
|
|
25445
25552
|
if (nextValue === currentValue) return;
|
|
25446
|
-
|
|
25553
|
+
if (typeof firstArg.start !== "number" || typeof firstArg.end !== "number" || firstArg.start < 0 || firstArg.end < firstArg.start) return;
|
|
25554
|
+
magicString.update(firstArg.start, firstArg.end, JSON.stringify(nextValue));
|
|
25447
25555
|
mutated = true;
|
|
25448
25556
|
} });
|
|
25449
|
-
if (
|
|
25450
|
-
|
|
25451
|
-
} catch {
|
|
25452
|
-
return code;
|
|
25453
|
-
}
|
|
25557
|
+
if (mutated) return magicString;
|
|
25558
|
+
} catch {}
|
|
25454
25559
|
}
|
|
25455
25560
|
function rewriteBundleNpmImportsByPlatform(platform, bundle, dependencies, mode, options) {
|
|
25456
25561
|
warmupBundleScriptAnalysis(bundle, {
|
|
@@ -25464,12 +25569,12 @@ function rewriteBundleNpmImportsByPlatform(platform, bundle, dependencies, mode,
|
|
|
25464
25569
|
astEngine: options?.astEngine,
|
|
25465
25570
|
cache: options?.analysisCache
|
|
25466
25571
|
});
|
|
25467
|
-
const
|
|
25572
|
+
const magicString = createPlatformNpmImportRewrite(platform, chunk.code, dependencies, mode, {
|
|
25468
25573
|
...options,
|
|
25469
25574
|
analysis
|
|
25470
25575
|
});
|
|
25471
|
-
if (
|
|
25472
|
-
chunk
|
|
25576
|
+
if (!magicString) continue;
|
|
25577
|
+
applyMagicStringChunkRewrite(chunk, magicString);
|
|
25473
25578
|
rememberChunkScriptAnalysis(chunk, analysis, { cache: options?.analysisCache });
|
|
25474
25579
|
}
|
|
25475
25580
|
}
|
|
@@ -25485,25 +25590,32 @@ function rewriteBundlePlatformApi(bundle, globalName, options) {
|
|
|
25485
25590
|
astEngine: options?.astEngine,
|
|
25486
25591
|
cache: options?.analysisCache
|
|
25487
25592
|
});
|
|
25488
|
-
|
|
25593
|
+
if (analysis && !analysis.hasPlatformApiAccess) continue;
|
|
25594
|
+
const magicString = createMiniProgramPlatformApiRewrite(chunk.code, globalName, {
|
|
25489
25595
|
...options,
|
|
25490
25596
|
analysis
|
|
25491
25597
|
});
|
|
25492
|
-
if (
|
|
25493
|
-
chunk
|
|
25598
|
+
if (!magicString) continue;
|
|
25599
|
+
applyMagicStringChunkRewrite(chunk, magicString);
|
|
25494
25600
|
}
|
|
25495
25601
|
}
|
|
25496
25602
|
function rewriteBundleDynamicGlobalResolution(bundle) {
|
|
25603
|
+
const applyPatternRewrite = (chunk, expression) => {
|
|
25604
|
+
expression.lastIndex = 0;
|
|
25605
|
+
const magicString = new MagicString(chunk.code);
|
|
25606
|
+
for (const match of chunk.code.matchAll(expression)) if (typeof match.index === "number") magicString.update(match.index, match.index + match[0].length, "globalThis");
|
|
25607
|
+
applyMagicStringChunkRewrite(chunk, magicString);
|
|
25608
|
+
};
|
|
25497
25609
|
for (const output of Object.values(bundle)) {
|
|
25498
25610
|
if (output?.type !== "chunk") continue;
|
|
25499
25611
|
const chunk = output;
|
|
25500
25612
|
if (!(chunk.code.includes("Function(") && chunk.code.includes("return this")) && !chunk.code.includes("typeof self<")) continue;
|
|
25501
25613
|
const hasDynamicGlobalResolution = DYNAMIC_GLOBAL_RESOLUTION_RE.test(chunk.code);
|
|
25502
25614
|
DYNAMIC_GLOBAL_RESOLUTION_RE.lastIndex = 0;
|
|
25615
|
+
if (hasDynamicGlobalResolution) applyPatternRewrite(chunk, DYNAMIC_GLOBAL_RESOLUTION_RE);
|
|
25503
25616
|
const hasBrowserGlobalHostTernary = BROWSER_GLOBAL_HOST_TERNARY_RE.test(chunk.code);
|
|
25504
25617
|
BROWSER_GLOBAL_HOST_TERNARY_RE.lastIndex = 0;
|
|
25505
|
-
if (
|
|
25506
|
-
chunk.code = chunk.code.replaceAll(DYNAMIC_GLOBAL_RESOLUTION_RE, "globalThis").replaceAll(BROWSER_GLOBAL_HOST_TERNARY_RE, "globalThis");
|
|
25618
|
+
if (hasBrowserGlobalHostTernary) applyPatternRewrite(chunk, BROWSER_GLOBAL_HOST_TERNARY_RE);
|
|
25507
25619
|
}
|
|
25508
25620
|
}
|
|
25509
25621
|
function matchesSubPackageDependency(dependencies, importee, fallbackDependencies) {
|
|
@@ -25521,43 +25633,6 @@ function matchesSubPackageDependency(dependencies, importee, fallbackDependencie
|
|
|
25521
25633
|
return hasNpmDependencyPrefix(fallbackDependencies, normalized);
|
|
25522
25634
|
}
|
|
25523
25635
|
//#endregion
|
|
25524
|
-
//#region src/utils/sourcemap.ts
|
|
25525
|
-
function isEncodedSourceMapLike(value) {
|
|
25526
|
-
return Boolean(value && typeof value === "object" && "version" in value && typeof value.version === "number" && "mappings" in value && "names" in value && "sources" in value);
|
|
25527
|
-
}
|
|
25528
|
-
function normalizeEncodedSourceMapLike(value) {
|
|
25529
|
-
if (!value || typeof value !== "object") return null;
|
|
25530
|
-
const sourceMap = value;
|
|
25531
|
-
const numericVersion = typeof sourceMap.version === "number" ? sourceMap.version : typeof sourceMap.version === "string" ? Number(sourceMap.version) : NaN;
|
|
25532
|
-
if (!Number.isFinite(numericVersion)) return null;
|
|
25533
|
-
const normalized = {
|
|
25534
|
-
...sourceMap,
|
|
25535
|
-
version: numericVersion
|
|
25536
|
-
};
|
|
25537
|
-
return isEncodedSourceMapLike(normalized) ? normalized : null;
|
|
25538
|
-
}
|
|
25539
|
-
function composeSourceMaps(transformedMap, originalMap) {
|
|
25540
|
-
if (isEncodedSourceMapLike(transformedMap) && isEncodedSourceMapLike(originalMap)) return remapping([transformedMap, originalMap], () => null);
|
|
25541
|
-
if (isEncodedSourceMapLike(transformedMap)) return transformedMap;
|
|
25542
|
-
if (isEncodedSourceMapLike(originalMap)) return originalMap;
|
|
25543
|
-
return null;
|
|
25544
|
-
}
|
|
25545
|
-
//#endregion
|
|
25546
|
-
//#region src/plugins/core/lifecycle/emit/rewrite/sourcemap.ts
|
|
25547
|
-
function applyMagicStringChunkRewrite(chunk, magicString, options) {
|
|
25548
|
-
const previousCode = chunk.code;
|
|
25549
|
-
const nextCode = magicString.toString();
|
|
25550
|
-
if (nextCode === previousCode) return false;
|
|
25551
|
-
const previousMap = normalizeEncodedSourceMapLike(chunk.map);
|
|
25552
|
-
chunk.code = nextCode;
|
|
25553
|
-
if (previousMap) chunk.map = composeSourceMaps(magicString.generateMap({
|
|
25554
|
-
hires: options?.hires ?? "boundary",
|
|
25555
|
-
includeContent: true,
|
|
25556
|
-
source: chunk.fileName
|
|
25557
|
-
}), previousMap);
|
|
25558
|
-
return true;
|
|
25559
|
-
}
|
|
25560
|
-
//#endregion
|
|
25561
25636
|
//#region src/plugins/core/lifecycle/emit/rewrite/localRoot.ts
|
|
25562
25637
|
function isRelativeMiniprogramNpmImport(importee) {
|
|
25563
25638
|
return importee === "miniprogram_npm" || importee.startsWith("./miniprogram_npm/") || importee.startsWith("../miniprogram_npm/") || importee.includes("/miniprogram_npm/");
|
|
@@ -32537,7 +32612,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
32537
32612
|
const { path: appEntryPath } = appEntry;
|
|
32538
32613
|
let configFromVue;
|
|
32539
32614
|
if (!appConfigFile && vueAppPath) {
|
|
32540
|
-
const { extractConfigFromVue } = await import("./file-
|
|
32615
|
+
const { extractConfigFromVue } = await import("./file-CV6ZWiTX.mjs");
|
|
32541
32616
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
32542
32617
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
32543
32618
|
}
|
package/dist/docs/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
|
|
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
|
|
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
|
|
|
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
84
84
|
}
|
|
85
85
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
86
86
|
try {
|
|
87
|
-
const { getCompilerContext } = await import("./getInstance-
|
|
87
|
+
const { getCompilerContext } = await import("./getInstance-HvLRUAtA.mjs");
|
|
88
88
|
const compilerContext = getCompilerContext();
|
|
89
89
|
const service = compilerContext.autoRoutesService;
|
|
90
90
|
const reference = service?.getReference?.();
|
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-
|
|
4
|
+
import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-r2rcHex1.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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.19.
|
|
4
|
+
"version": "6.19.4",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -130,19 +130,19 @@
|
|
|
130
130
|
"@weapp-core/constants": "0.1.16",
|
|
131
131
|
"@weapp-core/init": "6.0.13",
|
|
132
132
|
"@weapp-core/logger": "3.1.1",
|
|
133
|
-
"@weapp-core/schematics": "6.0
|
|
133
|
+
"@weapp-core/schematics": "6.1.0",
|
|
134
134
|
"@weapp-core/shared": "3.1.0",
|
|
135
|
-
"@weapp-vite/ast": "6.19.
|
|
136
|
-
"@weapp-vite/mcp": "1.4.
|
|
137
|
-
"@weapp-vite/miniprogram-automator": "1.2.
|
|
138
|
-
"@weapp-vite/volar": "2.1.
|
|
139
|
-
"@weapp-vite/web": "1.4.
|
|
140
|
-
"@wevu/api": "0.2.
|
|
141
|
-
"@wevu/web-apis": "1.2.
|
|
142
|
-
"rolldown-require": "2.0.
|
|
135
|
+
"@weapp-vite/ast": "6.19.4",
|
|
136
|
+
"@weapp-vite/mcp": "1.4.13",
|
|
137
|
+
"@weapp-vite/miniprogram-automator": "1.2.12",
|
|
138
|
+
"@weapp-vite/volar": "2.1.3",
|
|
139
|
+
"@weapp-vite/web": "1.4.4",
|
|
140
|
+
"@wevu/api": "0.2.15",
|
|
141
|
+
"@wevu/web-apis": "1.2.32",
|
|
142
|
+
"rolldown-require": "2.0.24",
|
|
143
143
|
"vite-plugin-performance": "2.0.1",
|
|
144
|
-
"weapp-ide-cli": "6.0.
|
|
145
|
-
"wevu": "6.19.
|
|
144
|
+
"weapp-ide-cli": "6.0.4",
|
|
145
|
+
"wevu": "6.19.4"
|
|
146
146
|
},
|
|
147
147
|
"publishConfig": {
|
|
148
148
|
"access": "public",
|
package/dist/file-BTZg_nyD.mjs
DELETED