weapp-vite 6.16.11 → 6.16.13

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-ZO_662XD.mjs";
1
+ import { g as getRouteRuntimeGlobalKeys, i as getCompilerContext } from "./createContext-CH-fflWu.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 getDefaultIdeProjectRoot, S as createCjsConfigLoadError, T as isPathInside, _ as resolveWeappConfigFile, b as loadViteConfigFile, 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 checkRuntime, w as shouldPassPlatformArgToIdeOpen, x as parseCommentJson, y as getProjectConfigFileName } from "./createContext-ZO_662XD.mjs";
1
+ import { C as getDefaultIdeProjectRoot, S as createCjsConfigLoadError, T as isPathInside, _ as resolveWeappConfigFile, b as loadViteConfigFile, 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 checkRuntime, w as shouldPassPlatformArgToIdeOpen, x as parseCommentJson, y as getProjectConfigFileName } from "./createContext-CH-fflWu.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
3
- import { h as VERSION } from "./file-C4fZvkCN.mjs";
3
+ import { h as VERSION } from "./file-BJggrdd-.mjs";
4
4
  import { o as resolveWeappMcpConfig, s as startWeappViteMcpServer } from "./mcp-DV3K2AVD.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import path, { posix } from "pathe";
@@ -3704,7 +3704,7 @@ function resolveRunnableHotkeyDefinition(input) {
3704
3704
  }
3705
3705
  //#endregion
3706
3706
  //#region package.json
3707
- var version = "6.16.11";
3707
+ var version = "6.16.13";
3708
3708
  //#endregion
3709
3709
  //#region src/cli/devHotkeys/format.ts
3710
3710
  const FULLWIDTH_ASCII_START = 65281;
@@ -1,6 +1,6 @@
1
1
  import { n as applyWeappViteHostMeta } from "./pluginHost-BEnGeaSo.mjs";
2
2
  import { n as configureLogger, r as logger_default } from "./logger-CgxdNjvb.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-C4fZvkCN.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-BJggrdd-.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";
@@ -9,7 +9,7 @@ import { fs } from "@weapp-core/shared/fs";
9
9
  import { collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, mayContainPlatformApiAccess, mayContainStaticRequireLiteral, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
10
10
  import { collectOnPageScrollPerformanceWarnings } from "@weapp-vite/ast/operations/onPageScroll";
11
11
  import { collectSetDataPickKeysFromTemplateCode } from "@weapp-vite/ast/operations/setDataPick";
12
- import createDebug from "debug";
12
+ import { createDebug } from "obug";
13
13
  import fs$1, { existsSync, readFileSync } from "node:fs";
14
14
  import { parse } from "vue/compiler-sfc";
15
15
  import { BABEL_TS_MODULE_PARSER_OPTIONS, generate, getVisitorKeys, parse as parse$2, parseJsLike, traverse } from "@weapp-vite/ast/babel";
@@ -34,7 +34,7 @@ import { getPackageInfo, getPackageInfoSync, resolveModule } from "local-pkg";
34
34
  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
- 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_ATTR, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
37
+ 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
38
  import { Buffer } from "node:buffer";
39
39
  import { detect } from "package-manager-detector/detect";
40
40
  import tsconfigPaths from "vite-tsconfig-paths";
@@ -8760,11 +8760,11 @@ const sharedChunkDiagnostics = /* @__PURE__ */ new Map();
8760
8760
  const takeImportersMap = /* @__PURE__ */ new Map();
8761
8761
  const forceDuplicateSharedChunks = /* @__PURE__ */ new Set();
8762
8762
  const sharedChunkNameCache = /* @__PURE__ */ new Map();
8763
- function resetTakeImportRegistry() {
8763
+ function resetTakeImportRegistry(options = {}) {
8764
8764
  takeImportersMap.clear();
8765
8765
  forceDuplicateSharedChunks.clear();
8766
8766
  sharedChunkDiagnostics.clear();
8767
- sharedChunkNameCache.clear();
8767
+ if (!options.preserveSharedChunkNameCache) sharedChunkNameCache.clear();
8768
8768
  }
8769
8769
  function getTakeImporters(moduleId) {
8770
8770
  return takeImportersMap.get(moduleId);
@@ -9911,6 +9911,12 @@ function resolveStableHashedDistChunkFileName(chunk) {
9911
9911
  return `weapp-vendors/${packageToken}-${baseName}.js`;
9912
9912
  }
9913
9913
  }
9914
+ function resolveStableHashedDistChunkName(chunk) {
9915
+ return resolveStableHashedDistChunkFileName(chunk)?.replace(/\.js$/, "");
9916
+ }
9917
+ function isStableHashedDistChunkModule(id) {
9918
+ return Boolean(resolveStableHashedDistChunkName({ facadeModuleId: id }));
9919
+ }
9914
9920
  function createSharedBuildResolver(configService, getSubPackageRoots) {
9915
9921
  const nodeModulesDeps = [REG_NODE_MODULES_DIR];
9916
9922
  const commonjsHelpersDeps = [REG_COMMONJS_HELPERS];
@@ -9930,6 +9936,10 @@ function createSharedBuildResolver(configService, getSubPackageRoots) {
9930
9936
  });
9931
9937
  const resolveSharedBuildChunkName = (id, ctx) => {
9932
9938
  if (isRequestGlobalsRuntimeModuleId(id)) return REQUEST_GLOBAL_RUNTIME_CHUNK_FILE_BASENAME.replace(/\.js$/, "");
9939
+ if (configService.isDev) {
9940
+ const stableHashedDistChunkName = resolveStableHashedDistChunkName({ facadeModuleId: id });
9941
+ if (stableHashedDistChunkName) return stableHashedDistChunkName;
9942
+ }
9933
9943
  return resolveAdvancedChunkName(id, ctx);
9934
9944
  };
9935
9945
  return { resolveAdvancedChunkName: resolveSharedBuildChunkName };
@@ -9937,7 +9947,13 @@ function createSharedBuildResolver(configService, getSubPackageRoots) {
9937
9947
  function createSharedBuildOutput(configService, getSubPackageRoots) {
9938
9948
  const { resolveAdvancedChunkName } = createSharedBuildResolver(configService, getSubPackageRoots);
9939
9949
  return {
9940
- codeSplitting: { groups: [{ name: (id, ctx) => resolveAdvancedChunkName(id, ctx) }] },
9950
+ codeSplitting: { groups: [...configService.isDev ? [{
9951
+ test: isStableHashedDistChunkModule,
9952
+ minShareCount: 1,
9953
+ minSize: 0,
9954
+ minModuleSize: 0,
9955
+ name: (id) => resolveStableHashedDistChunkName({ facadeModuleId: id })
9956
+ }] : [], { name: (id, ctx) => resolveAdvancedChunkName(id, ctx) }] },
9941
9957
  minifyInternalExports: false,
9942
9958
  chunkFileNames: (chunk) => {
9943
9959
  if (isRequestGlobalsRuntimeChunk(chunk)) return REQUEST_GLOBAL_RUNTIME_CHUNK_FILE_BASENAME;
@@ -13143,7 +13159,7 @@ function withScopedSlotComponentGenerics(ctx, fileName, buffer) {
13143
13159
  return Buffer.from(normalized ?? JSON.stringify(parsed, null, 2));
13144
13160
  }
13145
13161
  function createScopedSlotGenericTag(key) {
13146
- return `<${key} wx:if="{{${WEVU_SLOT_OWNER_ID_PROP}}}" ${WEVU_SLOT_OWNER_ATTR}="{{${WEVU_SLOT_OWNER_ID_PROP}}}" ${WEVU_SLOT_PROPS_ATTR}="{{[]}}" ${WEVU_SLOT_SCOPE_ATTR}="{{${WEVU_SLOT_SCOPE_KEY}}}" />`;
13162
+ return `<${key} wx:if="{{${WEVU_SLOT_OWNER_ID_PROP}}}" ${WEVU_SLOT_OWNER_ID_ATTR}="{{${WEVU_SLOT_OWNER_ID_PROP}}}" ${WEVU_SLOT_PROPS_ATTR}="{{[]}}" ${WEVU_SLOT_SCOPE_ATTR}="{{${WEVU_SLOT_SCOPE_KEY}}}" />`;
13147
13163
  }
13148
13164
  function createSlotPatchPattern(key) {
13149
13165
  const slotName = key.replace(/^scoped-slots-/, "");
@@ -15744,7 +15760,7 @@ function resolvePendingEntryIds(options) {
15744
15760
  const shouldExpandLayoutSharedChunks = pendingReasonSummary.includes("layout-propagation") || pendingReasonSummary.includes("layout-fallback-full");
15745
15761
  if (shouldExpandLayoutSharedChunks) for (const chunkId of options.sharedChunkImporters.keys()) relatedChunkIds.add(chunkId);
15746
15762
  for (const entryId of options.dirtyEntrySet) {
15747
- if (options.dirtyEntryReasons.get(entryId) === "metadata") continue;
15763
+ if (options.dirtyEntryReasons.get(entryId) !== "dependency") continue;
15748
15764
  const chunkIds = options.sharedChunksByEntry.get(entryId);
15749
15765
  if (!chunkIds?.size) continue;
15750
15766
  for (const chunkId of chunkIds) relatedChunkIds.add(chunkId);
@@ -16147,12 +16163,21 @@ function appendSharedChunkImporters(bundle, state, onlyEntryIds, previousImporte
16147
16163
  if (current) current.add(chunkId);
16148
16164
  else state.hmrSharedChunksByModule.set(moduleId, new Set([chunkId]));
16149
16165
  };
16166
+ const pruneSharedChunkModules = (chunkId, nextModuleIds) => {
16167
+ if (!nextModuleIds.size) return;
16168
+ for (const [moduleId, chunkIds] of state.hmrSharedChunksByModule) {
16169
+ if (nextModuleIds.has(moduleId)) continue;
16170
+ chunkIds.delete(chunkId);
16171
+ if (chunkIds.size === 0) state.hmrSharedChunksByModule.delete(moduleId);
16172
+ }
16173
+ };
16150
16174
  for (const [bundleKey, output] of Object.entries(bundle)) {
16151
16175
  if (output?.type !== "chunk") continue;
16152
16176
  const chunk = output;
16153
16177
  if (!chunk.fileName) chunk.fileName = bundleKey;
16154
16178
  const projectSourceModules = collectProjectSourceModules(chunk);
16155
16179
  bundleChunks.set(chunk.fileName, chunk);
16180
+ pruneSharedChunkModules(chunk.fileName, projectSourceModules);
16156
16181
  if (projectSourceModules.size > 0) state.hmrSourceSharedChunks.add(chunk.fileName);
16157
16182
  for (const moduleId of projectSourceModules) addSharedChunkModule(moduleId, chunk.fileName);
16158
16183
  }
@@ -19016,7 +19041,7 @@ function createBuildStartHook(state) {
19016
19041
  const { configService } = ctx;
19017
19042
  const isPluginBuild = buildTarget === "plugin";
19018
19043
  return async function buildStart() {
19019
- resetTakeImportRegistry();
19044
+ resetTakeImportRegistry({ preserveSharedChunkNameCache: configService.isDev });
19020
19045
  if (configService.isDev) if (isPluginBuild) {
19021
19046
  if (configService.absolutePluginRoot) ensureSidecarWatcher(ctx, configService.absolutePluginRoot);
19022
19047
  } else {
@@ -20569,17 +20594,101 @@ function injectPickIntoOptionsObject(optionsObject, keys) {
20569
20594
  }
20570
20595
  return false;
20571
20596
  }
20572
- /**
20573
- * 从编译后的 WXML 模板提取渲染相关的顶层 key。
20574
- */
20575
- function collectSetDataPickKeysFromTemplate(template, options) {
20576
- return collectSetDataPickKeysFromTemplateCode(template, options);
20597
+ function createScopedSlotHostPropertyDefinition(typeName, value) {
20598
+ return {
20599
+ type: "ObjectExpression",
20600
+ properties: [{
20601
+ type: "ObjectProperty",
20602
+ key: {
20603
+ type: "Identifier",
20604
+ name: "type"
20605
+ },
20606
+ computed: false,
20607
+ shorthand: false,
20608
+ value: typeName === "String" ? {
20609
+ type: "Identifier",
20610
+ name: "String"
20611
+ } : { type: "NullLiteral" }
20612
+ }, {
20613
+ type: "ObjectProperty",
20614
+ key: {
20615
+ type: "Identifier",
20616
+ name: "value"
20617
+ },
20618
+ computed: false,
20619
+ shorthand: false,
20620
+ value: value === null ? { type: "NullLiteral" } : {
20621
+ type: "StringLiteral",
20622
+ value
20623
+ }
20624
+ }]
20625
+ };
20577
20626
  }
20578
- /**
20579
- * 在 wevu 组件脚本中注入 setData.pick。
20580
- */
20581
- function injectSetDataPickInJs(source, pickKeys) {
20582
- if (!pickKeys.length || !mayNeedInjectSetDataPickInJs(source)) return {
20627
+ function createScopedSlotHostProperties() {
20628
+ return [{
20629
+ type: "ObjectProperty",
20630
+ key: {
20631
+ type: "Identifier",
20632
+ name: WEVU_SLOT_OWNER_ID_PROP
20633
+ },
20634
+ computed: false,
20635
+ shorthand: false,
20636
+ value: createScopedSlotHostPropertyDefinition("String", "")
20637
+ }, {
20638
+ type: "ObjectProperty",
20639
+ key: {
20640
+ type: "Identifier",
20641
+ name: WEVU_SLOT_SCOPE_KEY
20642
+ },
20643
+ computed: false,
20644
+ shorthand: false,
20645
+ value: createScopedSlotHostPropertyDefinition("null", null)
20646
+ }];
20647
+ }
20648
+ function injectScopedSlotHostPropertiesIntoObject(propertiesObject) {
20649
+ let changed = false;
20650
+ for (const prop of createScopedSlotHostProperties().reverse()) {
20651
+ const key = prop.key.type === "Identifier" ? prop.key.name : void 0;
20652
+ if (!key || getObjectPropertyByKey(propertiesObject, key)) continue;
20653
+ propertiesObject.properties.unshift(prop);
20654
+ changed = true;
20655
+ }
20656
+ return changed;
20657
+ }
20658
+ function injectScopedSlotHostPropertiesIntoOptionsObject(optionsObject) {
20659
+ const propertiesProp = getObjectPropertyByKey(optionsObject, "properties");
20660
+ if (!propertiesProp) {
20661
+ optionsObject.properties.unshift({
20662
+ type: "ObjectProperty",
20663
+ key: {
20664
+ type: "Identifier",
20665
+ name: "properties"
20666
+ },
20667
+ computed: false,
20668
+ shorthand: false,
20669
+ value: {
20670
+ type: "ObjectExpression",
20671
+ properties: createScopedSlotHostProperties()
20672
+ }
20673
+ });
20674
+ return true;
20675
+ }
20676
+ const propertiesValue = unwrapExpression(propertiesProp.value);
20677
+ if (propertiesValue.type === "ObjectExpression") return injectScopedSlotHostPropertiesIntoObject(propertiesValue);
20678
+ if (propertiesValue.type === "Identifier" || propertiesValue.type === "MemberExpression" || propertiesValue.type === "CallExpression") {
20679
+ propertiesProp.value = {
20680
+ type: "ObjectExpression",
20681
+ properties: [{
20682
+ type: "SpreadElement",
20683
+ argument: propertiesValue
20684
+ }, ...createScopedSlotHostProperties()]
20685
+ };
20686
+ return true;
20687
+ }
20688
+ return false;
20689
+ }
20690
+ function transformTargetWevuOptionsInJs(source, transformOptions) {
20691
+ if (!mayNeedInjectSetDataPickInJs(source)) return {
20583
20692
  code: source,
20584
20693
  transformed: false
20585
20694
  };
@@ -20597,7 +20706,7 @@ function injectSetDataPickInJs(source, pickKeys) {
20597
20706
  transformed: false
20598
20707
  };
20599
20708
  let changed = false;
20600
- for (const optionsObject of candidateOptions) changed = injectPickIntoOptionsObject(optionsObject, pickKeys) || changed;
20709
+ for (const optionsObject of candidateOptions) changed = transformOptions(optionsObject) || changed;
20601
20710
  if (!changed) return {
20602
20711
  code: source,
20603
20712
  transformed: false
@@ -20613,6 +20722,28 @@ function injectSetDataPickInJs(source, pickKeys) {
20613
20722
  map: generated.map
20614
20723
  };
20615
20724
  }
20725
+ /**
20726
+ * 从编译后的 WXML 模板提取渲染相关的顶层 key。
20727
+ */
20728
+ function collectSetDataPickKeysFromTemplate(template, options) {
20729
+ return collectSetDataPickKeysFromTemplateCode(template, options);
20730
+ }
20731
+ /**
20732
+ * 在 wevu 组件脚本中注入 setData.pick。
20733
+ */
20734
+ function injectSetDataPickInJs(source, pickKeys) {
20735
+ if (!pickKeys.length) return {
20736
+ code: source,
20737
+ transformed: false
20738
+ };
20739
+ return transformTargetWevuOptionsInJs(source, (optionsObject) => injectPickIntoOptionsObject(optionsObject, pickKeys));
20740
+ }
20741
+ /**
20742
+ * 在含有 scoped slot outlet 的 wevu 组件脚本中注入宿主内部属性。
20743
+ */
20744
+ function injectScopedSlotHostPropertiesInJs(source) {
20745
+ return transformTargetWevuOptionsInJs(source, injectScopedSlotHostPropertiesIntoOptionsObject);
20746
+ }
20616
20747
  //#endregion
20617
20748
  //#region src/plugins/vue/transform/bundle/shared/types.ts
20618
20749
  function getVueBundlePageLayoutPlan(result) {
@@ -20708,6 +20839,10 @@ async function finalizeCompiledVueLikeResult(options) {
20708
20839
  const injectedPick = injectSetDataPickInJs(result.script, keys);
20709
20840
  if (injectedPick.transformed) result.script = injectedPick.code;
20710
20841
  }
20842
+ if (!isPage && !isApp && result.script && result.template?.includes(WEVU_SLOT_OWNER_ID_PROP)) {
20843
+ const injectedProps = injectScopedSlotHostPropertiesInJs(result.script);
20844
+ if (injectedProps.transformed) result.script = injectedProps.code;
20845
+ }
20711
20846
  return result;
20712
20847
  }
20713
20848
  async function compileAndFinalizeVueLikeFile(options) {
@@ -21553,6 +21688,13 @@ async function finalizeTransformEntryScript(options) {
21553
21688
  result.scriptMap = composeSourceMaps(injectedPick.map, result.scriptMap);
21554
21689
  }
21555
21690
  }
21691
+ if (!isPage && !isApp && result.script && result.template?.includes(WEVU_SLOT_OWNER_ID_PROP)) {
21692
+ const injectedProps = injectScopedSlotHostPropertiesInJs(result.script);
21693
+ if (injectedProps.transformed) {
21694
+ result.script = injectedProps.code;
21695
+ result.scriptMap = composeSourceMaps(injectedProps.map, result.scriptMap);
21696
+ }
21697
+ }
21556
21698
  return result;
21557
21699
  }
21558
21700
  function finalizeTransformEntryCode(options) {
@@ -22208,6 +22350,26 @@ function escapeRegex(value) {
22208
22350
  function createAbsolutePathPattern(value) {
22209
22351
  return value.split(PATH_SEPARATOR_SPLIT_REGEX).map((segment) => escapeRegex(segment)).join("[/\\\\]+");
22210
22352
  }
22353
+ function normalizeInlineConfigAfterDefu(inline, options) {
22354
+ const { ctx, platform, rolldownOptions, subPackageMeta } = options;
22355
+ const build = inline.build ?? (inline.build = {});
22356
+ const userRolldownOptions = build.rolldownOptions;
22357
+ build.rolldownOptions = {
22358
+ ...userRolldownOptions ?? {},
22359
+ ...rolldownOptions,
22360
+ output: {
22361
+ ...rolldownOptions.output,
22362
+ ...userRolldownOptions?.output ?? {}
22363
+ }
22364
+ };
22365
+ inline.define = {
22366
+ ...inline.define ?? {},
22367
+ __VITE_IS_MODERN__: "false"
22368
+ };
22369
+ applyWeappViteHostMeta(inline, "miniprogram", platform);
22370
+ stripRollupOptions(inline);
22371
+ arrangePlugins(inline, ctx, subPackageMeta);
22372
+ }
22211
22373
  function resolveMiniprogramWatchInclude(options) {
22212
22374
  const watchInclude = [path.join(options.cwd, options.srcRoot, "**")];
22213
22375
  if (!options.pluginRoot) return watchInclude;
@@ -22267,13 +22429,12 @@ function mergeMiniprogram(options, ...configs) {
22267
22429
  sourcemap: false
22268
22430
  }
22269
22431
  });
22270
- inline.define = {
22271
- ...inline.define ?? {},
22272
- __VITE_IS_MODERN__: "false"
22273
- };
22274
- applyWeappViteHostMeta(inline, "miniprogram", platform);
22275
- stripRollupOptions(inline);
22276
- arrangePlugins(inline, ctx, subPackageMeta);
22432
+ normalizeInlineConfigAfterDefu(inline, {
22433
+ ctx,
22434
+ platform,
22435
+ rolldownOptions,
22436
+ subPackageMeta
22437
+ });
22277
22438
  injectBuiltinAliases(inline);
22278
22439
  return inline;
22279
22440
  }
@@ -22288,13 +22449,12 @@ function mergeMiniprogram(options, ...configs) {
22288
22449
  rolldownOptions: { ...rolldownOptions }
22289
22450
  }
22290
22451
  });
22291
- inlineConfig.define = {
22292
- ...inlineConfig.define ?? {},
22293
- __VITE_IS_MODERN__: "false"
22294
- };
22295
- applyWeappViteHostMeta(inlineConfig, "miniprogram", platform);
22296
- stripRollupOptions(inlineConfig);
22297
- arrangePlugins(inlineConfig, ctx, subPackageMeta);
22452
+ normalizeInlineConfigAfterDefu(inlineConfig, {
22453
+ ctx,
22454
+ platform,
22455
+ rolldownOptions,
22456
+ subPackageMeta
22457
+ });
22298
22458
  inlineConfig.logLevel = "warn";
22299
22459
  injectBuiltinAliases(inlineConfig);
22300
22460
  const currentRoot = subPackageMeta?.subPackage.root;
@@ -23240,7 +23400,7 @@ async function loadAppEntry(ctx, scanState) {
23240
23400
  const vueAppPath = await findVueEntry(appBasename);
23241
23401
  let configFromVue;
23242
23402
  if (!appConfigFile && vueAppPath) {
23243
- const { extractConfigFromVue } = await import("./file-B0TT5uIp.mjs");
23403
+ const { extractConfigFromVue } = await import("./file-Cnv4FhFK.mjs");
23244
23404
  configFromVue = await extractConfigFromVue(vueAppPath);
23245
23405
  if (configFromVue) appConfigFile = vueAppPath;
23246
23406
  }
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-RLgRsNLD.mjs");
87
+ const { getCompilerContext } = await import("./getInstance-CAxuHsMM.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-BJggrdd-.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { i as getCompilerContext } from "./createContext-CH-fflWu.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-D0HkutE0.mjs";
2
2
  import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BEnGeaSo.mjs";
3
3
  import { t as defineConfig } from "./config-DJjSbpNX.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-ZO_662XD.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-CH-fflWu.mjs";
5
5
  import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-spnjzaP2.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.11",
4
+ "version": "6.16.13",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -97,13 +97,13 @@
97
97
  "cac": "^7.0.0",
98
98
  "chokidar": "^5.0.0",
99
99
  "comment-json": "^5.0.0",
100
- "debug": "^4.4.3",
101
100
  "fdir": "^6.5.0",
102
101
  "htmlparser2": "^12.0.0",
103
102
  "local-pkg": "^1.1.2",
104
103
  "lru-cache": "^11.3.6",
105
104
  "magic-string": "^0.30.21",
106
105
  "merge": "^2.1.1",
106
+ "obug": "^2.1.1",
107
107
  "p-queue": "^9.2.0",
108
108
  "package-manager-detector": "^1.6.0",
109
109
  "pathe": "^2.0.3",
@@ -117,29 +117,29 @@
117
117
  "vite-tsconfig-paths": "^6.1.1",
118
118
  "vue": "^3.5.34",
119
119
  "vue-tsc": "^3.2.8",
120
- "@weapp-core/constants": "^0.1.6",
121
120
  "@weapp-core/init": "6.0.8",
122
- "@weapp-core/logger": "3.1.1",
123
- "@weapp-core/schematics": "6.0.4",
121
+ "@weapp-core/constants": "^0.1.7",
124
122
  "@weapp-core/shared": "3.0.4",
125
- "@weapp-vite/ast": "6.16.11",
126
- "@weapp-vite/mcp": "1.3.2",
127
- "@weapp-vite/miniprogram-automator": "1.1.0",
128
- "@weapp-vite/volar": "2.1.0",
123
+ "@weapp-core/schematics": "6.0.4",
124
+ "@weapp-core/logger": "3.1.1",
125
+ "@weapp-vite/ast": "6.16.13",
126
+ "@weapp-vite/miniprogram-automator": "1.1.1",
129
127
  "@weapp-vite/web": "1.3.20",
130
- "@wevu/api": "0.2.8",
131
- "@wevu/web-apis": "1.2.12",
128
+ "@weapp-vite/volar": "2.1.0",
132
129
  "rolldown-require": "2.0.15",
130
+ "@wevu/web-apis": "1.2.12",
131
+ "@wevu/api": "0.2.8",
133
132
  "vite-plugin-performance": "2.0.1",
134
- "weapp-ide-cli": "5.2.9",
135
- "wevu": "6.16.11"
133
+ "weapp-ide-cli": "5.2.10",
134
+ "wevu": "6.16.13",
135
+ "@weapp-vite/mcp": "1.3.3"
136
136
  },
137
137
  "publishConfig": {
138
138
  "access": "public",
139
139
  "registry": "https://registry.npmjs.org"
140
140
  },
141
141
  "devDependencies": {
142
- "oxc-parser": "^0.129.0",
142
+ "oxc-parser": "^0.130.0",
143
143
  "oxc-walker": "^1.0.0",
144
144
  "tailwindcss": "^4.3.0",
145
145
  "ts-morph": "^28.0.0"
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-C4fZvkCN.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { i as getCompilerContext } from "./createContext-ZO_662XD.mjs";
2
- export { getCompilerContext };