weapp-vite 6.16.28 → 6.16.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { g as getRouteRuntimeGlobalKeys, i as getCompilerContext } from "./createContext-e20SKsa-.mjs";
1
+ import { g as getRouteRuntimeGlobalKeys, i as getCompilerContext } from "./createContext-wBxmdc_3.mjs";
2
2
  //#region src/auto-routes.ts
3
3
  const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
4
4
  function createGetter(resolver) {
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, b as getProjectConfigFileName, f as resolveWeappViteTarget, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, n as syncProjectSupportFiles, p as createSharedBuildConfig, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-e20SKsa-.mjs";
1
+ import { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, b as getProjectConfigFileName, f as resolveWeappViteTarget, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, n as syncProjectSupportFiles, p as createSharedBuildConfig, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-wBxmdc_3.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
3
- import { h as VERSION } from "./file-6emWhSkC.mjs";
3
+ import { h as VERSION } from "./file-DgdYQ44n.mjs";
4
4
  import { o as resolveWeappMcpConfig, s as startWeappViteMcpServer } from "./mcp-qmDOTH07.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import path, { posix } from "pathe";
@@ -3708,7 +3708,7 @@ function resolveRunnableHotkeyDefinition(input) {
3708
3708
  }
3709
3709
  //#endregion
3710
3710
  //#region package.json
3711
- var version = "6.16.28";
3711
+ var version = "6.16.29";
3712
3712
  //#endregion
3713
3713
  //#region src/cli/devHotkeys/format.ts
3714
3714
  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-6emWhSkC.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-DgdYQ44n.mjs";
4
4
  import { createRequire, isBuiltin } from "node:module";
5
5
  import path, { posix } from "pathe";
6
6
  import path$1, { normalize, relative, win32 } from "node:path";
@@ -35,7 +35,7 @@ import { spawn } from "node:child_process";
35
35
  import * as t from "@weapp-vite/ast/babelTypes";
36
36
  import { objectHash } from "@weapp-core/shared/node";
37
37
  import PQueue from "p-queue";
38
- import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEVU_APP_SHELL_COMPONENT_BASE, WEVU_APP_SHELL_TAG_NAME, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
38
+ import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEVU_APP_SHELL_COMPONENT_BASE, WEVU_APP_SHELL_TAG_NAME, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_GLOBAL_PATH, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
39
39
  import { Buffer } from "node:buffer";
40
40
  import { detect } from "package-manager-detector/detect";
41
41
  import tsconfigPaths from "vite-tsconfig-paths";
@@ -4713,7 +4713,7 @@ function parseCommentJson(json) {
4713
4713
  function jsonFileRemoveJsExtension(fileName) {
4714
4714
  return fileName.replace(JSON_FILE_JS_EXTENSION_RE, "");
4715
4715
  }
4716
- function stringifyJson(value, replacer) {
4716
+ function stringifyJson$1(value, replacer) {
4717
4717
  return stringify(value, replacer, 2);
4718
4718
  }
4719
4719
  function normalizeAppJson(json) {
@@ -4830,7 +4830,7 @@ function resolveJson(entry, aliasEntries, platform, options) {
4830
4830
  const componentGenerics = get(json, "componentGenerics");
4831
4831
  if (isObject(componentGenerics)) set(json, "componentGenerics", normalizeComponentGenericsByPlatform(componentGenerics, platform));
4832
4832
  if (Reflect.has(json, "$schema")) delete json.$schema;
4833
- return stringifyJson(json);
4833
+ return stringifyJson$1(json);
4834
4834
  }
4835
4835
  }
4836
4836
  //#endregion
@@ -20974,6 +20974,132 @@ function getSourceFromVirtualId(id) {
20974
20974
  return id;
20975
20975
  }
20976
20976
  //#endregion
20977
+ //#region src/plugins/vue/transform/bundle/outputExtensions.ts
20978
+ function resolveBundleOutputExtensions(outputExtensions) {
20979
+ return resolveOutputExtensions(outputExtensions);
20980
+ }
20981
+ //#endregion
20982
+ //#region src/plugins/vue/transform/slotFallbackWrapper.ts
20983
+ const slotFallbackWrapperUsageByBundle = /* @__PURE__ */ new WeakMap();
20984
+ const slotFallbackWrapperScriptByBundle = /* @__PURE__ */ new WeakMap();
20985
+ function parseJsonSafely$1(source) {
20986
+ if (!source) return {};
20987
+ try {
20988
+ const parsed = JSON.parse(source);
20989
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
20990
+ } catch {
20991
+ return {};
20992
+ }
20993
+ }
20994
+ function stringifyJson(json) {
20995
+ return JSON.stringify(json, null, 2);
20996
+ }
20997
+ function isAsset(value) {
20998
+ return value?.type === "asset";
20999
+ }
21000
+ function getAssetSource(asset) {
21001
+ return asset?.source?.toString?.() ?? "";
21002
+ }
21003
+ function upsertSlotFallbackWrapperUsingComponent(json) {
21004
+ const usingComponents = json.usingComponents && typeof json.usingComponents === "object" && !Array.isArray(json.usingComponents) ? { ...json.usingComponents } : {};
21005
+ usingComponents[WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME] = WEVU_SLOT_FALLBACK_VIRTUAL_HOST_GLOBAL_PATH;
21006
+ json.usingComponents = usingComponents;
21007
+ return json;
21008
+ }
21009
+ function normalizeJsonConfigForPlatform$1(json, compilerCtx) {
21010
+ const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
21011
+ if (!jsonPlatformOptions.normalizeUsingComponents) return json;
21012
+ try {
21013
+ const source = resolveJson({ json }, void 0, jsonPlatformOptions.platform, {
21014
+ dependencies: jsonPlatformOptions.dependencies,
21015
+ alipayNpmMode: jsonPlatformOptions.alipayNpmMode
21016
+ });
21017
+ return source ? JSON.parse(source) : json;
21018
+ } catch {
21019
+ return json;
21020
+ }
21021
+ }
21022
+ function getSlotFallbackWrapperUsage(bundle) {
21023
+ let usage = slotFallbackWrapperUsageByBundle.get(bundle);
21024
+ if (!usage) {
21025
+ usage = /* @__PURE__ */ new Set();
21026
+ slotFallbackWrapperUsageByBundle.set(bundle, usage);
21027
+ }
21028
+ return usage;
21029
+ }
21030
+ function markSlotFallbackWrapperUsage(bundle, relativeBase) {
21031
+ getSlotFallbackWrapperUsage(bundle).add(relativeBase);
21032
+ }
21033
+ function getSlotFallbackWrapperScriptCache(bundle) {
21034
+ let cache = slotFallbackWrapperScriptByBundle.get(bundle);
21035
+ if (!cache) {
21036
+ cache = /* @__PURE__ */ new Map();
21037
+ slotFallbackWrapperScriptByBundle.set(bundle, cache);
21038
+ }
21039
+ return cache;
21040
+ }
21041
+ function injectSlotFallbackWrapperIntoJsonAsset(bundle, jsonFileName, compilerCtx) {
21042
+ const output = bundle[jsonFileName];
21043
+ if (!isAsset(output)) return false;
21044
+ output.source = stringifyJson(normalizeJsonConfigForPlatform$1(upsertSlotFallbackWrapperUsingComponent(parseJsonSafely$1(getAssetSource(output))), compilerCtx));
21045
+ return true;
21046
+ }
21047
+ function injectGlobalSlotFallbackWrapperUsingComponent(bundle, compilerCtx, outputExtensions) {
21048
+ const { jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
21049
+ const usage = slotFallbackWrapperUsageByBundle.get(bundle);
21050
+ if (!usage?.size) return false;
21051
+ if (injectSlotFallbackWrapperIntoJsonAsset(bundle, `app.${jsonExtension}`, compilerCtx)) return true;
21052
+ for (const relativeBase of usage) injectSlotFallbackWrapperIntoJsonAsset(bundle, `${relativeBase}.${jsonExtension}`, compilerCtx);
21053
+ return false;
21054
+ }
21055
+ function hasGlobalSlotFallbackWrapperUsingComponentAsset(bundle, outputExtensions) {
21056
+ const { jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
21057
+ return isAsset(bundle[`app.${jsonExtension}`]);
21058
+ }
21059
+ function injectLocalSlotFallbackWrapperUsingComponentIfNeeded(options) {
21060
+ if (!options.result.slotFallbackWrapperComponent || hasGlobalSlotFallbackWrapperUsingComponentAsset(options.bundle, options.outputExtensions)) return false;
21061
+ const config = upsertSlotFallbackWrapperUsingComponent(parseJsonSafely$1(options.result.config));
21062
+ options.result.config = stringifyJson(normalizeJsonConfigForPlatform$1(config, options.compilerCtx));
21063
+ return true;
21064
+ }
21065
+ function emitSlotFallbackWrapperScriptIfMissing(ctx, bundle, fileName, script) {
21066
+ const existing = bundle[fileName];
21067
+ if (existing && existing.type === "asset") {
21068
+ if ((existing.source?.toString?.() ?? "") !== script) existing.source = script;
21069
+ return;
21070
+ }
21071
+ const cache = getSlotFallbackWrapperScriptCache(bundle);
21072
+ if (cache.get(fileName) === script) return;
21073
+ if (!existing) {
21074
+ ctx.emitFile({
21075
+ type: "asset",
21076
+ fileName,
21077
+ source: script
21078
+ });
21079
+ cache.set(fileName, script);
21080
+ }
21081
+ }
21082
+ function emitSlotFallbackWrapperComponentAsset(options) {
21083
+ const component = options.result.slotFallbackWrapperComponent;
21084
+ if (!component) return;
21085
+ const { templateExtension, jsonExtension, scriptExtension } = resolveBundleOutputExtensions(options.outputExtensions);
21086
+ const componentBase = WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE;
21087
+ markSlotFallbackWrapperUsage(options.bundle, options.relativeBase);
21088
+ emitSfcTemplateIfMissing(options.ctx, options.bundle, componentBase, component.template, templateExtension);
21089
+ const jsonFileName = `${componentBase}.${jsonExtension}`;
21090
+ const mergeJson = createJsonMerger(options.jsonOptions?.mergeStrategy, {
21091
+ filename: jsonFileName,
21092
+ kind: "component"
21093
+ });
21094
+ let config = component.config;
21095
+ if (options.jsonOptions?.defaults && Object.keys(options.jsonOptions.defaults).length > 0) config = mergeJson(config, options.jsonOptions.defaults, "defaults");
21096
+ emitSfcJsonAsset(options.ctx, options.bundle, componentBase, { config: JSON.stringify(normalizeJsonConfigForPlatform$1(config, options.compilerCtx), null, 2) }, {
21097
+ kind: "component",
21098
+ extension: jsonExtension
21099
+ });
21100
+ emitSlotFallbackWrapperScriptIfMissing(options.ctx, options.bundle, `${componentBase}.${scriptExtension}`, component.script);
21101
+ }
21102
+ //#endregion
20977
21103
  //#region src/plugins/vue/transform/classStyle.ts
20978
21104
  function resolveClassStylePackageRoot(ctx, relativeBase, configService) {
20979
21105
  const currentRoot = normalizeRoot(configService.currentSubPackageRoot ?? "");
@@ -20999,16 +21125,11 @@ function resolveClassStyleWxsLocationForBase(ctx, relativeBase, extension, confi
20999
21125
  });
21000
21126
  }
21001
21127
  //#endregion
21002
- //#region src/plugins/vue/transform/bundle/outputExtensions.ts
21003
- function resolveBundleOutputExtensions(outputExtensions) {
21004
- return resolveOutputExtensions(outputExtensions);
21005
- }
21006
- //#endregion
21007
21128
  //#region src/plugins/vue/transform/scopedSlot/assets.ts
21008
21129
  function hasOwn(source, key) {
21009
21130
  return Object.prototype.hasOwnProperty.call(source, key);
21010
21131
  }
21011
- function parseJsonSafely$1(source) {
21132
+ function parseJsonSafely(source) {
21012
21133
  if (!source) return;
21013
21134
  try {
21014
21135
  return JSON.parse(source);
@@ -21016,7 +21137,7 @@ function parseJsonSafely$1(source) {
21016
21137
  return;
21017
21138
  }
21018
21139
  }
21019
- function normalizeJsonConfigForPlatform$1(json, compilerCtx) {
21140
+ function normalizeJsonConfigForPlatform(json, compilerCtx) {
21020
21141
  const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
21021
21142
  if (!jsonPlatformOptions.normalizeUsingComponents) return json;
21022
21143
  try {
@@ -21090,7 +21211,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
21090
21211
  const scopedSlots = result.scopedSlotComponents;
21091
21212
  if (!scopedSlots?.length) return;
21092
21213
  const { templateExtension, jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
21093
- const configObj = parseJsonSafely$1(result.config) ?? {};
21214
+ const configObj = parseJsonSafely(result.config) ?? {};
21094
21215
  const baseUsingComponents = configObj.usingComponents && typeof configObj.usingComponents === "object" && !Array.isArray(configObj.usingComponents) ? { ...configObj.usingComponents } : {};
21095
21216
  const usingComponents = { ...baseUsingComponents };
21096
21217
  registerScopedSlotHostGenerics(compilerCtx, scopedSlots, baseUsingComponents);
@@ -21121,7 +21242,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
21121
21242
  };
21122
21243
  json = mergeJson(defaultConfig, json, "emit");
21123
21244
  if (hasOwn(defaultConfig, "component")) json.component = true;
21124
- const normalizedJson = normalizeJsonConfigForPlatform$1(json, compilerCtx);
21245
+ const normalizedJson = normalizeJsonConfigForPlatform(json, compilerCtx);
21125
21246
  ctx.emitFile({
21126
21247
  type: "asset",
21127
21248
  fileName: jsonFile,
@@ -21131,7 +21252,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
21131
21252
  if (scopedSlot.classStyleWxs && classStyleWxs) emitClassStyleWxsAssetIfMissing(ctx, bundle, classStyleWxs.fileName, classStyleWxs.source);
21132
21253
  }
21133
21254
  configObj.usingComponents = usingComponents;
21134
- result.config = JSON.stringify(normalizeJsonConfigForPlatform$1(configObj, compilerCtx), null, 2);
21255
+ result.config = JSON.stringify(normalizeJsonConfigForPlatform(configObj, compilerCtx), null, 2);
21135
21256
  }
21136
21257
  //#endregion
21137
21258
  //#region src/plugins/vue/transform/scopedSlot/module.ts
@@ -21212,70 +21333,6 @@ function loadScopedSlotModule(id, scopedSlotModules) {
21212
21333
  };
21213
21334
  }
21214
21335
  //#endregion
21215
- //#region src/plugins/vue/transform/slotFallbackWrapper.ts
21216
- function parseJsonSafely(source) {
21217
- if (!source) return {};
21218
- try {
21219
- const parsed = JSON.parse(source);
21220
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
21221
- } catch {
21222
- return {};
21223
- }
21224
- }
21225
- function normalizeJsonConfigForPlatform(json, compilerCtx) {
21226
- const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
21227
- if (!jsonPlatformOptions.normalizeUsingComponents) return json;
21228
- try {
21229
- const source = resolveJson({ json }, void 0, jsonPlatformOptions.platform, {
21230
- dependencies: jsonPlatformOptions.dependencies,
21231
- alipayNpmMode: jsonPlatformOptions.alipayNpmMode
21232
- });
21233
- return source ? JSON.parse(source) : json;
21234
- } catch {
21235
- return json;
21236
- }
21237
- }
21238
- function emitSlotFallbackWrapperScriptIfMissing(ctx, bundle, fileName, script) {
21239
- const existing = bundle[fileName];
21240
- if (existing && existing.type === "asset") {
21241
- if ((existing.source?.toString?.() ?? "") !== script) existing.source = script;
21242
- return;
21243
- }
21244
- if (!existing) ctx.emitFile({
21245
- type: "asset",
21246
- fileName,
21247
- source: script
21248
- });
21249
- }
21250
- function injectSlotFallbackWrapperUsingComponent(result, relativeBase, compilerCtx) {
21251
- const component = result.slotFallbackWrapperComponent;
21252
- if (!component) return;
21253
- const config = parseJsonSafely(result.config);
21254
- const usingComponents = config.usingComponents && typeof config.usingComponents === "object" && !Array.isArray(config.usingComponents) ? { ...config.usingComponents } : {};
21255
- usingComponents[component.tagName] = `/${toPosixPath(`${relativeBase}.${component.componentBase}`)}`;
21256
- config.usingComponents = usingComponents;
21257
- result.config = JSON.stringify(normalizeJsonConfigForPlatform(config, compilerCtx), null, 2);
21258
- }
21259
- function emitSlotFallbackWrapperComponentAsset(options) {
21260
- const component = options.result.slotFallbackWrapperComponent;
21261
- if (!component) return;
21262
- const { templateExtension, jsonExtension, scriptExtension } = resolveBundleOutputExtensions(options.outputExtensions);
21263
- const componentBase = `${options.relativeBase}.${component.componentBase}`;
21264
- emitSfcTemplateIfMissing(options.ctx, options.bundle, componentBase, component.template, templateExtension);
21265
- const jsonFileName = `${componentBase}.${jsonExtension}`;
21266
- const mergeJson = createJsonMerger(options.jsonOptions?.mergeStrategy, {
21267
- filename: jsonFileName,
21268
- kind: "component"
21269
- });
21270
- let config = component.config;
21271
- if (options.jsonOptions?.defaults && Object.keys(options.jsonOptions.defaults).length > 0) config = mergeJson(config, options.jsonOptions.defaults, "defaults");
21272
- emitSfcJsonAsset(options.ctx, options.bundle, componentBase, { config: JSON.stringify(normalizeJsonConfigForPlatform(config, options.compilerCtx), null, 2) }, {
21273
- kind: "component",
21274
- extension: jsonExtension
21275
- });
21276
- emitSlotFallbackWrapperScriptIfMissing(options.ctx, options.bundle, `${componentBase}.${scriptExtension}`, component.script);
21277
- }
21278
- //#endregion
21279
21336
  //#region src/plugins/vue/transform/bundle/shared/assets.ts
21280
21337
  const APP_VUE_LIKE_FILE_RE$1 = /[\\/]app\.(?:vue|jsx|tsx)$/;
21281
21338
  function resolveVueBundleAssetContext(configService) {
@@ -21345,6 +21402,12 @@ function emitSharedVueEntryAssets(options) {
21345
21402
  defaults: scopedSlotDefaults,
21346
21403
  mergeStrategy: scopedSlotMergeStrategy
21347
21404
  });
21405
+ injectLocalSlotFallbackWrapperUsingComponentIfNeeded({
21406
+ bundle,
21407
+ result,
21408
+ compilerCtx: ctx,
21409
+ outputExtensions
21410
+ });
21348
21411
  emitSlotFallbackWrapperComponentAsset({
21349
21412
  ctx: pluginCtx,
21350
21413
  bundle,
@@ -21357,7 +21420,6 @@ function emitSharedVueEntryAssets(options) {
21357
21420
  mergeStrategy: scopedSlotMergeStrategy
21358
21421
  }
21359
21422
  });
21360
- injectSlotFallbackWrapperUsingComponent(result, relativeBase, ctx);
21361
21423
  return { classStyleWxs };
21362
21424
  }
21363
21425
  function emitBundleVueEntryAssets(options) {
@@ -23104,6 +23166,7 @@ async function emitVueBundleAssets(bundle, state) {
23104
23166
  if (!emitState) return;
23105
23167
  await emitCompiledBundleEntries(bundle, state, emitState.compilationEntries);
23106
23168
  await emitFallbackPageAssets(bundle, state, { emittedEntryIds: emitState.emittedEntryIds });
23169
+ injectGlobalSlotFallbackWrapperUsingComponent(bundle, state.ctx, state.ctx.configService.outputExtensions);
23107
23170
  }
23108
23171
  //#endregion
23109
23172
  //#region src/plugins/wevu.ts
@@ -24571,7 +24634,7 @@ async function loadAppEntry(ctx, scanState) {
24571
24634
  const vueAppPath = await findVueEntry(appBasename);
24572
24635
  let configFromVue;
24573
24636
  if (!appConfigFile && vueAppPath) {
24574
- const { extractConfigFromVue } = await import("./file-C85Sj-OD.mjs");
24637
+ const { extractConfigFromVue } = await import("./file-obpuUUBb.mjs");
24575
24638
  configFromVue = await extractConfigFromVue(vueAppPath);
24576
24639
  if (configFromVue) appConfigFile = vueAppPath;
24577
24640
  }
@@ -89,6 +89,15 @@ wv mcp doctor codex
89
89
 
90
90
  如果目标明确是 Web runtime,而不是微信开发者工具中的小程序运行时,才改用普通浏览器截图或 Web E2E 工具。
91
91
 
92
+ ## 原生小程序迁移路线
93
+
94
+ 当用户要求迁移存量原生小程序时,先判断迁移终点:
95
+
96
+ - 路线 A:`weapp-vite + 原生`。保留 `Page/Component + WXML/WXSS/JSON`,只升级构建、TypeScript、路径别名、资源处理、DevTools、截图日志、AI 协作和 CI。
97
+ - 路线 B:`weapp-vite + wevu + Vue SFC`。在路线 A 稳定后,按新页面、低风险页面或页面族继续迁到 `.vue`、响应式状态和类型化组件契约。
98
+
99
+ 不要把“接入 `weapp-vite`”自动解释为“必须引入 `wevu` 或改成 `.vue`”。如果用户只要求路线 A,迁移输出应包含原生保留区、工具链改动、验证命令和未来进入路线 B 的触发条件。
100
+
92
101
  ## 推荐阅读顺序
93
102
 
94
103
  - 项目初始化、命令和 AI 使用入口:[`getting-started.md`](./getting-started.md)
@@ -254,17 +254,17 @@
254
254
 
255
255
  如果需要回到旧版 `view` wrapper,可配置 `weapp.vue.template.slotFallbackWrapperStrategy: 'view'`,或显式配置 `slotFallbackWrapper: 'view'`。
256
256
 
257
- `block` 会被编译器拒绝并回退到 `view`。例如全局配置 `slotFallbackWrapper: 'block'` 后,转发 `<slot />` 的场景仍会生成:
257
+ 默认策略不会使用 `block`。如果显式配置 `slotFallbackWrapper: 'block'`,编译器会按原样输出:
258
258
 
259
259
  ```wxml
260
260
  <IssueCard>
261
- <view slot="header">
261
+ <block slot="header">
262
262
  <slot />
263
- </view>
263
+ </block>
264
264
  </IssueCard>
265
265
  ```
266
266
 
267
- 编译器会输出 warning:`slot fallback wrapper 不支持配置为 block,已回退为 view。`
267
+ 注意:`block` 在转发 `<slot />` 的部分 WeChat DevTools 运行时场景中会丢失内容,因此不作为默认值。显式启用时需要自行确认目标运行时和具体插槽内容可用。
268
268
 
269
269
  你选择的 wrapper 必须能承载实际内容。比如下面的写法会让 `text` 包裹 `view`,这不适合真实运行时:
270
270
 
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-DMap3kp4.mjs");
87
+ const { getCompilerContext } = await import("./getInstance-wSKEctAH.mjs");
88
88
  const compilerContext = getCompilerContext();
89
89
  const service = compilerContext.autoRoutesService;
90
90
  const reference = service?.getReference?.();
@@ -0,0 +1,2 @@
1
+ import { t as extractConfigFromVue } from "./file-DgdYQ44n.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { i as getCompilerContext } from "./createContext-wBxmdc_3.mjs";
2
+ export { getCompilerContext };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-BL8Dhhk6.mjs";
2
2
  import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost--CaeyWpA.mjs";
3
3
  import { t as defineConfig } from "./config-DRGcCi3h.mjs";
4
- import { c as WEB_PLATFORM_ALIASES, d as isWebPlatform, f as resolveWeappViteTarget, l as getSupportedWeappVitePlatforms, t as createCompilerContext, u as getSupportedWeappViteTargetDescriptors } from "./createContext-e20SKsa-.mjs";
4
+ import { c as WEB_PLATFORM_ALIASES, d as isWebPlatform, f as resolveWeappViteTarget, l as getSupportedWeappVitePlatforms, t as createCompilerContext, u as getSupportedWeappViteTargetDescriptors } from "./createContext-wBxmdc_3.mjs";
5
5
  import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-C3z9pDQB.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, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.16.28",
4
+ "version": "6.16.29",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -110,29 +110,29 @@
110
110
  "picomatch": "^4.0.4",
111
111
  "postcss": "^8.5.15",
112
112
  "rolldown": "1.0.3",
113
- "rolldown-plugin-dts": "0.25.1",
113
+ "rolldown-plugin-dts": "0.25.2",
114
114
  "semver": "^7.8.1",
115
115
  "typescript": "^6.0.3",
116
116
  "vite": "8.0.14",
117
117
  "vite-tsconfig-paths": "^6.1.1",
118
118
  "vue": "^3.5.35",
119
119
  "vue-tsc": "^3.3.2",
120
- "@weapp-core/constants": "0.1.11",
120
+ "@weapp-core/constants": "0.1.12",
121
121
  "@weapp-core/init": "6.0.9",
122
122
  "@weapp-core/logger": "3.1.1",
123
123
  "@weapp-core/schematics": "6.0.4",
124
124
  "@weapp-core/shared": "3.0.4",
125
- "@weapp-vite/ast": "6.16.28",
125
+ "@weapp-vite/ast": "6.16.29",
126
126
  "@weapp-vite/mcp": "1.3.6",
127
127
  "@weapp-vite/miniprogram-automator": "1.1.3",
128
128
  "@weapp-vite/volar": "2.1.0",
129
- "@weapp-vite/web": "1.3.28",
129
+ "@weapp-vite/web": "1.3.29",
130
130
  "@wevu/api": "0.2.9",
131
- "@wevu/web-apis": "1.2.18",
131
+ "@wevu/web-apis": "1.2.19",
132
132
  "rolldown-require": "2.0.18",
133
133
  "vite-plugin-performance": "2.0.1",
134
134
  "weapp-ide-cli": "5.3.2",
135
- "wevu": "6.16.28"
135
+ "wevu": "6.16.29"
136
136
  },
137
137
  "publishConfig": {
138
138
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-6emWhSkC.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { i as getCompilerContext } from "./createContext-e20SKsa-.mjs";
2
- export { getCompilerContext };