weapp-vite 6.10.0 → 6.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { n as getCompilerContext } from "./createContext-B7PguO6M.mjs";
1
+ import { n as getCompilerContext } from "./createContext-DUM1udUE.mjs";
2
2
  import "./logger-gutcwWKE.mjs";
3
- import "./file-arCdbPgR.mjs";
3
+ import "./file-DT8nNo0D.mjs";
4
4
  //#region src/auto-routes.ts
5
5
  const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
6
6
  function createGetter(resolver) {
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as DEFAULT_MP_PLATFORM, c as createSharedBuildConfig, d as checkRuntime, f as getProjectConfigFileName, i as formatBytes, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as isPathInside, o as normalizeMiniPlatform, p as createCjsConfigLoadError, s as resolveMiniPlatform, t as createCompilerContext, u as resolveWeappConfigFile } from "./createContext-B7PguO6M.mjs";
1
+ import { a as DEFAULT_MP_PLATFORM, c as createSharedBuildConfig, d as checkRuntime, f as getProjectConfigFileName, i as formatBytes, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as isPathInside, o as normalizeMiniPlatform, p as createCjsConfigLoadError, s as resolveMiniPlatform, t as createCompilerContext, u as resolveWeappConfigFile } from "./createContext-DUM1udUE.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-gutcwWKE.mjs";
3
- import { f as VERSION } from "./file-arCdbPgR.mjs";
3
+ import { f as VERSION } from "./file-DT8nNo0D.mjs";
4
4
  import { resolveWeappMcpConfig, startWeappViteMcpServer } from "./mcp.mjs";
5
5
  import { defu } from "@weapp-core/shared";
6
6
  import path, { posix } from "pathe";
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-twds-ZHy.mjs";
2
2
  import { n as applyWeappViteHostMeta } from "./pluginHost-SJdl15d3.mjs";
3
3
  import { n as configureLogger, r as logger_default } from "./logger-gutcwWKE.mjs";
4
- import { _ as vueExtensions, a as findJsEntry, c as findVueEntry, d as touch, g as templateExtensions, h as supportedCssLangs, i as findCssEntry, l as isJsOrTs, m as jsExtensions, n as extractConfigFromVue, o as findJsonEntry, p as configExtensions, s as findTemplateEntry, t as changeFileExtension, u as isTemplate } from "./file-arCdbPgR.mjs";
4
+ import { _ as vueExtensions, a as findJsEntry, c as findVueEntry, d as touch, g as templateExtensions, h as supportedCssLangs, i as findCssEntry, l as isJsOrTs, m as jsExtensions, n as extractConfigFromVue, o as findJsonEntry, p as configExtensions, s as findTemplateEntry, t as changeFileExtension, u as isTemplate } from "./file-DT8nNo0D.mjs";
5
5
  import { createRequire, isBuiltin } from "node:module";
6
6
  import { addExtension, defu, get, isEmptyObject, isObject, objectHash, removeExtension, removeExtensionDeep, set } from "@weapp-core/shared";
7
7
  import { LRUCache } from "lru-cache";
@@ -9773,6 +9773,7 @@ function useLoadEntry(ctx, options) {
9773
9773
  const entriesMap = /* @__PURE__ */ new Map();
9774
9774
  const loadedEntrySet = /* @__PURE__ */ new Set();
9775
9775
  const dirtyEntrySet = /* @__PURE__ */ new Set();
9776
+ const dirtyEntryReasons = /* @__PURE__ */ new Map();
9776
9777
  const resolvedEntryMap = /* @__PURE__ */ new Map();
9777
9778
  const jsonEmitManager = createJsonEmitManager(ctx.configService);
9778
9779
  const registerJsonAsset = jsonEmitManager.register.bind(jsonEmitManager);
@@ -9804,59 +9805,64 @@ function useLoadEntry(ctx, options) {
9804
9805
  resolvedEntryMap,
9805
9806
  jsonEmitFilesMap: jsonEmitManager.map,
9806
9807
  normalizeEntry,
9807
- markEntryDirty(entryId) {
9808
+ markEntryDirty(entryId, reason = "direct") {
9808
9809
  dirtyEntrySet.add(entryId);
9810
+ dirtyEntryReasons.set(entryId, reason);
9809
9811
  loadedEntrySet.delete(entryId);
9810
9812
  },
9811
9813
  async emitDirtyEntries() {
9812
9814
  if (!dirtyEntrySet.size) {
9813
9815
  options?.hmr?.setDidEmitAllEntries?.(false);
9816
+ options?.hmr?.setLastEmittedEntries?.(/* @__PURE__ */ new Set());
9814
9817
  return;
9815
9818
  }
9816
9819
  const dirtyCount = dirtyEntrySet.size;
9817
- const pending = [];
9818
- const shouldEmitAllEntries = resolveShouldEmitAllEntries({
9820
+ const pendingEntryIds = resolvePendingEntryIds({
9819
9821
  isDev: Boolean(ctx.configService?.isDev),
9820
9822
  mode: hmrSharedChunksMode,
9821
- dirtyEntrySet,
9822
9823
  resolvedEntryMap,
9824
+ dirtyEntrySet,
9825
+ dirtyEntryReasons,
9823
9826
  sharedChunkImporters: hmrSharedChunkImporters
9824
9827
  });
9828
+ const pending = [];
9829
+ const shouldEmitAllEntries = pendingEntryIds.size > 0 && pendingEntryIds.size === resolvedEntryMap.size;
9825
9830
  options?.hmr?.setDidEmitAllEntries?.(shouldEmitAllEntries);
9826
- if (shouldEmitAllEntries) {
9827
- const seen = /* @__PURE__ */ new Set();
9828
- for (const resolvedId of resolvedEntryMap.values()) {
9829
- if (!resolvedId) continue;
9830
- const key = resolvedId.id;
9831
- if (seen.has(key)) continue;
9832
- seen.add(key);
9833
- pending.push(resolvedId);
9834
- }
9835
- dirtyEntrySet.clear();
9836
- } else for (const entryId of Array.from(dirtyEntrySet)) {
9831
+ options?.hmr?.setLastEmittedEntries?.(new Set(pendingEntryIds));
9832
+ for (const entryId of pendingEntryIds) {
9837
9833
  const resolvedId = resolvedEntryMap.get(entryId);
9838
9834
  if (!resolvedId) continue;
9839
9835
  pending.push(resolvedId);
9840
9836
  dirtyEntrySet.delete(entryId);
9837
+ dirtyEntryReasons.delete(entryId);
9841
9838
  }
9842
9839
  if (debug) debug(`hmr emit dirty=${dirtyCount} resolved=${resolvedEntryMap.size} emitAll=${shouldEmitAllEntries} pending=${pending.length}`);
9843
9840
  if (pending.length) await Promise.all(emitEntriesChunks.call(this, pending));
9844
9841
  }
9845
9842
  };
9846
9843
  }
9847
- function resolveShouldEmitAllEntries(options) {
9848
- if (!options.isDev || options.resolvedEntryMap.size === 0) return false;
9849
- if (options.mode === "full") return true;
9850
- if (options.mode === "off") return false;
9851
- if (!options.sharedChunkImporters) return true;
9852
- if (options.sharedChunkImporters.size === 0) return false;
9844
+ function resolvePendingEntryIds(options) {
9845
+ const pending = new Set(options.dirtyEntrySet);
9846
+ if (options.mode === "full") return new Set(options.resolvedEntryMap.keys());
9847
+ if (!options.isDev || options.mode === "off") return pending;
9848
+ let hasDependencyDrivenEntry = false;
9849
+ for (const entryId of options.dirtyEntrySet) if (options.dirtyEntryReasons.get(entryId) === "dependency") {
9850
+ hasDependencyDrivenEntry = true;
9851
+ break;
9852
+ }
9853
+ if (!hasDependencyDrivenEntry) return pending;
9854
+ if (!options.sharedChunkImporters?.size) return pending;
9853
9855
  for (const importers of options.sharedChunkImporters.values()) {
9854
9856
  if (importers.size <= 1) continue;
9855
- let dirtyCount = 0;
9856
- for (const importer of importers) if (options.dirtyEntrySet.has(importer)) dirtyCount += 1;
9857
- if (dirtyCount > 0 && dirtyCount < importers.size) return true;
9857
+ let hasDependencyDrivenImporter = false;
9858
+ for (const importer of importers) if (options.dirtyEntrySet.has(importer) && options.dirtyEntryReasons.get(importer) === "dependency") {
9859
+ hasDependencyDrivenImporter = true;
9860
+ break;
9861
+ }
9862
+ if (!hasDependencyDrivenImporter) continue;
9863
+ for (const importer of importers) pending.add(importer);
9858
9864
  }
9859
- return false;
9865
+ return pending;
9860
9866
  }
9861
9867
  //#endregion
9862
9868
  //#region src/utils/wxmlScriptModule.ts
@@ -10256,6 +10262,17 @@ function refreshModuleGraph(pluginCtx, state) {
10256
10262
  }
10257
10263
  function refreshSharedChunkImporters(bundle, state) {
10258
10264
  state.hmrSharedChunkImporters.clear();
10265
+ appendSharedChunkImporters(bundle, state);
10266
+ }
10267
+ function refreshPartialSharedChunkImporters(bundle, state, entryIds) {
10268
+ if (!entryIds.size) return;
10269
+ for (const [chunkId, importers] of state.hmrSharedChunkImporters) {
10270
+ for (const entryId of entryIds) importers.delete(entryId);
10271
+ if (importers.size === 0) state.hmrSharedChunkImporters.delete(chunkId);
10272
+ }
10273
+ appendSharedChunkImporters(bundle, state, entryIds);
10274
+ }
10275
+ function appendSharedChunkImporters(bundle, state, onlyEntryIds) {
10259
10276
  const isEntryChunk = (chunk) => {
10260
10277
  if (chunk.isEntry) return true;
10261
10278
  if (!chunk.facadeModuleId) return false;
@@ -10269,6 +10286,7 @@ function refreshSharedChunkImporters(bundle, state) {
10269
10286
  if (!chunk.facadeModuleId) continue;
10270
10287
  if (!isEntryChunk(chunk)) continue;
10271
10288
  const entryId = normalizeFsResolvedId(chunk.facadeModuleId);
10289
+ if (onlyEntryIds && !onlyEntryIds.has(entryId)) continue;
10272
10290
  entryChunks.push({
10273
10291
  entryId,
10274
10292
  chunk
@@ -10597,6 +10615,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
10597
10615
  let redundantBytesTotal = 0;
10598
10616
  if (configService.isDev && state.hmrSharedChunksMode === "auto") {
10599
10617
  if (state.hmrState.didEmitAllEntries || !state.hmrState.hasBuiltOnce) refreshSharedChunkImporters(rolldownBundle, state);
10618
+ else if (state.hmrState.lastEmittedEntryIds?.size) refreshPartialSharedChunkImporters(rolldownBundle, state, state.hmrState.lastEmittedEntryIds);
10600
10619
  state.hmrState.hasBuiltOnce = true;
10601
10620
  }
10602
10621
  function matchSubPackage(filePath) {
@@ -11639,13 +11658,13 @@ function createWatchChangeHook(state) {
11639
11658
  const ext = path.extname(normalizedId);
11640
11659
  return ext ? normalizedId.slice(0, -ext.length) : normalizedId;
11641
11660
  })());
11642
- if (primaryScript.path) markEntryDirty(normalizeFsResolvedId(primaryScript.path));
11661
+ if (primaryScript.path) markEntryDirty(normalizeFsResolvedId(primaryScript.path), "direct");
11643
11662
  }
11644
11663
  }
11645
- if (loadedEntrySet.has(normalizedId)) markEntryDirty(normalizedId);
11664
+ if (loadedEntrySet.has(normalizedId)) markEntryDirty(normalizedId, "direct");
11646
11665
  else if (state.moduleImporters.size && state.entryModuleIds.size) {
11647
11666
  const affected = collectAffectedEntries(state, normalizedId);
11648
- if (affected.size) for (const entryId of affected) markEntryDirty(entryId);
11667
+ if (affected.size) for (const entryId of affected) markEntryDirty(entryId, "dependency");
11649
11668
  }
11650
11669
  const relativeSrc = configService.relativeAbsoluteSrcRoot(normalizedId);
11651
11670
  const relativeCwd = configService.relativeCwd(normalizedId);
@@ -11769,7 +11788,8 @@ function weappVite(ctx, subPackageMeta) {
11769
11788
  const hmrSharedChunkImporters = /* @__PURE__ */ new Map();
11770
11789
  const hmrState = {
11771
11790
  didEmitAllEntries: false,
11772
- hasBuiltOnce: false
11791
+ hasBuiltOnce: false,
11792
+ lastEmittedEntryIds: /* @__PURE__ */ new Set()
11773
11793
  };
11774
11794
  const { loadEntry, loadedEntrySet, jsonEmitFilesMap, entriesMap, resolvedEntryMap, markEntryDirty, emitDirtyEntries } = useLoadEntry(ctx, {
11775
11795
  buildTarget,
@@ -11778,6 +11798,9 @@ function weappVite(ctx, subPackageMeta) {
11778
11798
  sharedChunkImporters: hmrSharedChunkImporters,
11779
11799
  setDidEmitAllEntries: (value) => {
11780
11800
  hmrState.didEmitAllEntries = value;
11801
+ },
11802
+ setLastEmittedEntries: (entryIds) => {
11803
+ hmrState.lastEmittedEntryIds = new Set(entryIds);
11781
11804
  }
11782
11805
  }
11783
11806
  });
@@ -15848,7 +15871,7 @@ function createScanService(ctx) {
15848
15871
  let vueAppPath;
15849
15872
  if (!appEntryPath) vueAppPath = await findVueEntry(appBasename);
15850
15873
  if (!appConfigFile && vueAppPath) {
15851
- const { extractConfigFromVue } = await import("./file-arCdbPgR.mjs").then((n) => n.r);
15874
+ const { extractConfigFromVue } = await import("./file-DT8nNo0D.mjs").then((n) => n.r);
15852
15875
  configFromVue = await extractConfigFromVue(vueAppPath);
15853
15876
  if (configFromVue) appConfigFile = vueAppPath;
15854
15877
  }
@@ -78,7 +78,7 @@ function resolveAutoRoutesMacroImportPath() {
78
78
  }
79
79
  async function resolveAutoRoutesInlineSnapshot() {
80
80
  try {
81
- const { getCompilerContext } = await import("./createContext-B7PguO6M.mjs").then((n) => n.r);
81
+ const { getCompilerContext } = await import("./createContext-DUM1udUE.mjs").then((n) => n.r);
82
82
  const compilerContext = getCompilerContext();
83
83
  const service = compilerContext.autoRoutesService;
84
84
  const reference = service?.getReference?.();
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson } from "./json.mjs";
2
2
  import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-SJdl15d3.mjs";
3
3
  import { defineConfig } from "./config.mjs";
4
- import { t as createCompilerContext } from "./createContext-B7PguO6M.mjs";
4
+ import { t as createCompilerContext } from "./createContext-DUM1udUE.mjs";
5
5
  import "./logger-gutcwWKE.mjs";
6
- import "./file-arCdbPgR.mjs";
6
+ import "./file-DT8nNo0D.mjs";
7
7
  import { defineEmits, defineProps } from "./runtime.mjs";
8
8
  import { createWevuComponent } from "wevu";
9
9
  export { WEAPP_VITE_HOST_NAME, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.10.0",
4
+ "version": "6.10.1",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -117,7 +117,7 @@
117
117
  "@weapp-core/logger": "3.1.1",
118
118
  "@weapp-core/schematics": "6.0.4",
119
119
  "@weapp-core/shared": "3.0.2",
120
- "@weapp-vite/ast": "6.10.0",
120
+ "@weapp-vite/ast": "6.10.1",
121
121
  "@weapp-vite/mcp": "1.1.1",
122
122
  "@weapp-vite/volar": "2.0.7",
123
123
  "@weapp-vite/web": "1.3.5",
@@ -125,7 +125,7 @@
125
125
  "rolldown-require": "2.0.8",
126
126
  "vite-plugin-performance": "2.0.1",
127
127
  "weapp-ide-cli": "5.1.1",
128
- "wevu": "6.10.0"
128
+ "wevu": "6.10.1"
129
129
  },
130
130
  "publishConfig": {
131
131
  "access": "public",