weapp-vite 6.13.0 → 6.13.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.
package/README.md CHANGED
@@ -166,10 +166,13 @@ wv ide logs --open
166
166
  ```sh
167
167
  weapp-vite preview --project ./dist/build/mp-weixin
168
168
  weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
169
+ weapp-vite cache --clean compile
170
+ weapp-vite cache --clean all
169
171
  weapp-vite config lang zh
170
172
  weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
171
173
  # 等价写法
172
174
  wv preview --project ./dist/build/mp-weixin
175
+ wv cache --clean all
173
176
  ```
174
177
 
175
178
  也支持命名空间写法:
@@ -1,2 +1,2 @@
1
- import { a as ExternalMetadataFileCandidates, c as Resolver, d as ResolverObject, i as CreateResolver, l as ResolverFn, n as VantResolver, o as Options, r as TDesignResolver, s as ResolvedValue, t as WeuiResolver, u as ResolverMeta } from "../index-BQqQ_BLM.mjs";
1
+ import { a as ExternalMetadataFileCandidates, c as Resolver, d as ResolverObject, i as CreateResolver, l as ResolverFn, n as VantResolver, o as Options, r as TDesignResolver, s as ResolvedValue, t as WeuiResolver, u as ResolverMeta } from "../index-B5wBsuYI.mjs";
2
2
  export { CreateResolver, ExternalMetadataFileCandidates, Options, ResolvedValue, Resolver, ResolverFn, ResolverMeta, ResolverObject, TDesignResolver, VantResolver, WeuiResolver };
@@ -1,4 +1,4 @@
1
- import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-DUBjYF43.mjs";
1
+ import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-o20IHwXa.mjs";
2
2
 
3
3
  //#region src/auto-routes.d.ts
4
4
  declare const routes: AutoRoutes;
@@ -1,4 +1,4 @@
1
- import { i as getCompilerContext, l as getRouteRuntimeGlobalKeys } from "./createContext-CZ7Kunvn.mjs";
1
+ import { i as getCompilerContext, l as getRouteRuntimeGlobalKeys } from "./createContext-CwnO-Jw3.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 { _ as getDefaultIdeProjectRoot, b as shouldPassPlatformArgToIdeOpen, c as SHARED_CHUNK_VIRTUAL_PREFIX, d as checkRuntime, f as getProjectConfigFileName, g as DEFAULT_MP_PLATFORM, h as createCjsConfigLoadError, m as parseCommentJson, n as syncProjectSupportFiles, o as formatBytes, p as loadViteConfigFile, r as syncManagedTsconfigBootstrapFiles, s as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappConfigFile, v as normalizeMiniPlatform, x as isPathInside, y as resolveMiniPlatform } from "./createContext-CZ7Kunvn.mjs";
1
+ import { _ as getDefaultIdeProjectRoot, b as shouldPassPlatformArgToIdeOpen, c as SHARED_CHUNK_VIRTUAL_PREFIX, d as checkRuntime, f as getProjectConfigFileName, g as DEFAULT_MP_PLATFORM, h as createCjsConfigLoadError, m as parseCommentJson, n as syncProjectSupportFiles, o as formatBytes, p as loadViteConfigFile, r as syncManagedTsconfigBootstrapFiles, s as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappConfigFile, v as normalizeMiniPlatform, x as isPathInside, y as resolveMiniPlatform } from "./createContext-CwnO-Jw3.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-gutcwWKE.mjs";
3
- import { p as VERSION } from "./file-DwwblEq4.mjs";
3
+ import { p as VERSION } from "./file-WyRp0uK0.mjs";
4
4
  import { resolveWeappMcpConfig, startWeappViteMcpServer } from "./mcp.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import { defu } from "@weapp-core/shared";
@@ -1,5 +1,5 @@
1
- import { c as Resolver, s as ResolvedValue } from "./index-BQqQ_BLM.mjs";
2
- import { t as AutoRoutes } from "./routes-DUBjYF43.mjs";
1
+ import { c as Resolver, s as ResolvedValue } from "./index-B5wBsuYI.mjs";
2
+ import { t as AutoRoutes } from "./routes-o20IHwXa.mjs";
3
3
  import { LRUCache } from "lru-cache";
4
4
  import { LoggerConfig } from "@weapp-core/logger";
5
5
  import { WeappAstConfig } from "@weapp-vite/ast";
package/dist/config.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { An as createWeappViteHostMeta, Dn as WeappViteHostMeta, En as WEAPP_VITE_HOST_NAME, Mn as resolveWeappViteHostMeta, On as WeappViteRuntime, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, jn as isWeappViteHost, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-B3HNOAZo.mjs";
1
+ import { An as createWeappViteHostMeta, Dn as WeappViteHostMeta, En as WEAPP_VITE_HOST_NAME, Mn as resolveWeappViteHostMeta, On as WeappViteRuntime, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, jn as isWeappViteHost, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-WBWY_UlE.mjs";
2
2
  export { App, Component, Page, Sitemap, Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, WeappViteConfig, WeappViteHostMeta, WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
@@ -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 templateExtensions, a as findJsEntry, c as findVueEntry, d as isTemplate, f as touch, g as supportedCssLangs, h as jsExtensions, i as findCssEntry, l as inlineAutoRoutesImports, m as configExtensions, n as extractConfigFromVue, o as findJsonEntry, s as findTemplateEntry, t as changeFileExtension, u as isJsOrTs, v as vueExtensions } from "./file-DwwblEq4.mjs";
4
+ import { _ as templateExtensions, a as findJsEntry, c as findVueEntry, d as isTemplate, f as touch, g as supportedCssLangs, h as jsExtensions, i as findCssEntry, l as inlineAutoRoutesImports, m as configExtensions, n as extractConfigFromVue, o as findJsonEntry, s as findTemplateEntry, t as changeFileExtension, u as isJsOrTs, v as vueExtensions } from "./file-WyRp0uK0.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";
@@ -8195,6 +8195,13 @@ function normalizeSharedPathCandidate(absoluteId) {
8195
8195
  stripLeadingNullByte: true
8196
8196
  });
8197
8197
  }
8198
+ function resolveNodeModulesSharedPath(cleanedAbsoluteId) {
8199
+ const normalized = cleanedAbsoluteId.replaceAll("\\", "/");
8200
+ const markerIndex = normalized.lastIndexOf("/node_modules/");
8201
+ if (markerIndex < 0) return;
8202
+ const packageRelativePath = normalizeNpmImportLookupPath(normalized.slice(markerIndex));
8203
+ return packageRelativePath ? normalizeRelativePath(packageRelativePath) : void 0;
8204
+ }
8198
8205
  function createStringOrRegExpMatcher(pattern) {
8199
8206
  if (typeof pattern === "string") {
8200
8207
  const matcher = picomatch(pattern, { dot: true });
@@ -8237,7 +8244,7 @@ function createSharedPathResolver(configService, sharedPathRoot) {
8237
8244
  return (absoluteId) => {
8238
8245
  const cleaned = normalizeSharedPathCandidate(absoluteId);
8239
8246
  if (!path.isAbsolute(cleaned)) return;
8240
- if (!isPathInside(resolvedRoot, cleaned)) return;
8247
+ if (!isPathInside(resolvedRoot, cleaned)) return resolveNodeModulesSharedPath(cleaned);
8241
8248
  return normalizeRelativePath(path.relative(resolvedRoot, cleaned));
8242
8249
  };
8243
8250
  }
@@ -8820,27 +8827,93 @@ function createOxcRuntimeSupport() {
8820
8827
  }
8821
8828
  //#endregion
8822
8829
  //#region src/runtime/packageAliases.ts
8823
- const SPECIAL_PACKAGE_ALIASES = [{
8824
- packageName: "class-variance-authority",
8825
- distEntry: "dist/index.js"
8826
- }];
8827
- const SPECIFIER_ALIASES = [{
8828
- find: "vue-demi",
8829
- replacement: "wevu/vue-demi"
8830
- }];
8830
+ const WEVU_WORKSPACE_PACKAGE_PATH = "packages-runtime/wevu";
8831
+ const PACKAGE_ALIASES = [
8832
+ {
8833
+ find: "class-variance-authority",
8834
+ packageName: "class-variance-authority",
8835
+ distEntry: "dist/index.js"
8836
+ },
8837
+ {
8838
+ find: "wevu",
8839
+ packageName: "wevu",
8840
+ distEntry: "dist/index.mjs",
8841
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8842
+ },
8843
+ {
8844
+ find: "wevu/compiler",
8845
+ packageName: "wevu",
8846
+ distEntry: "dist/compiler.mjs",
8847
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8848
+ },
8849
+ {
8850
+ find: "wevu/jsx-runtime",
8851
+ packageName: "wevu",
8852
+ distEntry: "dist/jsx-runtime.mjs",
8853
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8854
+ },
8855
+ {
8856
+ find: "wevu/store",
8857
+ packageName: "wevu",
8858
+ distEntry: "dist/store.mjs",
8859
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8860
+ },
8861
+ {
8862
+ find: "wevu/api",
8863
+ packageName: "wevu",
8864
+ distEntry: "dist/api.mjs",
8865
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8866
+ },
8867
+ {
8868
+ find: "wevu/fetch",
8869
+ packageName: "wevu",
8870
+ distEntry: "dist/fetch.mjs",
8871
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8872
+ },
8873
+ {
8874
+ find: "wevu/router",
8875
+ packageName: "wevu",
8876
+ distEntry: "dist/router.mjs",
8877
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8878
+ },
8879
+ {
8880
+ find: "vue-demi",
8881
+ packageName: "wevu",
8882
+ distEntry: "dist/vue-demi.mjs",
8883
+ fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
8884
+ }
8885
+ ];
8886
+ function resolveRepoRoot(fromDir) {
8887
+ let currentDir = fromDir;
8888
+ while (true) {
8889
+ if (existsSync(path.join(currentDir, "pnpm-workspace.yaml"))) return currentDir;
8890
+ const parentDir = path.dirname(currentDir);
8891
+ if (parentDir === currentDir) return;
8892
+ currentDir = parentDir;
8893
+ }
8894
+ }
8895
+ function resolvePackageEntry(packageName, distEntry, fallbackWorkspacePackagePath) {
8896
+ const packageInfo = getPackageInfoSync(packageName);
8897
+ if (packageInfo) {
8898
+ const resolvedEntry = path.resolve(packageInfo.rootPath, distEntry);
8899
+ if (existsSync(resolvedEntry)) return resolvedEntry;
8900
+ }
8901
+ if (!fallbackWorkspacePackagePath) return;
8902
+ const repoRoot = resolveRepoRoot(path.dirname(fileURLToPath(import.meta.url)));
8903
+ if (!repoRoot) return;
8904
+ const fallbackEntry = path.resolve(repoRoot, fallbackWorkspacePackagePath, distEntry);
8905
+ if (existsSync(fallbackEntry)) return fallbackEntry;
8906
+ }
8831
8907
  function resolveBuiltinPackageAliases() {
8832
8908
  const aliases = [];
8833
- for (const { packageName, distEntry } of SPECIAL_PACKAGE_ALIASES) {
8834
- const info = getPackageInfoSync(packageName);
8835
- if (!info) continue;
8836
- const resolvedEntry = path.resolve(info.rootPath, distEntry);
8837
- if (!existsSync(resolvedEntry)) continue;
8909
+ for (const { find, packageName, distEntry, fallbackWorkspacePackagePath } of PACKAGE_ALIASES) {
8910
+ const resolvedEntry = resolvePackageEntry(packageName, distEntry, fallbackWorkspacePackagePath);
8911
+ if (!resolvedEntry) continue;
8838
8912
  aliases.push({
8839
- find: packageName,
8913
+ find,
8840
8914
  replacement: resolvedEntry
8841
8915
  });
8842
8916
  }
8843
- aliases.push(...SPECIFIER_ALIASES);
8844
8917
  return aliases;
8845
8918
  }
8846
8919
  //#endregion
@@ -9806,7 +9879,7 @@ function asset(ctx) {
9806
9879
  const LEADING_DOT_SLASH_RE$2 = /^\.\//;
9807
9880
  const LEADING_SLASHES_RE$2 = /^\/+/;
9808
9881
  const GLOB_WILDCARD_RE = /[*?[{]/;
9809
- const TRAILING_SLASHES_RE$2 = /\/+$/;
9882
+ const TRAILING_SLASHES_RE$1 = /\/+$/;
9810
9883
  const AUTO_IMPORT_WATCHER_KEY = "__auto-import-vue-watcher__";
9811
9884
  function isEnabledOutputOption(option) {
9812
9885
  if (option === true) return true;
@@ -9870,7 +9943,7 @@ function registerAutoImportWatchTargets(state, globs, registrar, options = {}) {
9870
9943
  for (const pattern of globs ?? []) {
9871
9944
  const normalizedPattern = toPosixPath(pattern).replace(LEADING_DOT_SLASH_RE$2, "").replace(LEADING_SLASHES_RE$2, "");
9872
9945
  const wildcardIndex = normalizedPattern.search(GLOB_WILDCARD_RE);
9873
- const cleanedBase = (wildcardIndex >= 0 ? normalizedPattern.slice(0, wildcardIndex) : normalizedPattern).replace(TRAILING_SLASHES_RE$2, "");
9946
+ const cleanedBase = (wildcardIndex >= 0 ? normalizedPattern.slice(0, wildcardIndex) : normalizedPattern).replace(TRAILING_SLASHES_RE$1, "");
9874
9947
  if (!cleanedBase) continue;
9875
9948
  watchTargets.add(path.resolve(configService.absoluteSrcRoot, cleanedBase));
9876
9949
  }
@@ -11823,8 +11896,6 @@ function createTemplateScanner(wxmlService, debug) {
11823
11896
  }
11824
11897
  //#endregion
11825
11898
  //#region src/plugins/hooks/useLoadEntry/index.ts
11826
- const LEADING_RELATIVE_SEGMENTS_RE = /^[./]+/;
11827
- const TRAILING_SLASHES_RE$1 = /\/+$/;
11828
11899
  function useLoadEntry(ctx, options) {
11829
11900
  const debug = createDebugger("weapp-vite:load-entry");
11830
11901
  const buildTarget = options?.buildTarget ?? "app";
@@ -11931,54 +12002,23 @@ function resolvePendingEntryIds(options) {
11931
12002
  const pending = new Set(options.dirtyEntrySet);
11932
12003
  if (options.mode === "full") return new Set(options.resolvedEntryMap.keys());
11933
12004
  if (!options.isDev || options.mode === "off") return pending;
11934
- let hasDependencyDrivenEntry = false;
11935
- for (const entryId of options.dirtyEntrySet) if (options.dirtyEntryReasons.get(entryId) === "dependency") {
11936
- hasDependencyDrivenEntry = true;
11937
- break;
11938
- }
11939
12005
  if (!options.sharedChunkImporters?.size) return pending;
11940
- if (!hasDependencyDrivenEntry && !hasCrossPackageDirectDirtyImporter(options)) return pending;
11941
12006
  for (const importers of options.sharedChunkImporters.values()) {
11942
12007
  if (importers.size <= 1) continue;
11943
12008
  let hasDependencyDrivenImporter = false;
11944
- for (const importer of importers) if (options.dirtyEntrySet.has(importer) && options.dirtyEntryReasons.get(importer) === "dependency") {
11945
- hasDependencyDrivenImporter = true;
11946
- break;
11947
- }
11948
- if (!hasDependencyDrivenImporter) {
11949
- if (!shouldExpandDirectUpdateAcrossPackageScopes(importers, options)) continue;
12009
+ let hasDirectDirtyImporter = false;
12010
+ for (const importer of importers) {
12011
+ if (options.dirtyEntrySet.has(importer) && options.dirtyEntryReasons.get(importer) === "dependency") {
12012
+ hasDependencyDrivenImporter = true;
12013
+ break;
12014
+ }
12015
+ if (options.dirtyEntrySet.has(importer) && options.dirtyEntryReasons.get(importer) === "direct") hasDirectDirtyImporter = true;
11950
12016
  }
12017
+ if (!hasDependencyDrivenImporter && !hasDirectDirtyImporter) continue;
11951
12018
  for (const importer of importers) pending.add(importer);
11952
12019
  }
11953
12020
  return pending;
11954
12021
  }
11955
- function shouldExpandDirectUpdateAcrossPackageScopes(importers, options) {
11956
- let hasDirectDirtyImporter = false;
11957
- const scopes = /* @__PURE__ */ new Set();
11958
- for (const importer of importers) {
11959
- if (options.dirtyEntrySet.has(importer) && options.dirtyEntryReasons.get(importer) === "direct") hasDirectDirtyImporter = true;
11960
- const scope = resolveEntryPackageScope(importer, options.subPackageRoots, options.relativeAbsoluteSrcRoot);
11961
- scopes.add(scope);
11962
- if (scopes.size > 1 && hasDirectDirtyImporter) return true;
11963
- }
11964
- return false;
11965
- }
11966
- function hasCrossPackageDirectDirtyImporter(options) {
11967
- for (const importers of options.sharedChunkImporters?.values() ?? []) {
11968
- if (importers.size <= 1) continue;
11969
- if (shouldExpandDirectUpdateAcrossPackageScopes(importers, options)) return true;
11970
- }
11971
- return false;
11972
- }
11973
- function resolveEntryPackageScope(entryId, subPackageRoots, relativeAbsoluteSrcRoot) {
11974
- const normalized = (relativeAbsoluteSrcRoot?.(entryId) ?? entryId).replace(LEADING_RELATIVE_SEGMENTS_RE, "");
11975
- for (const root of subPackageRoots ?? []) {
11976
- const normalizedRoot = posix.normalize(root).replace(LEADING_RELATIVE_SEGMENTS_RE, "").replace(TRAILING_SLASHES_RE$1, "");
11977
- if (!normalizedRoot) continue;
11978
- if (normalized === normalizedRoot || normalized.startsWith(`${normalizedRoot}/`)) return normalizedRoot;
11979
- }
11980
- return "";
11981
- }
11982
12022
  //#endregion
11983
12023
  //#region src/utils/wxmlScriptModule.ts
11984
12024
  const IMPORT_SJS_TAG_RE = /<import-sjs([\s\S]*?)>/g;
@@ -12458,37 +12498,32 @@ function refreshModuleGraph(pluginCtx, state) {
12458
12498
  if (importers.size) state.moduleImporters.set(normalizedId, importers);
12459
12499
  }
12460
12500
  }
12461
- function refreshSharedChunkImporters(bundle, state) {
12462
- state.hmrSharedChunkImporters.clear();
12463
- appendSharedChunkImporters(bundle, state);
12464
- }
12465
- function refreshPartialSharedChunkImporters(bundle, state, entryIds) {
12466
- if (!entryIds.size) return;
12467
- for (const [chunkId, importers] of state.hmrSharedChunkImporters) {
12468
- for (const entryId of entryIds) importers.delete(entryId);
12469
- if (importers.size === 0) state.hmrSharedChunkImporters.delete(chunkId);
12470
- }
12471
- appendSharedChunkImporters(bundle, state, entryIds);
12472
- }
12473
12501
  function appendSharedChunkImporters(bundle, state, onlyEntryIds) {
12474
- const isEntryChunk = (chunk) => {
12475
- if (chunk.isEntry) return true;
12476
- if (!chunk.facadeModuleId) return false;
12477
- const entryId = normalizeFsResolvedId(chunk.facadeModuleId);
12478
- return state.resolvedEntryMap.has(entryId);
12502
+ const getTrackedImporterIds = (chunk) => {
12503
+ const trackedImporterIds = /* @__PURE__ */ new Set();
12504
+ if (chunk.facadeModuleId) {
12505
+ const entryId = normalizeFsResolvedId(chunk.facadeModuleId);
12506
+ if (chunk.isEntry || state.resolvedEntryMap.has(entryId)) trackedImporterIds.add(entryId);
12507
+ }
12508
+ if (Array.isArray(chunk.moduleIds)) for (const moduleId of chunk.moduleIds) {
12509
+ const normalizedModuleId = normalizeFsResolvedId(moduleId);
12510
+ if (state.resolvedEntryMap.has(normalizedModuleId)) trackedImporterIds.add(normalizedModuleId);
12511
+ }
12512
+ return trackedImporterIds;
12479
12513
  };
12480
12514
  const entryChunks = [];
12481
12515
  for (const output of Object.values(bundle)) {
12482
12516
  if (output?.type !== "chunk") continue;
12483
12517
  const chunk = output;
12484
- if (!chunk.facadeModuleId) continue;
12485
- if (!isEntryChunk(chunk)) continue;
12486
- const entryId = normalizeFsResolvedId(chunk.facadeModuleId);
12487
- if (onlyEntryIds && !onlyEntryIds.has(entryId)) continue;
12488
- entryChunks.push({
12489
- entryId,
12490
- chunk
12491
- });
12518
+ const trackedImporterIds = getTrackedImporterIds(chunk);
12519
+ if (!trackedImporterIds.size) continue;
12520
+ for (const trackedImporterId of trackedImporterIds) {
12521
+ if (onlyEntryIds && !onlyEntryIds.has(trackedImporterId)) continue;
12522
+ entryChunks.push({
12523
+ entryId: trackedImporterId,
12524
+ chunk
12525
+ });
12526
+ }
12492
12527
  }
12493
12528
  if (!entryChunks.length) return;
12494
12529
  for (const { chunk, entryId } of entryChunks) {
@@ -12499,13 +12534,25 @@ function appendSharedChunkImporters(bundle, state, onlyEntryIds) {
12499
12534
  for (const imported of imports) {
12500
12535
  const target = bundle[imported];
12501
12536
  if (!target || target.type !== "chunk") continue;
12502
- if (isEntryChunk(target)) continue;
12537
+ if (getTrackedImporterIds(target).size) continue;
12503
12538
  const current = state.hmrSharedChunkImporters.get(imported);
12504
12539
  if (current) current.add(entryId);
12505
12540
  else state.hmrSharedChunkImporters.set(imported, new Set([entryId]));
12506
12541
  }
12507
12542
  }
12508
12543
  }
12544
+ function refreshSharedChunkImporters(bundle, state) {
12545
+ state.hmrSharedChunkImporters.clear();
12546
+ appendSharedChunkImporters(bundle, state);
12547
+ }
12548
+ function refreshPartialSharedChunkImporters(bundle, state, entryIds) {
12549
+ if (!entryIds.size) return;
12550
+ for (const [chunkId, importers] of state.hmrSharedChunkImporters) {
12551
+ for (const entryId of entryIds) importers.delete(entryId);
12552
+ if (importers.size === 0) state.hmrSharedChunkImporters.delete(chunkId);
12553
+ }
12554
+ appendSharedChunkImporters(bundle, state, entryIds);
12555
+ }
12509
12556
  //#endregion
12510
12557
  //#region src/plugins/core/helpers/independent.ts
12511
12558
  async function flushIndependentBuilds(state) {
@@ -12713,7 +12760,7 @@ const PRETTY_NODE_MODULES_RE = /node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?
12713
12760
  const REQUEST_GLOBAL_EXPORT_RE = /Object\.defineProperty\(exports,\s*(?:`([^`]+)`|'([^']+)'|"([^"]+)"),\s*\{[\s\S]*?get:function\(\)\{return ([A-Za-z_$][\w$]*)\}\}\)/g;
12714
12761
  const REQUEST_GLOBAL_INSTALLER_RE = /function\s+([A-Za-z_$][\w$]*)\([^)]*=\{\}\)\{[\s\S]{0,200}?targets\?\?\[[\s\S]{0,80}?fetch[\s\S]{0,80}?Headers[\s\S]{0,80}?Request[\s\S]{0,80}?Response[\s\S]{0,80}?AbortController[\s\S]{0,80}?AbortSignal[\s\S]{0,80}?XMLHttpRequest[\s\S]{0,240}?return [^}]+\}/;
12715
12762
  const REQUEST_GLOBAL_ENTRY_NAME_RE = /\.[^/.]+$/;
12716
- const REQUEST_GLOBAL_REQUIRE_RE = /^(const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*require\((`([^`]+)`|'([^']+)'|"([^"]+)")\);?/;
12763
+ const REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE = /([A-Za-z_$][\w$]*)\s*=\s*require\((`([^`]+)`|'([^']+)'|"([^"]+)")\)/g;
12717
12764
  const REQUEST_GLOBAL_TARGET_SIGNATURES = [
12718
12765
  "fetch",
12719
12766
  "Headers",
@@ -12933,6 +12980,29 @@ function resolveRequestGlobalsBindingTargets(targets) {
12933
12980
  if (targets.some((target) => target === "fetch" || target === "Request" || target === "Response" || target === "XMLHttpRequest")) bindingTargets.push("URL", "URLSearchParams", "Blob", "FormData");
12934
12981
  return [...new Set(bindingTargets)].filter((target) => REQUEST_GLOBAL_FREE_BINDING_TARGETS.has(target));
12935
12982
  }
12983
+ function createRequestGlobalsPassiveBindingsCode(bindingTargets) {
12984
+ return `${[
12985
+ "const __weappViteRequestGlobalsActuals__ = globalThis.__weappViteRequestGlobalsActuals__ || (globalThis.__weappViteRequestGlobalsActuals__ = Object.create(null))",
12986
+ "function __weappViteMarkRequestGlobalsPlaceholder__(value){try{Object.defineProperty(value,\"__weappViteRequestGlobalsPlaceholder__\",{value:true,configurable:true})}catch{value.__weappViteRequestGlobalsPlaceholder__=true}return value}",
12987
+ "function __weappViteCreateLazyRequestGlobalsFunction__(name){const placeholder=function(...args){const actual=__weappViteRequestGlobalsActuals__[name];if(typeof actual!==\"function\"){throw new Error(name+\" is not initialized\")}return actual.apply(this,args)};return __weappViteMarkRequestGlobalsPlaceholder__(placeholder)}",
12988
+ "function __weappViteCreateLazyRequestGlobalsConstructor__(name){const placeholder=function(...args){const actual=__weappViteRequestGlobalsActuals__[name];if(typeof actual!==\"function\"){throw new Error(name+\" is not initialized\")}return Reflect.construct(actual,args)};return __weappViteMarkRequestGlobalsPlaceholder__(placeholder)}",
12989
+ "function __weappViteHasUsableRequestGlobalsConstructor__(value,args){if(typeof value!==\"function\"||value?.__weappViteRequestGlobalsPlaceholder__===true){return false}try{return Reflect.construct(value,args),true}catch{return false}}"
12990
+ ].join(";")};${bindingTargets.map((target) => {
12991
+ if (target === "fetch") return "var fetch = typeof __weappViteRequestGlobalsActuals__[\"fetch\"]===\"function\"&&__weappViteRequestGlobalsActuals__[\"fetch\"]?.__weappViteRequestGlobalsPlaceholder__!==true?__weappViteRequestGlobalsActuals__[\"fetch\"]:typeof globalThis.fetch===\"function\"&&globalThis.fetch?.__weappViteRequestGlobalsPlaceholder__!==true?globalThis.fetch:__weappViteCreateLazyRequestGlobalsFunction__(\"fetch\")";
12992
+ const placeholderFactory = `__weappViteCreateLazyRequestGlobalsConstructor__(${JSON.stringify(target)})`;
12993
+ const actualRef = `__weappViteRequestGlobalsActuals__[${JSON.stringify(target)}]`;
12994
+ if (target === "URL") return `var URL = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},["https://request-globals.invalid"])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.URL,["https://request-globals.invalid"])?globalThis.URL:${placeholderFactory}`;
12995
+ if (target === "URLSearchParams") return `var URLSearchParams = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},["client=graphql-request"])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.URLSearchParams,["client=graphql-request"])?globalThis.URLSearchParams:${placeholderFactory}`;
12996
+ if (target === "Blob") return `var Blob = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},[])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.Blob,[])?globalThis.Blob:${placeholderFactory}`;
12997
+ if (target === "FormData") return `var FormData = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},[])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.FormData,[])?globalThis.FormData:${placeholderFactory}`;
12998
+ if (target === "Headers") return `var Headers = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},[])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.Headers,[])?globalThis.Headers:${placeholderFactory}`;
12999
+ if (target === "Request") return `var Request = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},["https://request-globals.invalid"])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.Request,["https://request-globals.invalid"])?globalThis.Request:${placeholderFactory}`;
13000
+ if (target === "Response") return `var Response = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},[null])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.Response,[null])?globalThis.Response:${placeholderFactory}`;
13001
+ if (target === "XMLHttpRequest") return `var XMLHttpRequest = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},[])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.XMLHttpRequest,[])?globalThis.XMLHttpRequest:${placeholderFactory}`;
13002
+ if (target === "AbortController") return `var AbortController = __weappViteHasUsableRequestGlobalsConstructor__(${actualRef},[])?${actualRef}:__weappViteHasUsableRequestGlobalsConstructor__(globalThis.AbortController,[])?globalThis.AbortController:${placeholderFactory}`;
13003
+ return `var ${target} = typeof ${actualRef}==="function"&&${actualRef}?.__weappViteRequestGlobalsPlaceholder__!==true?${actualRef}:typeof globalThis.${target}==="function"&&globalThis.${target}?.__weappViteRequestGlobalsPlaceholder__!==true?globalThis.${target}:${placeholderFactory}`;
13004
+ }).join(";")};`;
13005
+ }
12936
13006
  function injectRequestGlobalsBundleRuntime(bundle, targets) {
12937
13007
  const installerChunks = /* @__PURE__ */ new Map();
12938
13008
  if (targets.length === 0) return installerChunks;
@@ -12945,14 +13015,38 @@ function injectRequestGlobalsBundleRuntime(bundle, targets) {
12945
13015
  const exportName = resolveRequestGlobalsExportName(chunk.code);
12946
13016
  if (!installerName || !exportName) continue;
12947
13017
  installerChunks.set(toPosixPath(chunk.fileName), exportName);
12948
- const placeholderCode = bindingTargets.map((target) => {
12949
- return `var ${target} = typeof globalThis.${target} !== "undefined" ? globalThis.${target} : ${target === "fetch" ? "function __weappViteFetchPlaceholder__(){throw new Error(\"fetch is not initialized\")}" : `function ${target}(){}`}`;
12950
- }).join(";");
12951
- const runtimeBindingCode = [`const __weappViteRequestGlobalsBundleHost__ = ${installerName}({ targets: ${JSON.stringify(targets)} }) || globalThis`, ...bindingTargets.map((target) => `${target} = __weappViteRequestGlobalsBundleHost__.${target}`)].join(";");
12952
- chunk.code = `/* __weappViteRequestGlobalsBundleInstalled__ */ ${placeholderCode};\n${chunk.code}\n;${runtimeBindingCode};\n`;
13018
+ const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(bindingTargets);
13019
+ const runtimeBindingCode = [
13020
+ `const __weappViteRequestGlobalsBundleHost__ = ${installerName}({ targets: ${JSON.stringify(targets)} }) || globalThis`,
13021
+ ...bindingTargets.map((target) => `__weappViteRequestGlobalsActuals__[${JSON.stringify(target)}] = __weappViteRequestGlobalsBundleHost__.${target}`),
13022
+ ...bindingTargets.map((target) => `${target} = __weappViteRequestGlobalsBundleHost__.${target}`)
13023
+ ].join(";");
13024
+ const bundlePrelude = `/* __weappViteRequestGlobalsBundleInstalled__ */ ${passiveBindingsCode}\n`;
13025
+ const firstRequireMatch = chunk.code.match(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE);
13026
+ if (firstRequireMatch?.[0]) {
13027
+ chunk.code = `${bundlePrelude}${chunk.code.replace(firstRequireMatch[0], (match) => `${match};${runtimeBindingCode}`)}\n`;
13028
+ continue;
13029
+ }
13030
+ chunk.code = `${bundlePrelude}${chunk.code}\n;${runtimeBindingCode};\n`;
12953
13031
  }
12954
13032
  return installerChunks;
12955
13033
  }
13034
+ function injectRequestGlobalsPassiveBindings(bundle, installerChunks, targets, entriesMap) {
13035
+ if (installerChunks.size === 0 || targets.length === 0) return;
13036
+ const bindingTargets = resolveRequestGlobalsBindingTargets(targets);
13037
+ if (bindingTargets.length === 0) return;
13038
+ const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(bindingTargets);
13039
+ for (const output of Object.values(bundle)) {
13040
+ if (output?.type !== "chunk") continue;
13041
+ const chunk = output;
13042
+ if (installerChunks.has(toPosixPath(chunk.fileName))) continue;
13043
+ if (chunk.code.includes("__weappViteRequestGlobalsPassiveBindings__") || chunk.code.includes("__weappViteRequestGlobalsLocalBindings__") || chunk.code.includes("__weappViteRequestGlobalsBundleInstalled__")) continue;
13044
+ const entryName = chunk.fileName.replace(REQUEST_GLOBAL_ENTRY_NAME_RE, "");
13045
+ const entryType = entriesMap?.get(entryName)?.type;
13046
+ if (entryType === "page" || entryType === "component") continue;
13047
+ chunk.code = `/* __weappViteRequestGlobalsPassiveBindings__ */ ${passiveBindingsCode}\n${chunk.code}`;
13048
+ }
13049
+ }
12956
13050
  function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, entriesMap) {
12957
13051
  if (installerChunks.size === 0 || targets.length === 0) return;
12958
13052
  const bindingTargets = resolveRequestGlobalsBindingTargets(targets);
@@ -12964,16 +13058,25 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, ent
12964
13058
  const entryType = entriesMap?.get(entryName)?.type;
12965
13059
  if (entryType !== "page" && entryType !== "component") continue;
12966
13060
  if (chunk.code.includes("__weappViteRequestGlobalsLocalBindings__")) continue;
12967
- if (chunk.code.includes("__weappViteRequestGlobalsHost__") || chunk.code.includes("__weappViteInstallRequestGlobals")) continue;
12968
- const requireMatch = chunk.code.match(REQUEST_GLOBAL_REQUIRE_RE);
12969
- const requireAlias = requireMatch?.[2];
12970
- const importee = requireMatch?.[4] ?? requireMatch?.[5] ?? requireMatch?.[6];
12971
- if (!requireAlias || !importee) continue;
12972
- const installerChunkFileName = normalizeRelativeChunkImport(chunk.fileName, importee);
12973
- const exportName = installerChunks.get(installerChunkFileName);
12974
- if (!exportName) continue;
12975
- const injectionCode = [`const __weappViteRequestGlobalsHost__ = ${requireAlias}[${JSON.stringify(exportName)}]({ targets: ${JSON.stringify(targets)} }) || globalThis`, ...bindingTargets.map((target) => `var ${target} = __weappViteRequestGlobalsHost__.${target}`)].join(";");
12976
- chunk.code = chunk.code.replace(REQUEST_GLOBAL_REQUIRE_RE, (match) => `${match};/* __weappViteRequestGlobalsLocalBindings__ */ ${injectionCode};`);
13061
+ let requireImportLiteral = null;
13062
+ let exportName;
13063
+ for (const requireMatch of chunk.code.matchAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE)) {
13064
+ const importee = requireMatch[3] ?? requireMatch[4] ?? requireMatch[5];
13065
+ if (!importee) continue;
13066
+ const installerChunkFileName = normalizeRelativeChunkImport(chunk.fileName, importee);
13067
+ exportName = installerChunks.get(installerChunkFileName);
13068
+ if (!exportName) continue;
13069
+ requireImportLiteral = requireMatch[2] ?? null;
13070
+ break;
13071
+ }
13072
+ if (!requireImportLiteral || !exportName) continue;
13073
+ chunk.code = `/* __weappViteRequestGlobalsLocalBindings__ */ ${[
13074
+ `const __weappViteChunkRequestGlobalsModule__ = require(${requireImportLiteral})`,
13075
+ `const __weappViteChunkRequestGlobalsHost__ = __weappViteChunkRequestGlobalsModule__[${JSON.stringify(exportName)}]({ targets: ${JSON.stringify(targets)} }) || globalThis`,
13076
+ "const __weappViteRequestGlobalsActuals__ = globalThis.__weappViteRequestGlobalsActuals__ || (globalThis.__weappViteRequestGlobalsActuals__ = Object.create(null))",
13077
+ ...bindingTargets.map((target) => `__weappViteRequestGlobalsActuals__[${JSON.stringify(target)}] = __weappViteChunkRequestGlobalsHost__.${target}`),
13078
+ ...bindingTargets.map((target) => `var ${target} = __weappViteChunkRequestGlobalsHost__.${target}`)
13079
+ ].join(";")};\n${chunk.code}`;
12977
13080
  }
12978
13081
  }
12979
13082
  function toRelativeRuntimeNpmImport(fileName, root, importee) {
@@ -13178,7 +13281,11 @@ function createGenerateBundleHook(state, isPluginBuild) {
13178
13281
  }
13179
13282
  const injectWeapiGlobalName = resolveInjectWeapiGlobalName(state);
13180
13283
  if (injectWeapiGlobalName) rewriteBundlePlatformApi(rolldownBundle, injectWeapiGlobalName, { astEngine });
13181
- if (injectRequestGlobalsOptions?.targets?.length) injectRequestGlobalsLocalBindings(rolldownBundle, injectRequestGlobalsBundleRuntime(rolldownBundle, injectRequestGlobalsOptions.targets), injectRequestGlobalsOptions.targets, state.entriesMap);
13284
+ if (injectRequestGlobalsOptions?.targets?.length) {
13285
+ const installerChunks = injectRequestGlobalsBundleRuntime(rolldownBundle, injectRequestGlobalsOptions.targets);
13286
+ injectRequestGlobalsPassiveBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, state.entriesMap);
13287
+ injectRequestGlobalsLocalBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, state.entriesMap);
13288
+ }
13182
13289
  refreshModuleGraph(this, state);
13183
13290
  if (configService.weappViteConfig?.debug?.watchFiles) {
13184
13291
  const watcherService = ctx.watcherService;
@@ -19380,7 +19487,7 @@ function createScanService(ctx) {
19380
19487
  const vueAppPath = await findVueEntry(appBasename);
19381
19488
  let configFromVue;
19382
19489
  if (!appConfigFile && vueAppPath) {
19383
- const { extractConfigFromVue } = await import("./file-DwwblEq4.mjs").then((n) => n.r);
19490
+ const { extractConfigFromVue } = await import("./file-WyRp0uK0.mjs").then((n) => n.r);
19384
19491
  configFromVue = await extractConfigFromVue(vueAppPath);
19385
19492
  if (configFromVue) appConfigFile = vueAppPath;
19386
19493
  }
@@ -166,10 +166,13 @@ wv ide logs --open
166
166
  ```sh
167
167
  weapp-vite preview --project ./dist/build/mp-weixin
168
168
  weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
169
+ weapp-vite cache --clean compile
170
+ weapp-vite cache --clean all
169
171
  weapp-vite config lang zh
170
172
  weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
171
173
  # 等价写法
172
174
  wv preview --project ./dist/build/mp-weixin
175
+ wv cache --clean all
173
176
  ```
174
177
 
175
178
  也支持命名空间写法:
@@ -102,7 +102,7 @@ function resolveAutoRoutesMacroImportPath() {
102
102
  }
103
103
  async function resolveAutoRoutesInlineSnapshot() {
104
104
  try {
105
- const { getCompilerContext } = await import("./createContext-CZ7Kunvn.mjs").then((n) => n.a);
105
+ const { getCompilerContext } = await import("./createContext-CwnO-Jw3.mjs").then((n) => n.a);
106
106
  const compilerContext = getCompilerContext();
107
107
  const service = compilerContext.autoRoutesService;
108
108
  const reference = service?.getReference?.();
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { A as Ref, An as createWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, Dn as WeappViteHostMeta, E as InlineConfig, En as WEAPP_VITE_HOST_NAME, F as RolldownPlugin, I as RolldownPluginOption, L as RolldownWatchOptions, M as RolldownBuild, Mn as resolveWeappViteHostMeta, N as RolldownOptions, O as Plugin, On as WeappViteRuntime, P as RolldownOutput, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, jn as isWeappViteHost, k as PluginOption, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-B3HNOAZo.mjs";
2
- import { WevuComponentOptions, defineEmits, defineProps } from "./runtime.mjs";
3
- import { createWevuComponent, setPageLayout } from "wevu";
1
+ import { A as Ref, An as createWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, Dn as WeappViteHostMeta, E as InlineConfig, En as WEAPP_VITE_HOST_NAME, F as RolldownPlugin, I as RolldownPluginOption, L as RolldownWatchOptions, M as RolldownBuild, Mn as resolveWeappViteHostMeta, N as RolldownOptions, O as Plugin, On as WeappViteRuntime, P as RolldownOutput, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, jn as isWeappViteHost, k as PluginOption, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-WBWY_UlE.mjs";
2
+ import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-CpQutkhu.mjs";
4
3
 
5
4
  //#region src/createContext.d.ts
6
5
  interface CreateCompilerContextOptions extends Partial<LoadConfigOptions> {
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
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-CZ7Kunvn.mjs";
5
- import { defineEmits, defineProps } from "./runtime.mjs";
6
- import { createWevuComponent, setPageLayout } from "wevu";
4
+ import { t as createCompilerContext } from "./createContext-CwnO-Jw3.mjs";
5
+ import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-gyZnAGCZ.mjs";
7
6
  export { WEAPP_VITE_HOST_NAME, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta, setPageLayout };
package/dist/json.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-B3HNOAZo.mjs";
1
+ import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-WBWY_UlE.mjs";
2
2
  export { App, Component, Page, Sitemap, Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _t as WeappMcpConfig } from "./config-B3HNOAZo.mjs";
1
+ import { _t as WeappMcpConfig } from "./config-WBWY_UlE.mjs";
2
2
  import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
3
3
 
4
4
  //#region src/mcp.d.ts
@@ -0,0 +1,39 @@
1
+ import { ComputedDefinitions, MethodDefinitions, WevuPageLayoutMap } from "wevu";
2
+
3
+ //#region src/plugins/vue/createWevuComponent.d.ts
4
+ interface WevuComponentOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> {
5
+ data?: () => D;
6
+ computed?: C;
7
+ methods?: M;
8
+ watch?: any;
9
+ setup?: (...args: any[]) => any;
10
+ setupLifecycle?: 'created' | 'attached';
11
+ properties?: Record<string, any>;
12
+ [key: string]: any;
13
+ }
14
+ /**
15
+ * 从 Vue SFC 的 options 创建 wevu 组件
16
+ * 同时支持 Vue 2 风格(Options API)与 Vue 3 风格(Composition API)
17
+ *
18
+ * 始终使用 defineComponent(其内部会调用小程序的 Component())。
19
+ * 在微信小程序中,Component() 可以同时定义页面与组件。
20
+ */
21
+ declare function createWevuComponent(options: WevuComponentOptions): void;
22
+ //#endregion
23
+ //#region src/plugins/vue/nativePageLayout.d.ts
24
+ type ResolveTypedPageLayoutName = keyof WevuPageLayoutMap extends never ? string : Extract<keyof WevuPageLayoutMap, string>;
25
+ type ResolveTypedPageLayoutProps<Name extends string> = Name extends keyof WevuPageLayoutMap ? WevuPageLayoutMap[Name] : Record<string, any>;
26
+ declare function setPageLayout(layout: false): void;
27
+ declare function setPageLayout<Name extends ResolveTypedPageLayoutName>(layout: Name, props?: ResolveTypedPageLayoutProps<Name>): void;
28
+ //#endregion
29
+ //#region src/plugins/vue/runtimeMacros.d.ts
30
+ /**
31
+ * 说明:Vue 3 风格的 props 声明(用于类型提示)
32
+ */
33
+ declare function defineProps<T extends Record<string, any>>(props: T): T;
34
+ /**
35
+ * 说明:Vue 3 风格的 emits 声明(用于类型提示)
36
+ */
37
+ declare function defineEmits<T extends Record<string, any> | string[]>(emits: T): T;
38
+ //#endregion
39
+ export { createWevuComponent as a, WevuComponentOptions as i, defineProps as n, setPageLayout as r, defineEmits as t };
@@ -0,0 +1,53 @@
1
+ import { defineComponent } from "wevu";
2
+ //#region src/plugins/vue/createWevuComponent.ts
3
+ /**
4
+ * 从 Vue SFC 的 options 创建 wevu 组件
5
+ * 同时支持 Vue 2 风格(Options API)与 Vue 3 风格(Composition API)
6
+ *
7
+ * 始终使用 defineComponent(其内部会调用小程序的 Component())。
8
+ * 在微信小程序中,Component() 可以同时定义页面与组件。
9
+ */
10
+ function createWevuComponent(options) {
11
+ const { properties, ...restOptions } = options;
12
+ const mpOptions = {};
13
+ if (properties) mpOptions.properties = properties;
14
+ defineComponent({
15
+ ...restOptions,
16
+ ...mpOptions
17
+ });
18
+ }
19
+ //#endregion
20
+ //#region src/plugins/vue/nativePageLayout.ts
21
+ const PAGE_LAYOUT_SETTER_KEY = "__wevuSetPageLayout";
22
+ function resolveCurrentPageInstance() {
23
+ const getCurrentPagesFn = globalThis.getCurrentPages;
24
+ if (typeof getCurrentPagesFn !== "function") return;
25
+ return getCurrentPagesFn().at(-1);
26
+ }
27
+ /**
28
+ * 为原生 Page() 页面切换 layout。
29
+ */
30
+ function setPageLayout(layout, props) {
31
+ const pageSetter = resolveCurrentPageInstance()?.[PAGE_LAYOUT_SETTER_KEY];
32
+ if (typeof pageSetter === "function") {
33
+ pageSetter(layout, props);
34
+ return;
35
+ }
36
+ throw new Error("setPageLayout() 未找到当前页面实例。请在页面生命周期、事件回调或当前页面上下文中调用。");
37
+ }
38
+ //#endregion
39
+ //#region src/plugins/vue/runtimeMacros.ts
40
+ /**
41
+ * 说明:Vue 3 风格的 props 声明(用于类型提示)
42
+ */
43
+ function defineProps(props) {
44
+ return props;
45
+ }
46
+ /**
47
+ * 说明:Vue 3 风格的 emits 声明(用于类型提示)
48
+ */
49
+ function defineEmits(emits) {
50
+ return emits;
51
+ }
52
+ //#endregion
53
+ export { createWevuComponent as i, defineProps as n, setPageLayout as r, defineEmits as t };
@@ -1,31 +1,2 @@
1
- import { ComputedDefinitions, MethodDefinitions, setPageLayout } from "wevu";
2
-
3
- //#region src/plugins/vue/runtime.d.ts
4
- interface WevuComponentOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> {
5
- data?: () => D;
6
- computed?: C;
7
- methods?: M;
8
- watch?: any;
9
- setup?: (...args: any[]) => any;
10
- setupLifecycle?: 'created' | 'attached';
11
- properties?: Record<string, any>;
12
- [key: string]: any;
13
- }
14
- /**
15
- * 从 Vue SFC 的 options 创建 wevu 组件
16
- * 同时支持 Vue 2 风格(Options API)与 Vue 3 风格(Composition API)
17
- *
18
- * 始终使用 defineComponent(其内部会调用小程序的 Component())。
19
- * 在微信小程序中,Component() 可以同时定义页面与组件。
20
- */
21
- declare function createWevuComponent(options: WevuComponentOptions): void;
22
- /**
23
- * 说明:Vue 3 风格的 props 声明(用于类型提示)
24
- */
25
- declare function defineProps<T extends Record<string, any>>(props: T): T;
26
- /**
27
- * 说明:Vue 3 风格的 emits 声明(用于类型提示)
28
- */
29
- declare function defineEmits<T extends Record<string, any> | string[]>(emits: T): T;
30
- //#endregion
1
+ import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-CpQutkhu.mjs";
31
2
  export { WevuComponentOptions, createWevuComponent, defineEmits, defineProps, setPageLayout };
package/dist/runtime.mjs CHANGED
@@ -1,32 +1,2 @@
1
- import { defineComponent, setPageLayout } from "wevu";
2
- //#region src/plugins/vue/runtime.ts
3
- /**
4
- * 从 Vue SFC 的 options 创建 wevu 组件
5
- * 同时支持 Vue 2 风格(Options API)与 Vue 3 风格(Composition API)
6
- *
7
- * 始终使用 defineComponent(其内部会调用小程序的 Component())。
8
- * 在微信小程序中,Component() 可以同时定义页面与组件。
9
- */
10
- function createWevuComponent(options) {
11
- const { properties, ...restOptions } = options;
12
- const mpOptions = {};
13
- if (properties) mpOptions.properties = properties;
14
- defineComponent({
15
- ...restOptions,
16
- ...mpOptions
17
- });
18
- }
19
- /**
20
- * 说明:Vue 3 风格的 props 声明(用于类型提示)
21
- */
22
- function defineProps(props) {
23
- return props;
24
- }
25
- /**
26
- * 说明:Vue 3 风格的 emits 声明(用于类型提示)
27
- */
28
- function defineEmits(emits) {
29
- return emits;
30
- }
31
- //#endregion
1
+ import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-gyZnAGCZ.mjs";
32
2
  export { createWevuComponent, defineEmits, defineProps, setPageLayout };
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as Resolver } from "./index-BQqQ_BLM.mjs";
2
- import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-DUBjYF43.mjs";
3
- import { $ as WeappDebugConfig, $t as NpmBuildOptions, A as Ref, At as ChunksConfig, B as BindingErrorLike, Bt as GenerateTemplateEntry, Cn as WeappManagedSharedTsconfigConfig, Ct as WeappVueTemplateConfig, D as MethodDefinitions, Dn as WeappViteHostMeta, Dt as AliasOptions, E as InlineConfig, Et as Alias, F as RolldownPlugin, Ft as GenerateFileType, G as EntryJsonFragment, Gt as GenerateTemplatesConfig, H as BaseEntry, Ht as GenerateTemplateFileSource, I as RolldownPluginOption, It as GenerateFilenamesOptions, J as ScanComponentItem, Jt as JsonMergeContext, K as PageEntry, Kt as JsFormat, L as RolldownWatchOptions, Lt as GenerateOptions, M as RolldownBuild, Mt as CopyOptions, N as RolldownOptions, Nt as GenerateDirsOptions, O as Plugin, On as WeappViteRuntime, Ot as AlipayNpmMode, P as RolldownOutput, Pt as GenerateExtensionsOptions, Q as UserConfig, Qt as MpPlatform, R as RolldownWatcher, Rt as GenerateTemplate, Sn as WeappManagedServerTsconfigConfig, St as WeappVueConfig, T as ConfigEnv, Tn as WeappWebConfig, Tt as WeappWorkerConfig, U as ComponentEntry, Ut as GenerateTemplateInlineSource, V as AppEntry, Vt as GenerateTemplateFactory, W as Entry, Wt as GenerateTemplateScope, X as ProjectConfig, Xt as JsonMergeStage, Y as WxmlDep, Yt as JsonMergeFunction, Z as SubPackageMetaValue, Zt as JsonMergeStrategy, _n as WeappLibFileName, _t as WeappMcpConfig, an as SharedChunkMode, at as EnhanceOptions, b as ChangeEvent, bn as WeappManagedAppTsconfigConfig, bt as WeappRouteRules, cn as SubPackage, ct as MultiPlatformConfig, dn as SubPackageStyleEntry, dt as WeappAutoRoutesInclude, en as NpmMainPackageConfig, et as WeappForwardConsoleConfig, fn as SubPackageStyleScope, ft as WeappAutoRoutesIncludePattern, gn as WeappLibEntryContext, gt as WeappInjectWeapiConfig, hn as WeappLibDtsOptions, ht as WeappInjectRequestGlobalsTarget, in as SharedChunkDynamicImports, it as AutoImportComponentsOption, j as ResolvedConfig, jt as CopyGlobs, k as PluginOption, kt as BuildNpmPackageMeta, ln as SubPackageStyleConfigEntry, lt as ScanWxmlOptions, mn as WeappLibConfig, mt as WeappInjectRequestGlobalsConfig, nn as NpmSubPackageConfig, nt as WeappViteConfig, on as SharedChunkOverride, ot as EnhanceWxmlOptions, pn as WeappLibComponentJson, pt as WeappHmrConfig, q as ComponentsMap, qt as JsonConfig, rn as ResolvedAlias, rt as AutoImportComponents, sn as SharedChunkStrategy, st as HandleWxmlOptions, tn as NpmPluginPackageConfig, tt as WeappForwardConsoleLogLevel, un as SubPackageStyleConfigObject, ut as WeappAutoRoutesConfig, vn as WeappLibInternalDtsOptions, vt as WeappNpmConfig, w as ComputedDefinitions, wn as WeappManagedTypeScriptConfig, wt as WeappWevuConfig, x as WeappVitePluginApi, xn as WeappManagedNodeTsconfigConfig, xt as WeappSubPackageConfig, yn as WeappLibVueTscOptions, yt as WeappRouteRule, z as ViteDevServer, zt as GenerateTemplateContext } from "./config-B3HNOAZo.mjs";
1
+ import { c as Resolver } from "./index-B5wBsuYI.mjs";
2
+ import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-o20IHwXa.mjs";
3
+ import { $ as WeappDebugConfig, $t as NpmBuildOptions, A as Ref, At as ChunksConfig, B as BindingErrorLike, Bt as GenerateTemplateEntry, Cn as WeappManagedSharedTsconfigConfig, Ct as WeappVueTemplateConfig, D as MethodDefinitions, Dn as WeappViteHostMeta, Dt as AliasOptions, E as InlineConfig, Et as Alias, F as RolldownPlugin, Ft as GenerateFileType, G as EntryJsonFragment, Gt as GenerateTemplatesConfig, H as BaseEntry, Ht as GenerateTemplateFileSource, I as RolldownPluginOption, It as GenerateFilenamesOptions, J as ScanComponentItem, Jt as JsonMergeContext, K as PageEntry, Kt as JsFormat, L as RolldownWatchOptions, Lt as GenerateOptions, M as RolldownBuild, Mt as CopyOptions, N as RolldownOptions, Nt as GenerateDirsOptions, O as Plugin, On as WeappViteRuntime, Ot as AlipayNpmMode, P as RolldownOutput, Pt as GenerateExtensionsOptions, Q as UserConfig, Qt as MpPlatform, R as RolldownWatcher, Rt as GenerateTemplate, Sn as WeappManagedServerTsconfigConfig, St as WeappVueConfig, T as ConfigEnv, Tn as WeappWebConfig, Tt as WeappWorkerConfig, U as ComponentEntry, Ut as GenerateTemplateInlineSource, V as AppEntry, Vt as GenerateTemplateFactory, W as Entry, Wt as GenerateTemplateScope, X as ProjectConfig, Xt as JsonMergeStage, Y as WxmlDep, Yt as JsonMergeFunction, Z as SubPackageMetaValue, Zt as JsonMergeStrategy, _n as WeappLibFileName, _t as WeappMcpConfig, an as SharedChunkMode, at as EnhanceOptions, b as ChangeEvent, bn as WeappManagedAppTsconfigConfig, bt as WeappRouteRules, cn as SubPackage, ct as MultiPlatformConfig, dn as SubPackageStyleEntry, dt as WeappAutoRoutesInclude, en as NpmMainPackageConfig, et as WeappForwardConsoleConfig, fn as SubPackageStyleScope, ft as WeappAutoRoutesIncludePattern, gn as WeappLibEntryContext, gt as WeappInjectWeapiConfig, hn as WeappLibDtsOptions, ht as WeappInjectRequestGlobalsTarget, in as SharedChunkDynamicImports, it as AutoImportComponentsOption, j as ResolvedConfig, jt as CopyGlobs, k as PluginOption, kt as BuildNpmPackageMeta, ln as SubPackageStyleConfigEntry, lt as ScanWxmlOptions, mn as WeappLibConfig, mt as WeappInjectRequestGlobalsConfig, nn as NpmSubPackageConfig, nt as WeappViteConfig, on as SharedChunkOverride, ot as EnhanceWxmlOptions, pn as WeappLibComponentJson, pt as WeappHmrConfig, q as ComponentsMap, qt as JsonConfig, rn as ResolvedAlias, rt as AutoImportComponents, sn as SharedChunkStrategy, st as HandleWxmlOptions, tn as NpmPluginPackageConfig, tt as WeappForwardConsoleLogLevel, un as SubPackageStyleConfigObject, ut as WeappAutoRoutesConfig, vn as WeappLibInternalDtsOptions, vt as WeappNpmConfig, w as ComputedDefinitions, wn as WeappManagedTypeScriptConfig, wt as WeappWevuConfig, x as WeappVitePluginApi, xn as WeappManagedNodeTsconfigConfig, xt as WeappSubPackageConfig, yn as WeappLibVueTscOptions, yt as WeappRouteRule, z as ViteDevServer, zt as GenerateTemplateContext } from "./config-WBWY_UlE.mjs";
4
4
  export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, ComputedDefinitions, ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmMainPackageConfig, NpmPluginPackageConfig, NpmSubPackageConfig, PageEntry, Plugin, PluginOption, ProjectConfig, Ref, ResolvedAlias, ResolvedConfig, Resolver, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, ViteDevServer, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.13.0",
4
+ "version": "6.13.1",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -115,13 +115,13 @@
115
115
  "typescript": "^6.0.2",
116
116
  "vite": "8.0.2",
117
117
  "vite-tsconfig-paths": "^6.1.1",
118
- "vue": "^3.5.31",
118
+ "vue": "^3.5.32",
119
119
  "vue-tsc": "^3.2.6",
120
120
  "@weapp-core/init": "6.0.5",
121
121
  "@weapp-core/logger": "3.1.1",
122
122
  "@weapp-core/schematics": "6.0.4",
123
123
  "@weapp-core/shared": "3.0.2",
124
- "@weapp-vite/ast": "6.13.0",
124
+ "@weapp-vite/ast": "6.13.1",
125
125
  "@weapp-vite/mcp": "1.1.2",
126
126
  "@weapp-vite/volar": "2.0.8",
127
127
  "@weapp-vite/web": "1.3.10",
@@ -129,8 +129,8 @@
129
129
  "@wevu/web-apis": "1.1.0",
130
130
  "rolldown-require": "2.0.12",
131
131
  "vite-plugin-performance": "2.0.1",
132
- "weapp-ide-cli": "5.1.4",
133
- "wevu": "6.13.0"
132
+ "weapp-ide-cli": "5.1.5",
133
+ "wevu": "6.13.1"
134
134
  },
135
135
  "publishConfig": {
136
136
  "access": "public",