weapp-vite 6.18.7 → 6.19.0

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,22 +1,22 @@
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-DjQkG6ce.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-BgstESAr.mjs";
4
4
  import { createRequire, isBuiltin } from "node:module";
5
5
  import { createDebug } from "obug";
6
6
  import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
7
- 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, WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX, WEAPP_VITE_LOGICAL_ENTRY_VIRTUAL_PREFIX, WEAPP_VITE_RUNTIME_CONTRACT_VERSION, WEAPP_VITE_RUNTIME_REACTIVITY_VIRTUAL_ID, WEAPP_VITE_RUNTIME_TEMPLATE_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_IDS, WEAPP_VITE_SIDECAR_OWNER_QUERY_MARKER, WEAPP_VITE_SIDECAR_QUERY_MARKER, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX, WEAPP_VITE_SIDECAR_VIRTUAL_PREFIX, WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY, WEAPP_VITE_STATEFUL_HMR_CLIENT_KEY, WEAPP_VITE_STATEFUL_HMR_CONTROL_FILE, WEAPP_VITE_STATEFUL_HMR_CONTROL_KEY, WEAPP_VITE_STATEFUL_HMR_PRELOAD_FILE, WEAPP_VITE_STATEFUL_HMR_UPDATE_FILE, 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_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
7
+ 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_EXTERNAL_OUTPUT_DIRECTORY, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX, WEAPP_VITE_LOGICAL_ENTRY_VIRTUAL_PREFIX, WEAPP_VITE_RUNTIME_CONTRACT_VERSION, WEAPP_VITE_RUNTIME_REACTIVITY_VIRTUAL_ID, WEAPP_VITE_RUNTIME_TEMPLATE_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_IDS, WEAPP_VITE_SIDECAR_OWNER_QUERY_MARKER, WEAPP_VITE_SIDECAR_QUERY_MARKER, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX, WEAPP_VITE_SIDECAR_VIRTUAL_PREFIX, WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY, WEAPP_VITE_STATEFUL_HMR_CLIENT_KEY, WEAPP_VITE_STATEFUL_HMR_CONTROL_FILE, WEAPP_VITE_STATEFUL_HMR_CONTROL_KEY, WEAPP_VITE_STATEFUL_HMR_PRELOAD_FILE, WEAPP_VITE_STATEFUL_HMR_UPDATE_FILE, 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_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
8
8
  import path, { posix } from "pathe";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import path$1, { normalize, relative, win32 } from "node:path";
11
11
  import { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, MINI_PROGRAM_PLATFORM_DESCRIPTORS as MINI_PROGRAM_PLATFORM_ADAPTERS, addExtension, defu, escapeStringRegexp, get, getDefaultMiniProgramPlatform, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, isEmptyObject, isObject, normalizeMiniProgramPlatform, removeExtension, removeExtensionDeep, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle } from "@weapp-core/shared";
12
12
  import { fs as fs$1 } from "@weapp-core/shared/fs";
13
- import { analyzeScript, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
13
+ import { analyzeScript, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
14
14
  import { collectOnPageScrollPerformanceWarnings } from "@weapp-vite/ast/operations/onPageScroll";
15
15
  import { collectSetDataPickKeysFromTemplateCode } from "@weapp-vite/ast/operations/setDataPick";
16
16
  import { compileScript, parse } from "vue/compiler-sfc";
17
- import { BABEL_TS_MODULE_PARSER_OPTIONS, generate, getVisitorKeys, parse as parse$2, parseJsLike, traverse } from "@weapp-vite/ast/babel";
17
+ import { BABEL_TS_MODULE_PARSER_OPTIONS, generate as generate$1, getVisitorKeys, parse as parse$2, parseJsLike, traverse } from "@weapp-vite/ast/babel";
18
18
  import pm from "picomatch";
19
- import { VUE_COMPONENT_TAG_RE, WE_VU_COMPILER_REACTIVITY_MODULE_ID, WE_VU_COMPILER_RUNTIME_MODULE_ID, WE_VU_COMPILER_TEMPLATE_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, collectVueTemplateTags, compileJsxFile, compileVueFile, compileVueStyleToWxss, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, pathExists, readAndParseSfc, readFile as readFile$1, refreshVueFileJsonConfig, resolveClassStyleWxsLocation, stripJsonMacroCallsFromCode } from "wevu/compiler";
19
+ import { VUE_COMPONENT_TAG_RE, WE_VU_COMPILER_REACTIVITY_MODULE_ID, WE_VU_COMPILER_RUNTIME_MODULE_ID, WE_VU_COMPILER_TEMPLATE_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, collectVueTemplateTags, compileJsxFile, compileVueFile, compileVueStyleToWxss, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isUniAppCompatibilityFile, pathExists, readAndParseSfc, readFile as readFile$1, refreshVueFileJsonConfig, resolveClassStyleWxsLocation, stripJsonMacroCallsFromCode, transformNestedWxssVars, transformUniAppSource, transformVueDeepSelectors } from "wevu/compiler";
20
20
  import process from "node:process";
21
21
  import { parse as parse$1, stringify } from "comment-json";
22
22
  import fs$2, { appendFile, copyFile, mkdir, readFile, readdir, rm } from "node:fs/promises";
@@ -1216,7 +1216,7 @@ function mapConstructorName(name) {
1216
1216
  //#endregion
1217
1217
  //#region src/runtime/autoImport/dtsProps.ts
1218
1218
  function getNodeText(node) {
1219
- return generate(node, {
1219
+ return generate$1(node, {
1220
1220
  comments: false,
1221
1221
  concise: true
1222
1222
  }).code.trim();
@@ -4895,7 +4895,7 @@ async function syncTypedComponentsDefinition(settings, options) {
4895
4895
  }
4896
4896
  }
4897
4897
  async function syncVueComponentsDefinition(settings, options) {
4898
- const { outputsState, ctx, resolverComponentsMapRef, resolveNavigationImport } = options;
4898
+ const { outputsState, ctx, resolverComponentsMapRef, resolveComponentTypeImport } = options;
4899
4899
  const configService = requireConfigService(ctx, "写入 components.d.ts 前必须初始化 configService。");
4900
4900
  if (!settings.enabled || !settings.outputPath) {
4901
4901
  if (outputsState.lastVueComponentsOutputPath) try {
@@ -4931,7 +4931,7 @@ async function syncVueComponentsDefinition(settings, options) {
4931
4931
  }
4932
4932
  const from = resolverComponentsMapRef.value[name];
4933
4933
  if (!from) return;
4934
- return resolveNavigationImport(from);
4934
+ return resolveComponentTypeImport(name, from);
4935
4935
  }
4936
4936
  });
4937
4937
  const vueUnchanged = nextDefinition === outputsState.lastWrittenVueComponentsDefinition && outputPath === outputsState.lastVueComponentsOutputPath;
@@ -4984,7 +4984,7 @@ async function syncHtmlCustomData(settings, options) {
4984
4984
  //#endregion
4985
4985
  //#region src/runtime/autoImport/service/outputs/index.ts
4986
4986
  function createOutputsHelpers(options) {
4987
- const { ctx, registry, manifestFileName, manifestCache, componentMetadataMap, outputsState, getPreparedStateVersion, resolverComponentsMapRef, collectResolverComponents, collectManifestResolverComponents, syncResolverComponentProps, preloadResolverComponentMetadata, getComponentMetadata, resolveNavigationImport } = options;
4987
+ const { ctx, registry, manifestFileName, manifestCache, componentMetadataMap, outputsState, getPreparedStateVersion, resolverComponentsMapRef, collectResolverComponents, collectManifestResolverComponents, syncResolverComponentProps, preloadResolverComponentMetadata, getComponentMetadata, resolveComponentTypeImport } = options;
4988
4988
  const commonSyncOptions = {
4989
4989
  ctx,
4990
4990
  outputsState,
@@ -5015,7 +5015,7 @@ function createOutputsHelpers(options) {
5015
5015
  syncVueComponents: async (settings) => syncVueComponentsDefinition(settings, {
5016
5016
  ...commonSyncOptions,
5017
5017
  resolverComponentsMapRef,
5018
- resolveNavigationImport
5018
+ resolveComponentTypeImport
5019
5019
  })
5020
5020
  });
5021
5021
  return {
@@ -5951,6 +5951,11 @@ function createResolverHelpers(state) {
5951
5951
  }
5952
5952
  resolveCache.set(cacheKey, null);
5953
5953
  }
5954
+ function resolveComponentTypeImport(componentName, from) {
5955
+ const resolved = resolveWithResolvers(componentName);
5956
+ if (resolved?.from === from && resolved.typeImport === false) return;
5957
+ return resolveNavigationImport(from);
5958
+ }
5954
5959
  return {
5955
5960
  collectResolverComponents,
5956
5961
  collectRuntimeResolverComponents,
@@ -5961,7 +5966,8 @@ function createResolverHelpers(state) {
5961
5966
  clearSupportFileResolverComponents,
5962
5967
  collectStaticResolverComponentsForSupportFiles,
5963
5968
  resolveWithResolvers,
5964
- resolveNavigationImport
5969
+ resolveNavigationImport,
5970
+ resolveComponentTypeImport
5965
5971
  };
5966
5972
  }
5967
5973
  //#endregion
@@ -6114,7 +6120,7 @@ function createAutoImportService(ctx) {
6114
6120
  syncResolverComponentProps: resolverHelpers.syncResolverComponentProps,
6115
6121
  preloadResolverComponentMetadata: metadataHelpers.preloadResolverComponentMetadata,
6116
6122
  getComponentMetadata: metadataHelpers.getComponentMetadata,
6117
- resolveNavigationImport: resolverHelpers.resolveNavigationImport
6123
+ resolveComponentTypeImport: resolverHelpers.resolveComponentTypeImport
6118
6124
  })
6119
6125
  });
6120
6126
  return {
@@ -7602,7 +7608,15 @@ function resolveNpmStrategyMode(ctx) {
7602
7608
  //#region src/moduleGraph/logicalEntry.ts
7603
7609
  function createLogicalEntryModuleCode(entry, dependencies) {
7604
7610
  const source = JSON.stringify(entry.sourceId);
7605
- const imports = [entry.type !== "app" && /\.(?:vue|jsx|tsx)$/.test(entry.sourceId) ? `export { default } from ${source};` : `import ${source};`];
7611
+ const isVueLikeEntry = /\.(?:vue|jsx|tsx)$/.test(entry.sourceId);
7612
+ const delegatesComponentRegistration = entry.type === "component" && isVueLikeEntry;
7613
+ const forwardsDefault = entry.type !== "app" && isVueLikeEntry;
7614
+ const imports = delegatesComponentRegistration ? [
7615
+ `import { createWevuComponent as __weappViteCreateWevuComponent } from "wevu";`,
7616
+ `import __weappViteComponentOptions from ${source};`,
7617
+ `__weappViteCreateWevuComponent(__weappViteComponentOptions);`,
7618
+ `export default __weappViteComponentOptions;`
7619
+ ] : [forwardsDefault ? `export { default } from ${source};` : `import ${source};`];
7606
7620
  const seen = /* @__PURE__ */ new Set();
7607
7621
  for (const dependency of dependencies) {
7608
7622
  const dependencyId = createSidecarModuleId(entry.sourceId, dependency.sourceId, dependency.kind);
@@ -10194,6 +10208,103 @@ function createAdvancedChunkNameResolver(options) {
10194
10208
  };
10195
10209
  }
10196
10210
  //#endregion
10211
+ //#region src/runtime/wevuModules.ts
10212
+ const WEVU_RUNTIME_MODULE_IDS = [
10213
+ "wevu",
10214
+ "wevu/router",
10215
+ "wevu/store",
10216
+ "wevu/api",
10217
+ "wevu/fetch",
10218
+ "wevu/web-apis",
10219
+ "wevu/internal-runtime",
10220
+ "wevu/internal-reactivity",
10221
+ "wevu/internal-template"
10222
+ ];
10223
+ const WEVU_ENTRY_MODULE_IDS = {
10224
+ "api": "wevu/api",
10225
+ "fetch": "wevu/fetch",
10226
+ "index": "wevu",
10227
+ "internal-reactivity": "wevu/internal-reactivity",
10228
+ "internal-runtime": "wevu/internal-runtime",
10229
+ "internal-template": "wevu/internal-template",
10230
+ "router": "wevu/router",
10231
+ "store": "wevu/store",
10232
+ "web-apis": "wevu/web-apis"
10233
+ };
10234
+ const WEVU_STABLE_VENDOR_FILE_RE = /^weapp-vendors\/wevu-[^/]+\.js$/;
10235
+ const HASHED_MODULE_BASENAME_RE = /-[\w-]{8}$/;
10236
+ const WEVU_RUNTIME_MODULE_ID_BY_FAMILY = {
10237
+ "api": "wevu/api",
10238
+ "fetch": "wevu/fetch",
10239
+ "reactivity": "wevu/internal-reactivity",
10240
+ "router": "wevu/router",
10241
+ "runtime": "wevu/internal-runtime",
10242
+ "store": "wevu/store",
10243
+ "template": "wevu/internal-template",
10244
+ "web-apis": "wevu/web-apis"
10245
+ };
10246
+ function isWevuEntryModulePath(value) {
10247
+ return Object.prototype.hasOwnProperty.call(WEVU_ENTRY_MODULE_IDS, value);
10248
+ }
10249
+ function normalizeModuleId(id) {
10250
+ return normalizeViteId(id, {
10251
+ stripQuery: true,
10252
+ fileProtocolToPath: true,
10253
+ stripAtFsPrefix: true,
10254
+ stripLeadingNullByte: true
10255
+ }).replaceAll("\\", "/");
10256
+ }
10257
+ function resolveWevuPreservedModulePath(id) {
10258
+ const normalized = normalizeModuleId(id);
10259
+ const sourceMarker = "/packages-runtime/wevu/src/";
10260
+ const distMarker = "/wevu/dist/";
10261
+ const sourceIndex = normalized.lastIndexOf(sourceMarker);
10262
+ if (sourceIndex >= 0) return normalized.slice(sourceIndex + 27).replace(/\.[cm]?[jt]s$/, "");
10263
+ const distIndex = normalized.lastIndexOf(distMarker);
10264
+ if (distIndex < 0) return;
10265
+ const modulePath = normalized.slice(distIndex + 11).replace(/^dev\//, "").replace(/\.[cm]?[jt]s$/, "");
10266
+ if (!isWevuEntryModulePath(modulePath) && HASHED_MODULE_BASENAME_RE.test(modulePath)) return;
10267
+ return modulePath;
10268
+ }
10269
+ function resolveWevuRuntimeModuleId(id) {
10270
+ if (WEVU_RUNTIME_MODULE_IDS.includes(id)) return id;
10271
+ const modulePath = resolveWevuPreservedModulePath(id);
10272
+ if (!modulePath || modulePath.includes("/")) return;
10273
+ return WEVU_ENTRY_MODULE_IDS[modulePath];
10274
+ }
10275
+ function resolveWevuRuntimeModuleFamily(id) {
10276
+ const bareModuleId = resolveWevuRuntimeModuleId(id);
10277
+ if (bareModuleId) {
10278
+ if (bareModuleId === "wevu/internal-reactivity") return "reactivity";
10279
+ if (bareModuleId === "wevu/internal-template") return "template";
10280
+ if (bareModuleId === "wevu/internal-runtime" || bareModuleId === "wevu") return "runtime";
10281
+ return bareModuleId.slice(5);
10282
+ }
10283
+ const modulePath = resolveWevuPreservedModulePath(id);
10284
+ if (!modulePath) return;
10285
+ if (modulePath.startsWith("reactivity/") || modulePath === "scheduler") return "reactivity";
10286
+ if (modulePath === "runtime/template") return "template";
10287
+ if (modulePath.startsWith("router/") || modulePath.startsWith("routerInternal/")) return "router";
10288
+ if (modulePath.startsWith("store/")) return "store";
10289
+ if (modulePath.startsWith("compiler/")) return "compiler";
10290
+ if (modulePath === "jsx-runtime" || modulePath === "vue-demi") return modulePath;
10291
+ if (modulePath === "api" || modulePath === "fetch" || modulePath === "web-apis") return modulePath;
10292
+ return "runtime";
10293
+ }
10294
+ function resolveWevuStableVendorFileName(id) {
10295
+ const family = resolveWevuRuntimeModuleFamily(id);
10296
+ return family ? `weapp-vendors/wevu-${family}.js` : void 0;
10297
+ }
10298
+ function isWevuStableVendorFileName(fileName) {
10299
+ return WEVU_STABLE_VENDOR_FILE_RE.test(fileName.replaceAll("\\", "/"));
10300
+ }
10301
+ function resolveWevuRuntimeModuleIdFromStableVendorFileName(fileName) {
10302
+ const normalized = fileName.replaceAll("\\", "/");
10303
+ if (!isWevuStableVendorFileName(normalized)) return;
10304
+ const family = normalized.slice(19, -3);
10305
+ return WEVU_RUNTIME_MODULE_ID_BY_FAMILY[family];
10306
+ }
10307
+ //#endregion
10197
10308
  //#region src/runtime/sharedBuildConfig.ts
10198
10309
  const REG_NODE_MODULES_DIR = /[\\/]node_modules[\\/]/gi;
10199
10310
  const REG_COMMONJS_HELPERS = /commonjsHelpers\.js$/;
@@ -10331,6 +10442,10 @@ function resolveStableHashedDistChunkFileName(chunk) {
10331
10442
  const candidateIds = [chunk.facadeModuleId, ...chunk.moduleIds ?? []].filter((id) => typeof id === "string");
10332
10443
  const matchedChunks = [];
10333
10444
  let facadeMatchedChunk;
10445
+ for (const id of candidateIds) {
10446
+ const fileName = resolveWevuStableVendorFileName(id);
10447
+ if (fileName) return fileName;
10448
+ }
10334
10449
  for (const id of candidateIds) {
10335
10450
  if (isWeappViteRuntimeModuleId(id)) return "weapp-vendors/weapp-vite-runtime.js";
10336
10451
  const cleanedAbsoluteId = normalizeSharedPathCandidate(id);
@@ -10403,7 +10518,7 @@ function createSharedBuildResolver(configService, getSubPackageRoots) {
10403
10518
  };
10404
10519
  return { resolveAdvancedChunkName: resolveSharedBuildChunkName };
10405
10520
  }
10406
- function createSharedBuildOutput(configService, getSubPackageRoots) {
10521
+ function createSharedBuildOutput(configService, getSubPackageRoots, options = {}) {
10407
10522
  const { resolveAdvancedChunkName } = createSharedBuildResolver(configService, getSubPackageRoots);
10408
10523
  return {
10409
10524
  codeSplitting: { groups: [...configService.isDev ? [{
@@ -10416,8 +10531,12 @@ function createSharedBuildOutput(configService, getSubPackageRoots) {
10416
10531
  minifyInternalExports: false,
10417
10532
  chunkFileNames: (chunk) => {
10418
10533
  if (isRequestGlobalsRuntimeChunk(chunk)) return REQUEST_GLOBAL_RUNTIME_CHUNK_FILE_BASENAME;
10419
- const stableHashedDistChunkFileName = resolveStableHashedDistChunkFileName(chunk);
10420
- if (stableHashedDistChunkFileName) return stableHashedDistChunkFileName;
10534
+ if (options.runtime !== "web") {
10535
+ const namedStableVendorFileName = `${chunk.name}.js`;
10536
+ if (isWevuStableVendorFileName(namedStableVendorFileName)) return namedStableVendorFileName;
10537
+ const stableHashedDistChunkFileName = resolveStableHashedDistChunkFileName(chunk);
10538
+ if (stableHashedDistChunkFileName) return stableHashedDistChunkFileName;
10539
+ }
10421
10540
  return "[name].js";
10422
10541
  }
10423
10542
  };
@@ -10553,6 +10672,8 @@ const bridgeKey = ${JSON.stringify(WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY)};
10553
10672
  const definitions = new Map();
10554
10673
  const registered = new Set();
10555
10674
  const instances = new Map();
10675
+ const instanceSnapshots = new WeakMap();
10676
+ const moduleSnapshots = new Map();
10556
10677
  const pendingNativeDefinitions = new Map();
10557
10678
  const wevuRefreshes = new Map();
10558
10679
  const wevuRefreshGenerations = new Map();
@@ -10564,6 +10685,74 @@ function getInstances(moduleId) {
10564
10685
  if (!values) instances.set(moduleId, values = new Set());
10565
10686
  return values;
10566
10687
  }
10688
+ function cloneInstanceData(value) {
10689
+ if (Array.isArray(value)) return value.map(cloneInstanceData);
10690
+ if (!value || typeof value !== 'object') return value;
10691
+ const result = {};
10692
+ for (const [key, child] of Object.entries(value)) result[key] = cloneInstanceData(child);
10693
+ return result;
10694
+ }
10695
+ function countChangedDataKeys(data, initialData) {
10696
+ let changed = 0;
10697
+ for (const [key, value] of Object.entries(data)) {
10698
+ if (!Object.prototype.hasOwnProperty.call(initialData, key)) {
10699
+ changed++;
10700
+ continue;
10701
+ }
10702
+ try {
10703
+ if (JSON.stringify(value) !== JSON.stringify(initialData[key])) changed++;
10704
+ } catch {
10705
+ if (value !== initialData[key]) changed++;
10706
+ }
10707
+ }
10708
+ return changed;
10709
+ }
10710
+ function rememberInstanceState(instance, moduleId) {
10711
+ if (!instance?.data || typeof instance.data !== 'object') return;
10712
+ const data = cloneInstanceData(instance.data);
10713
+ const definitionData = definitions.get(moduleId)?.data;
10714
+ const initialData = definitionData && typeof definitionData === 'object' ? definitionData : {};
10715
+ const changedKeys = countChangedDataKeys(data, initialData);
10716
+ const previous = instanceSnapshots.get(instance) || moduleSnapshots.get(moduleId);
10717
+ if (!previous || changedKeys >= previous.changedKeys) {
10718
+ const snapshot = { changedKeys, data, moduleId };
10719
+ instanceSnapshots.set(instance, snapshot);
10720
+ moduleSnapshots.set(moduleId, snapshot);
10721
+ }
10722
+ }
10723
+ function trackInstance(instance, moduleId) {
10724
+ getInstances(moduleId).add(instance);
10725
+ if (instanceSnapshots.has(instance)) return;
10726
+ const snapshot = moduleSnapshots.get(moduleId);
10727
+ if (snapshot) {
10728
+ instanceSnapshots.set(instance, snapshot);
10729
+ restoreInstanceState(instance, moduleId);
10730
+ } else {
10731
+ rememberInstanceState(instance, moduleId);
10732
+ }
10733
+ }
10734
+ function forgetInstance(instance, moduleId) {
10735
+ getInstances(moduleId).delete(instance);
10736
+ instanceSnapshots.delete(instance);
10737
+ if (!suppressLifecycles) moduleSnapshots.delete(moduleId);
10738
+ }
10739
+ function restoreInstanceState(instance, moduleId) {
10740
+ const snapshot = instanceSnapshots.get(instance);
10741
+ if (!snapshot || snapshot.moduleId !== moduleId) return;
10742
+ const data = cloneInstanceData(snapshot.data);
10743
+ if (instance.data && typeof instance.data === 'object') Object.assign(instance.data, data);
10744
+ if (typeof instance.setData === 'function') instance.setData(data);
10745
+ }
10746
+ function rememberTrackedInstances() {
10747
+ for (const [moduleId, values] of instances) {
10748
+ for (const instance of values) rememberInstanceState(instance, moduleId);
10749
+ }
10750
+ }
10751
+ function restoreTrackedInstances() {
10752
+ for (const [moduleId, values] of instances) {
10753
+ for (const instance of values) restoreInstanceState(instance, moduleId);
10754
+ }
10755
+ }
10567
10756
  function refreshWevuInstance(instance, moduleId) {
10568
10757
  if (!instance || (typeof instance !== 'object' && typeof instance !== 'function')) return;
10569
10758
  const generation = wevuRefreshGenerations.get(moduleId) || 0;
@@ -10572,7 +10761,10 @@ function refreshWevuInstance(instance, moduleId) {
10572
10761
  if (generations?.get(moduleId) === generation) return;
10573
10762
  const refresh = wevuRefreshes.get(moduleId);
10574
10763
  if (typeof refresh !== 'function') return;
10575
- refresh(instance);
10764
+ restoreInstanceState(instance, moduleId);
10765
+ const snapshot = instanceSnapshots.get(instance) || moduleSnapshots.get(moduleId);
10766
+ refresh(instance, cloneInstanceData(snapshot?.data));
10767
+ rememberInstanceState(instance, moduleId);
10576
10768
  if (!generations) wevuInstanceGenerations.set(instance, generations = new Map());
10577
10769
  generations.set(moduleId, generation);
10578
10770
  }
@@ -10583,10 +10775,15 @@ function proxyFunction(moduleId, path, fallback) {
10583
10775
  const segments = path.split('.');
10584
10776
  let value = definition;
10585
10777
  for (const segment of segments) value = value && value[segment];
10586
- return (typeof value === 'function' ? value : fallback)?.apply(this, args);
10778
+ trackInstance(this, moduleId);
10779
+ try {
10780
+ return (typeof value === 'function' ? value : fallback)?.apply(this, args);
10781
+ } finally {
10782
+ rememberInstanceState(this, moduleId);
10783
+ }
10587
10784
  };
10588
10785
  }
10589
- function decorateObject(value, moduleId, prefix = '') {
10786
+ function decorateObject(value, moduleId, prefix = '', trackLifecycle = false) {
10590
10787
  if (!value || typeof value !== 'object' || Array.isArray(value)) return value;
10591
10788
  const result = { ...value };
10592
10789
  for (const [key, child] of Object.entries(value)) {
@@ -10599,24 +10796,28 @@ function decorateObject(value, moduleId, prefix = '') {
10599
10796
  if (!prefix && typeof value.onLoad === 'function') {
10600
10797
  const onLoad = result.onLoad;
10601
10798
  result.onLoad = function (...args) {
10602
- getInstances(moduleId).add(this);
10799
+ trackInstance(this, moduleId);
10603
10800
  return onLoad.apply(this, args);
10604
10801
  };
10605
10802
  }
10606
- if (!prefix && result.lifetimes && typeof result.lifetimes === 'object') {
10607
- const attached = result.lifetimes.attached;
10608
- const detached = result.lifetimes.detached;
10609
- result.lifetimes = { ...result.lifetimes };
10610
- if (typeof attached === 'function') {
10803
+ if (!prefix && (trackLifecycle || (result.lifetimes && typeof result.lifetimes === 'object'))) {
10804
+ const lifetimes = { ...(result.lifetimes || {}) };
10805
+ const attached = lifetimes.attached;
10806
+ const detached = lifetimes.detached;
10807
+ result.lifetimes = lifetimes;
10808
+ if (trackLifecycle || typeof attached === 'function') {
10611
10809
  result.lifetimes.attached = function (...args) {
10612
- getInstances(moduleId).add(this);
10613
- return attached.apply(this, args);
10810
+ trackInstance(this, moduleId);
10811
+ return attached?.apply(this, args);
10614
10812
  };
10615
10813
  }
10616
- if (typeof detached === 'function') {
10814
+ if (trackLifecycle || typeof detached === 'function') {
10617
10815
  result.lifetimes.detached = function (...args) {
10618
- getInstances(moduleId).delete(this);
10619
- return detached.apply(this, args);
10816
+ try {
10817
+ return detached?.apply(this, args);
10818
+ } finally {
10819
+ forgetInstance(this, moduleId);
10820
+ }
10620
10821
  };
10621
10822
  }
10622
10823
  }
@@ -10628,9 +10829,13 @@ function decorateWevuComponent(definition, moduleId) {
10628
10829
  for (const [name, method] of Object.entries(methods)) {
10629
10830
  if (typeof method !== 'function') continue;
10630
10831
  methods[name] = function (...args) {
10631
- getInstances(moduleId).add(this);
10832
+ trackInstance(this, moduleId);
10632
10833
  refreshWevuInstance(this, moduleId);
10633
- return method.apply(this, args);
10834
+ try {
10835
+ return method.apply(this, args);
10836
+ } finally {
10837
+ rememberInstanceState(this, moduleId);
10838
+ }
10634
10839
  };
10635
10840
  }
10636
10841
  result.methods = methods;
@@ -10638,26 +10843,38 @@ function decorateWevuComponent(definition, moduleId) {
10638
10843
  const onUnload = definition.onUnload;
10639
10844
  if (typeof onLoad === 'function') {
10640
10845
  result.onLoad = function (...args) {
10641
- getInstances(moduleId).add(this);
10846
+ trackInstance(this, moduleId);
10847
+ refreshWevuInstance(this, moduleId);
10848
+ if (suppressLifecycles) return;
10642
10849
  return onLoad.apply(this, args);
10643
10850
  };
10644
10851
  }
10645
10852
  if (typeof onUnload === 'function') {
10646
10853
  result.onUnload = function (...args) {
10647
- getInstances(moduleId).delete(this);
10648
- return onUnload.apply(this, args);
10854
+ if (suppressLifecycles) return;
10855
+ try {
10856
+ return onUnload.apply(this, args);
10857
+ } finally {
10858
+ forgetInstance(this, moduleId);
10859
+ }
10649
10860
  };
10650
10861
  }
10651
10862
  const lifetimes = { ...(definition.lifetimes || {}) };
10652
10863
  const attached = lifetimes.attached;
10653
10864
  const detached = lifetimes.detached;
10654
10865
  lifetimes.attached = function (...args) {
10655
- getInstances(moduleId).add(this);
10866
+ trackInstance(this, moduleId);
10867
+ refreshWevuInstance(this, moduleId);
10868
+ if (suppressLifecycles) return;
10656
10869
  return attached?.apply(this, args);
10657
10870
  };
10658
10871
  lifetimes.detached = function (...args) {
10659
- getInstances(moduleId).delete(this);
10660
- return detached?.apply(this, args);
10872
+ if (suppressLifecycles) return;
10873
+ try {
10874
+ return detached?.apply(this, args);
10875
+ } finally {
10876
+ forgetInstance(this, moduleId);
10877
+ }
10661
10878
  };
10662
10879
  return { ...result, lifetimes };
10663
10880
  }
@@ -10671,7 +10888,7 @@ function registerDefinition(name, definition, nativeRegistration) {
10671
10888
  if (name === 'Component') {
10672
10889
  let pending = pendingNativeDefinitions.get(name);
10673
10890
  if (!pending) pendingNativeDefinitions.set(name, pending = []);
10674
- pending.push(decorateObject(definition, moduleId));
10891
+ pending.push(decorateObject(definition, moduleId, '', true));
10675
10892
  registered.add(moduleId);
10676
10893
  return;
10677
10894
  }
@@ -10695,15 +10912,14 @@ globalThis[bridgeKey] = {
10695
10912
  isApplying() { return runtime.applyingPatch; },
10696
10913
  trackWevuComponent(definition, refresh) {
10697
10914
  const moduleId = runtime.registrationModuleId || runtime.currentModuleId || 'Component';
10698
- if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) return definition;
10915
+ if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) {
10916
+ return decorateWevuComponent(definition, moduleId);
10917
+ }
10699
10918
  definitions.set(moduleId, definition);
10700
10919
  if (typeof refresh === 'function') wevuRefreshes.set(moduleId, refresh);
10701
10920
  if (runtime.applyingPatch) {
10702
10921
  wevuRefreshGenerations.set(moduleId, (wevuRefreshGenerations.get(moduleId) || 0) + 1);
10703
- const currentRefresh = wevuRefreshes.get(moduleId);
10704
- if (typeof currentRefresh === 'function') {
10705
- for (const instance of [...getInstances(moduleId)]) currentRefresh(instance);
10706
- }
10922
+ for (const instance of [...getInstances(moduleId)]) refreshWevuInstance(instance, moduleId);
10707
10923
  return definition;
10708
10924
  }
10709
10925
  return decorateWevuComponent(definition, moduleId);
@@ -10711,10 +10927,12 @@ globalThis[bridgeKey] = {
10711
10927
  ready: true,
10712
10928
  beginUpdate() {
10713
10929
  suppressLifecycles = true;
10930
+ rememberTrackedInstances();
10714
10931
  runtime.beginPatch();
10715
10932
  },
10716
10933
  endUpdate() {
10717
10934
  runtime.endPatch();
10935
+ restoreTrackedInstances();
10718
10936
  setTimeout(() => { suppressLifecycles = false; });
10719
10937
  }
10720
10938
  };
@@ -11980,12 +12198,37 @@ const TEMPLATE_COMPONENT_TAG_HINT_RE = /<\s*(?:[A-Z_$]|[a-z][\w$]*-)/;
11980
12198
  function hasTemplateComponentTagHint(source) {
11981
12199
  return TEMPLATE_COMPONENT_TAG_HINT_RE.test(source);
11982
12200
  }
11983
- function collectVueTemplateComponentNames(template, filename) {
11984
- return collectVueTemplateTags(template, {
12201
+ function kebabToCamel(name) {
12202
+ return name.replace(/-([a-z0-9])/g, (_, character) => character.toUpperCase());
12203
+ }
12204
+ function capitalize(name) {
12205
+ return name ? `${name.charAt(0).toUpperCase()}${name.slice(1)}` : name;
12206
+ }
12207
+ function collectVueTemplateComponentTagInfo(template, filename) {
12208
+ const templateTags = collectVueTemplateTags(template, {
11985
12209
  filename,
11986
12210
  warnLabel: "自动 usingComponents",
11987
- shouldCollect: (tag) => VUE_COMPONENT_TAG_RE.test(tag)
12211
+ shouldCollect: (tag) => VUE_COMPONENT_TAG_RE.test(tag) || isAutoImportCandidateTag(tag)
11988
12212
  });
12213
+ const componentNames = /* @__PURE__ */ new Set();
12214
+ const tagsByComponentName = /* @__PURE__ */ new Map();
12215
+ for (const tag of templateTags) {
12216
+ const camelName = kebabToCamel(tag);
12217
+ for (const componentName of [
12218
+ tag,
12219
+ camelName,
12220
+ capitalize(camelName)
12221
+ ]) {
12222
+ componentNames.add(componentName);
12223
+ const matchedTags = tagsByComponentName.get(componentName) ?? /* @__PURE__ */ new Set();
12224
+ matchedTags.add(tag);
12225
+ tagsByComponentName.set(componentName, matchedTags);
12226
+ }
12227
+ }
12228
+ return {
12229
+ componentNames,
12230
+ tagsByComponentName
12231
+ };
11989
12232
  }
11990
12233
  function collectVueTemplateAutoImportTags(template, filename) {
11991
12234
  return collectVueTemplateTags(template, {
@@ -12016,7 +12259,8 @@ async function applyScriptSetupUsingComponents(options) {
12016
12259
  }
12017
12260
  }
12018
12261
  if (!errors?.length && descriptor?.scriptSetup && descriptor?.template) {
12019
- const templateComponentNames = collectVueTemplateComponentNames(descriptor.template.content, vueEntryPath);
12262
+ const templateComponentTagInfo = collectVueTemplateComponentTagInfo(descriptor.template.content, vueEntryPath);
12263
+ const templateComponentNames = templateComponentTagInfo.componentNames;
12020
12264
  if (templateComponentNames.size) {
12021
12265
  const astEngine = resolveAstEngine(configService.weappViteConfig);
12022
12266
  const imports = collectScriptSetupImports(descriptor.scriptSetup.content, templateComponentNames, { astEngine });
@@ -12033,15 +12277,18 @@ async function applyScriptSetupUsingComponents(options) {
12033
12277
  localName,
12034
12278
  importSource,
12035
12279
  resolvedId,
12036
- from: resolvedFrom
12280
+ from: resolvedFrom,
12281
+ templateTags: [...templateComponentTagInfo.tagsByComponentName.get(localName) ?? [localName]]
12037
12282
  };
12038
12283
  }));
12039
- for (const { localName, importSource, resolvedId, from: resolvedFrom } of resolvedImports) {
12284
+ for (const { importSource, resolvedId, from: resolvedFrom, templateTags } of resolvedImports) {
12040
12285
  let from = resolvedFrom;
12041
12286
  if (!from && importSource.startsWith("/")) from = removeExtensionDeep(importSource);
12042
12287
  if (!from) continue;
12043
- if (Reflect.has(usingComponents, localName) && usingComponents[localName] !== from) logger_default.warn(`[自动 usingComponents] 冲突:${vueEntryPath} 中 usingComponents['${localName}']='${usingComponents[localName]}' 将被 <script setup> 导入覆盖为 '${from}'`);
12044
- usingComponents[localName] = from;
12288
+ for (const tag of templateTags) {
12289
+ if (Reflect.has(usingComponents, tag) && usingComponents[tag] !== from) logger_default.warn(`[自动 usingComponents] 冲突:${vueEntryPath} 中 usingComponents['${tag}']='${usingComponents[tag]}' 将被 <script setup> 导入覆盖为 '${from}'`);
12290
+ usingComponents[tag] = from;
12291
+ }
12045
12292
  if (resolvedId) externalComponentEntryMap?.set(removeExtensionDeep(from).replace(/^\/+/, ""), resolvedId);
12046
12293
  }
12047
12294
  json.usingComponents = usingComponents;
@@ -13070,11 +13317,18 @@ async function createManagedTsconfigFiles(ctx) {
13070
13317
  const appPath = path.join(managedDir, "tsconfig.app.json");
13071
13318
  const nodePath = path.join(managedDir, "tsconfig.node.json");
13072
13319
  const serverPath = path.join(managedDir, "tsconfig.server.json");
13320
+ const sharedEmptyPath = path.join(managedDir, "tsconfig.shared.empty.d.ts");
13321
+ const uniAppTypesPath = path.join(managedDir, "uni-app.d.ts");
13322
+ const uniAppEnabled = Boolean(ctx.configService?.weappViteConfig.uniApp);
13073
13323
  return [
13074
13324
  {
13075
- path: path.join(managedDir, "tsconfig.shared.empty.d.ts"),
13325
+ path: sharedEmptyPath,
13076
13326
  content: "export {}\n"
13077
13327
  },
13328
+ {
13329
+ path: uniAppTypesPath,
13330
+ content: uniAppEnabled ? "export {}\n\ndeclare global {\n const uni: typeof wx\n}\n" : "export {}\n"
13331
+ },
13078
13332
  {
13079
13333
  path: sharedPath,
13080
13334
  content: toJson(createSharedTsconfig(ctx, legacyConfig))
@@ -14963,7 +15217,15 @@ function createOxcRuntimeSupport() {
14963
15217
  //#endregion
14964
15218
  //#region src/runtime/packageAliases.ts
14965
15219
  const WEVU_WORKSPACE_PACKAGE_PATH = "packages-runtime/wevu";
15220
+ const SHARED_WORKSPACE_PACKAGE_PATH = "@weapp-core/shared";
15221
+ const PACKAGE_ALIAS_MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
14966
15222
  const PACKAGE_ALIASES = [
15223
+ {
15224
+ find: "@weapp-core/shared/platforms",
15225
+ packageName: "@weapp-core/shared",
15226
+ distEntry: "dist/platforms/index.js",
15227
+ fallbackWorkspacePackagePath: SHARED_WORKSPACE_PACKAGE_PATH
15228
+ },
14967
15229
  {
14968
15230
  find: "class-variance-authority",
14969
15231
  packageName: "class-variance-authority",
@@ -14988,7 +15250,6 @@ const PACKAGE_ALIASES = [
14988
15250
  packageName: "wevu",
14989
15251
  distEntry: "dist/internal-runtime.mjs",
14990
15252
  devDistEntry: "dist/dev/internal-runtime.mjs",
14991
- devWorkspaceEntry: "src/internal-runtime.ts",
14992
15253
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
14993
15254
  },
14994
15255
  {
@@ -14996,7 +15257,6 @@ const PACKAGE_ALIASES = [
14996
15257
  packageName: "wevu",
14997
15258
  distEntry: "dist/internal-reactivity.mjs",
14998
15259
  devDistEntry: "dist/dev/internal-reactivity.mjs",
14999
- devWorkspaceEntry: "src/internal-reactivity.ts",
15000
15260
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
15001
15261
  },
15002
15262
  {
@@ -15004,7 +15264,6 @@ const PACKAGE_ALIASES = [
15004
15264
  packageName: "wevu",
15005
15265
  distEntry: "dist/internal-template.mjs",
15006
15266
  devDistEntry: "dist/dev/internal-template.mjs",
15007
- devWorkspaceEntry: "src/internal-template.ts",
15008
15267
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
15009
15268
  },
15010
15269
  {
@@ -15060,7 +15319,7 @@ const PACKAGE_ALIASES = [
15060
15319
  function resolveWevuRuntimeDistEntries(target, options) {
15061
15320
  if (!target.devDistEntry || target.packageName !== "wevu") return [target.distEntry];
15062
15321
  const mode = options.wevuRuntime ?? "auto";
15063
- if (mode === "dev" || mode === "auto" && options.isDev) return [target.devWorkspaceEntry, target.devDistEntry].filter((entry) => Boolean(entry));
15322
+ if (mode === "dev" || mode === "auto" && options.isDev) return [target.devDistEntry];
15064
15323
  return [target.distEntry];
15065
15324
  }
15066
15325
  function resolveRepoRoot(fromDir) {
@@ -15072,25 +15331,28 @@ function resolveRepoRoot(fromDir) {
15072
15331
  currentDir = parentDir;
15073
15332
  }
15074
15333
  }
15075
- function resolvePackageEntry(packageName, distEntries, fallbackWorkspacePackagePath) {
15076
- const packageInfo = safeGetPackageInfoSync(packageName);
15334
+ function resolvePackageEntry(packageName, distEntries, fallbackWorkspacePackagePath, cwd) {
15335
+ const packageInfo = safeGetPackageInfoSync(packageName, cwd ? { paths: [cwd] } : void 0);
15077
15336
  if (packageInfo) for (const distEntry of distEntries) {
15078
15337
  const resolvedEntry = path.resolve(packageInfo.rootPath, distEntry);
15079
15338
  if (existsSync(resolvedEntry)) return resolvedEntry;
15080
15339
  }
15081
15340
  if (!fallbackWorkspacePackagePath) return;
15082
- const repoRoot = resolveRepoRoot(path.dirname(fileURLToPath(import.meta.url)));
15083
- if (!repoRoot) return;
15084
- for (const distEntry of distEntries) {
15085
- const fallbackEntry = path.resolve(repoRoot, fallbackWorkspacePackagePath, distEntry);
15086
- if (existsSync(fallbackEntry)) return fallbackEntry;
15341
+ const fallbackRoots = new Set([cwd, PACKAGE_ALIAS_MODULE_DIR].filter((value) => Boolean(value)));
15342
+ for (const fromDir of fallbackRoots) {
15343
+ const repoRoot = resolveRepoRoot(fromDir);
15344
+ if (!repoRoot) continue;
15345
+ for (const distEntry of distEntries) {
15346
+ const fallbackEntry = path.resolve(repoRoot, fallbackWorkspacePackagePath, distEntry);
15347
+ if (existsSync(fallbackEntry)) return fallbackEntry;
15348
+ }
15087
15349
  }
15088
15350
  }
15089
15351
  function resolveBuiltinPackageAliases(options = {}) {
15090
15352
  const aliases = [];
15091
15353
  for (const target of PACKAGE_ALIASES) {
15092
15354
  const { find, packageName, fallbackWorkspacePackagePath } = target;
15093
- const resolvedEntry = resolvePackageEntry(packageName, resolveWevuRuntimeDistEntries(target, options), fallbackWorkspacePackagePath);
15355
+ const resolvedEntry = resolvePackageEntry(packageName, resolveWevuRuntimeDistEntries(target, options), fallbackWorkspacePackagePath, options.cwd);
15094
15356
  if (!resolvedEntry) continue;
15095
15357
  aliases.push({
15096
15358
  find,
@@ -15171,7 +15433,8 @@ function normalizeOutDir(root, config) {
15171
15433
  return path.resolve(root, config.outDir);
15172
15434
  }
15173
15435
  function resolveWeappWebConfig(options) {
15174
- const { cwd, srcRoot, config } = options;
15436
+ const { cwd, srcRoot, enableByCli } = options;
15437
+ const config = options.config ?? (enableByCli ? {} : void 0);
15175
15438
  if (!config) return;
15176
15439
  if (!(config.enable !== false)) return;
15177
15440
  const root = config.root ? path.resolve(cwd, config.root) : cwd;
@@ -15300,7 +15563,7 @@ var PlatformBackendRegistry = class {
15300
15563
  label: "config",
15301
15564
  raw
15302
15565
  });
15303
- const targetKey = normalized ?? "";
15566
+ const targetKey = normalized;
15304
15567
  if (RESERVED_COMBINED_TARGETS.has(targetKey)) return createExecution(this.backends.map((backend) => ({
15305
15568
  descriptor: backend.descriptor,
15306
15569
  driver: backend.driver,
@@ -15693,14 +15956,14 @@ function configureBuildAndPlugins(options) {
15693
15956
  const arr = raw == null ? [] : Array.isArray(raw) ? [...raw] : [raw];
15694
15957
  rd.plugins = arr.includes(oxcRolldownPlugin) ? arr : [oxcRolldownPlugin, ...arr];
15695
15958
  }
15696
- injectBuiltinAliases(config);
15959
+ const { normalizedCliPlatform, isWebRuntime } = resolveCliPlatformRuntime(cliPlatform);
15960
+ injectBuiltinAliases(config, isWebRuntime ? "build" : void 0);
15697
15961
  if (oxcVitePlugin) {
15698
15962
  config.plugins ??= [];
15699
15963
  config.plugins.unshift(oxcVitePlugin);
15700
15964
  }
15701
15965
  const platform = config.weapp?.platform ?? DEFAULT_MP_PLATFORM;
15702
15966
  const multiPlatform = resolveMultiPlatformConfig(config.weapp?.multiPlatform);
15703
- const { normalizedCliPlatform, isWebRuntime } = resolveCliPlatformRuntime(cliPlatform);
15704
15967
  if (multiPlatform.enabled && !isWebRuntime && !normalizedCliPlatform) throw new Error("已开启 weapp.multiPlatform,请通过 --platform 指定目标小程序平台,例如:weapp-vite dev -p weapp");
15705
15968
  if (multiPlatform.enabled && !isWebRuntime && !supportsMultiPlatformTarget(multiPlatform, platform)) throw new Error(`当前平台 "${platform}" 不在 weapp.multiPlatform.targets 配置中,可选平台:${multiPlatform.targets.join(", ")}`);
15706
15969
  if (multiPlatform.enabled && !isWebRuntime && projectConfigPath) {
@@ -15958,7 +16221,7 @@ async function loadConfigFileWithFallback(configEnv, configFile, cwd, configLoad
15958
16221
  function createLoadConfig(options) {
15959
16222
  const { injectBuiltinAliases, oxcRolldownPlugin, oxcVitePlugin } = options;
15960
16223
  return async function loadConfig(opts) {
15961
- const { cwd, isDev, mode, pluginOnly = false, inlineConfig, configFile, configLoader = "runner", cliPlatform, projectConfigPath } = opts;
16224
+ const { cwd, isDev, mode, outputRoot, pluginOnly = false, inlineConfig, configFile, configLoader = "runner", cliPlatform, projectConfigPath } = opts;
15962
16225
  const { packageJson, packageJsonPath } = await loadPackageJson(cwd);
15963
16226
  const resolvedConfigFile = resolveConfigFilePath(cwd, configFile);
15964
16227
  const weappConfigFilePath = await resolveWeappConfigFile({
@@ -16069,7 +16332,8 @@ function createLoadConfig(options) {
16069
16332
  const resolvedWebConfig = resolveWeappWebConfig({
16070
16333
  cwd,
16071
16334
  srcRoot,
16072
- config: config.weapp?.web
16335
+ config: config.weapp?.web,
16336
+ enableByCli: resolveCliPlatformRuntime(cliPlatform).isWebRuntime
16073
16337
  });
16074
16338
  const { buildConfig, platform, multiPlatform, isWebRuntime } = configureBuildAndPlugins({
16075
16339
  config,
@@ -16108,7 +16372,10 @@ function createLoadConfig(options) {
16108
16372
  const normalizedDistRoot = normalizeRelativeDistRoot(mpDistRoot);
16109
16373
  if (normalizedDistRoot === "dist") mpDistRoot = path.join("dist", platform, normalizedDistRoot);
16110
16374
  }
16111
- buildConfig.outDir ??= mpDistRoot;
16375
+ if (outputRoot) {
16376
+ mpDistRoot = outputRoot;
16377
+ buildConfig.outDir = outputRoot;
16378
+ } else buildConfig.outDir ??= mpDistRoot;
16112
16379
  projectConfigPathResolved = path.resolve(cwd, basePath ?? getProjectConfigFileName(platform));
16113
16380
  projectPrivateConfigPathResolved = path.resolve(cwd, privatePath ?? getProjectPrivateConfigFileName(platform));
16114
16381
  } else if (isLibMode) {
@@ -16401,7 +16668,7 @@ async function transformJsModuleToCjs(source, options) {
16401
16668
  }
16402
16669
  if (!transformed) return source;
16403
16670
  if (options?.markEsModule && hasConvertedExport) ast.program.body.unshift(createEsModuleMarker());
16404
- return generate(ast).code;
16671
+ return generate$1(ast).code;
16405
16672
  } catch {
16406
16673
  return source;
16407
16674
  }
@@ -17109,10 +17376,20 @@ const webRuntimeProvider = {
17109
17376
  backend: "web",
17110
17377
  compilation: "web",
17111
17378
  injection: "virtual-module",
17112
- entries: Object.freeze({ runtime: Object.freeze({
17113
- development: "@weapp-vite/web/runtime",
17114
- production: "@weapp-vite/web/runtime"
17115
- }) }),
17379
+ entries: Object.freeze({
17380
+ runtime: Object.freeze({
17381
+ development: "@weapp-vite/web/runtime",
17382
+ production: "@weapp-vite/web/runtime"
17383
+ }),
17384
+ reactivity: Object.freeze({
17385
+ development: "wevu/internal-reactivity",
17386
+ production: "wevu/internal-reactivity"
17387
+ }),
17388
+ template: Object.freeze({
17389
+ development: "wevu/internal-template",
17390
+ production: "wevu/internal-template"
17391
+ })
17392
+ }),
17116
17393
  capabilities: Object.freeze({
17117
17394
  framework: false,
17118
17395
  hmr: true,
@@ -17126,12 +17403,14 @@ const webRuntimeProvider = {
17126
17403
  contractVersion: WEAPP_VITE_RUNTIME_CONTRACT_VERSION
17127
17404
  },
17128
17405
  resolveModuleId(entry) {
17406
+ if (entry.kind !== "runtime") return entry.moduleId;
17129
17407
  return fileURLToPath(import.meta.resolve(entry.moduleId));
17130
17408
  }
17131
17409
  };
17132
17410
  //#endregion
17133
17411
  //#region src/runtimeProviders/plugin.ts
17134
17412
  const runtimeKindByVirtualId = new Map(Object.entries(WEAPP_VITE_RUNTIME_VIRTUAL_IDS).map(([kind, id]) => [id, kind]));
17413
+ const WEB_RUNTIME_COMPAT_ENTRY = "weapp-vite/runtime";
17135
17414
  function resolveRuntimeProviderEntry(provider, kind, variant) {
17136
17415
  const { descriptor } = provider;
17137
17416
  if (descriptor.contractVersion !== WEAPP_VITE_RUNTIME_CONTRACT_VERSION) throw new Error(`运行时 provider "${descriptor.id}" 的 contract version 为 ${descriptor.contractVersion},当前编译器要求 ${WEAPP_VITE_RUNTIME_CONTRACT_VERSION}。`);
@@ -17154,7 +17433,7 @@ function createRuntimeProviderPlugin(provider, variant) {
17154
17433
  name: `weapp-vite:runtime-provider:${provider.descriptor.id}`,
17155
17434
  enforce: "pre",
17156
17435
  async resolveId(id, importer) {
17157
- const kind = runtimeKindByVirtualId.get(id);
17436
+ const kind = runtimeKindByVirtualId.get(id) ?? (provider.descriptor.backend === "web" && id === WEB_RUNTIME_COMPAT_ENTRY ? "runtime" : void 0);
17158
17437
  if (!kind) return null;
17159
17438
  const entry = resolveRuntimeProviderEntry(provider, kind, variant);
17160
17439
  let moduleId = entry.moduleId;
@@ -17781,7 +18060,7 @@ function isKnownWevuComponentCallee(callee) {
17781
18060
  * 通过轻量字符串特征快速判断脚本是否可能需要注入 setData.pick。
17782
18061
  */
17783
18062
  function mayNeedInjectSetDataPickInJs(source) {
17784
- return source.includes("createWevuComponent") || source.includes("defineComponent") || source.includes("__wevu_isPage") || source.includes(".so(");
18063
+ return source.includes("createWevuComponent") || source.includes("defineComponent") || source.includes("__wevu_isPage") || source.includes(".so(") || source.includes("export default");
17785
18064
  }
17786
18065
  /**
17787
18066
  * 判断脚本 setup 阶段是否会读取编译期 slot 名元数据。
@@ -18056,12 +18335,20 @@ function transformTargetWevuOptionsInJs(source, transformOptions, options) {
18056
18335
  };
18057
18336
  const ast = parseJsLike(source);
18058
18337
  const candidateOptions = /* @__PURE__ */ new Set();
18059
- traverse(ast, { CallExpression(path) {
18060
- const firstArg = path.node.arguments[0];
18061
- if (!firstArg || firstArg.type === "SpreadElement") return;
18062
- const resolvedOptions = t.isExpression(firstArg) ? resolveOptionsObjectExpression(firstArg, path.scope) : null;
18063
- if (resolvedOptions && (isKnownWevuComponentCallee(path.node.callee) || hasCompiledWevuOptionsMarker(resolvedOptions))) candidateOptions.add(resolvedOptions);
18064
- } });
18338
+ traverse(ast, {
18339
+ CallExpression(path) {
18340
+ const firstArg = path.node.arguments[0];
18341
+ if (!firstArg || firstArg.type === "SpreadElement") return;
18342
+ const resolvedOptions = t.isExpression(firstArg) ? resolveOptionsObjectExpression(firstArg, path.scope) : null;
18343
+ if (resolvedOptions && (isKnownWevuComponentCallee(path.node.callee) || hasCompiledWevuOptionsMarker(resolvedOptions))) candidateOptions.add(resolvedOptions);
18344
+ },
18345
+ ExportDefaultDeclaration(path) {
18346
+ const declaration = path.node.declaration;
18347
+ if (!t.isExpression(declaration)) return;
18348
+ const resolvedOptions = resolveOptionsObjectExpression(declaration, path.scope);
18349
+ if (resolvedOptions) candidateOptions.add(resolvedOptions);
18350
+ }
18351
+ });
18065
18352
  if (!candidateOptions.size) return {
18066
18353
  code: source,
18067
18354
  transformed: false
@@ -18073,7 +18360,7 @@ function transformTargetWevuOptionsInJs(source, transformOptions, options) {
18073
18360
  transformed: false
18074
18361
  };
18075
18362
  const sourceMap = options?.sourceMap !== false;
18076
- const generated = generate(ast, {
18363
+ const generated = generate$1(ast, {
18077
18364
  retainLines: true,
18078
18365
  sourceMaps: sourceMap,
18079
18366
  sourceFileName: "inline.js"
@@ -19365,7 +19652,7 @@ function injectLayoutBindingComputed(script, props) {
19365
19652
  else if (t.isObjectExpression(computedProp.value)) computedProp.value.properties.push(...computedEntries);
19366
19653
  else if (t.isIdentifier(computedProp.value) || t.isMemberExpression(computedProp.value)) computedProp.value = t.objectExpression([...computedEntries, t.spreadElement(t.cloneNode(computedProp.value, true))]);
19367
19654
  else return script;
19368
- return generate(ast, { retainLines: true }).code;
19655
+ return generate$1(ast, { retainLines: true }).code;
19369
19656
  }
19370
19657
  //#endregion
19371
19658
  //#region src/plugins/vue/transform/pageLayout/apply/native.ts
@@ -19427,12 +19714,12 @@ function injectNativePageLayoutRuntime(script, filename, plan) {
19427
19714
  const strippedMeta = stripDefinePageMetaCalls(ast);
19428
19715
  const shouldInjectSetter = Boolean(plan?.dynamicSwitch);
19429
19716
  if (!shouldInjectSetter && !strippedMeta) return script;
19430
- if (!shouldInjectSetter) return generate(ast, { retainLines: true }).code;
19717
+ if (!shouldInjectSetter) return generate$1(ast, { retainLines: true }).code;
19431
19718
  const pageOptions = findNativePageOptionsObject(ast);
19432
19719
  if (!pageOptions) throw new Error(`${filename} 中未找到可注入 layout 运行时的 Page({}) 定义。`);
19433
19720
  injectNativePageLayoutState(pageOptions, plan?.currentLayout);
19434
19721
  injectNativePageLayoutSetter(pageOptions);
19435
- return generate(ast, { retainLines: true }).code;
19722
+ return generate$1(ast, { retainLines: true }).code;
19436
19723
  }
19437
19724
  //#endregion
19438
19725
  //#region src/plugins/vue/transform/pageLayout/apply/index.ts
@@ -19492,7 +19779,7 @@ function extractStaticLayoutPropValue(node, filename, keyName) {
19492
19779
  if (t.isNumericLiteral(normalized)) return normalized.value;
19493
19780
  if (t.isBooleanLiteral(normalized)) return normalized.value;
19494
19781
  if (t.isNullLiteral(normalized)) return null;
19495
- const expression = generate(normalized, { compact: true }).code;
19782
+ const expression = generate$1(normalized, { compact: true }).code;
19496
19783
  if (!expression) throw new Error(`${filename} 中 definePageMeta().layout.props.${keyName} 无法解析为表达式。`);
19497
19784
  return {
19498
19785
  kind: "expression",
@@ -20977,6 +21264,28 @@ function createEntryLoader(options) {
20977
21264
  const templateEntryPathCache = /* @__PURE__ */ new Map();
20978
21265
  const styleImportsCache = /* @__PURE__ */ new Map();
20979
21266
  let resolveCacheVersion = 0;
21267
+ async function materializeVueAutoImportEntries(pluginCtx, importer, json, injectedEntries) {
21268
+ const usingComponents = get(json, "usingComponents");
21269
+ if (!isObject(usingComponents) || !injectedEntries.length) {
21270
+ if (!isObject(usingComponents) || !configService.weappViteConfig?.uniApp) return injectedEntries;
21271
+ }
21272
+ const candidateEntries = Array.from(/* @__PURE__ */ new Set([...injectedEntries, ...Object.values(usingComponents).filter((entry) => typeof entry === "string" && entry.endsWith(".vue"))]));
21273
+ const rewritten = /* @__PURE__ */ new Map();
21274
+ for (const entry of candidateEntries) {
21275
+ const resolved = await pluginCtx.resolve(entry, importer);
21276
+ const resolvedId = resolved?.id ? normalizeFsResolvedId(resolved.id) : void 0;
21277
+ if (!resolvedId?.endsWith(".vue")) {
21278
+ if (configService.weappViteConfig?.uniApp && entry.endsWith(".vue")) throw new Error(`[uni-app] 无法解析外部 Vue 组件: importer=${importer} request=${entry}`);
21279
+ continue;
21280
+ }
21281
+ const outputPath = usingComponentFromResolvedFile(resolvedId, configService);
21282
+ if (!outputPath) throw new Error(`[uni-app] 无法生成外部 Vue 组件输出路径: importer=${importer} resolvedId=${resolvedId}`);
21283
+ for (const [name, value] of Object.entries(usingComponents)) if (value === entry) usingComponents[name] = outputPath;
21284
+ ctx.runtimeState.build.hmr.externalComponentEntryMap.set(removeExtensionDeep(outputPath).replace(/^\/+/, ""), resolvedId);
21285
+ rewritten.set(entry, outputPath);
21286
+ }
21287
+ return Array.from(/* @__PURE__ */ new Set([...injectedEntries.map((entry) => rewritten.get(entry) ?? entry), ...candidateEntries.map((entry) => rewritten.get(entry) ?? entry)]));
21288
+ }
20980
21289
  const shouldEmitScriptlessVueLayoutJs$1 = async (layoutFile) => {
20981
21290
  const cached = scriptlessVueLayoutDecisionCache.get(layoutFile);
20982
21291
  if (cached) return await cached;
@@ -21287,7 +21596,8 @@ function createEntryLoader(options) {
21287
21596
  const autoImportStartedAt = performance$1.now();
21288
21597
  try {
21289
21598
  if (ctx.autoImportService?.hasPendingRegistrations?.() !== false) await ctx.autoImportService?.awaitPendingRegistrations?.();
21290
- const injectedAutoImportEntries = await applyAutoImports(baseName, json) ?? [];
21599
+ const rawInjectedAutoImportEntries = await applyAutoImports(baseName, json) ?? [];
21600
+ const injectedAutoImportEntries = await materializeVueAutoImportEntries(this, vueEntryPath ?? id, json, rawInjectedAutoImportEntries);
21291
21601
  const componentEntries = analyzeCommonJson(json);
21292
21602
  const pendingAutoImportMap = ctx.runtimeState?.autoImport?.pendingEntriesByImporter;
21293
21603
  const vueBaseName = vueEntryPath ? removeExtensionDeep(vueEntryPath) : void 0;
@@ -22031,19 +22341,6 @@ const WEVU_INTERNAL_RUNTIME_EXPORTS = [
22031
22341
  "version",
22032
22342
  "waitForLayoutHost"
22033
22343
  ];
22034
- const WEVU_RUNTIME_MODULE_IDS = [
22035
- "wevu",
22036
- "wevu/router",
22037
- "wevu/store",
22038
- "wevu/api",
22039
- "wevu/fetch",
22040
- "wevu/web-apis",
22041
- ...[
22042
- "wevu/internal-runtime",
22043
- "wevu/internal-reactivity",
22044
- "wevu/internal-template"
22045
- ]
22046
- ];
22047
22344
  const WEVU_RUNTIME_MODULE_ID_PATTERN = ["wevu(?:\\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?", ...Object.values(WEAPP_VITE_RUNTIME_VIRTUAL_IDS).map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))].join("|");
22048
22345
  const WEVU_RUNTIME_NAMED_IMPORT_RE = new RegExp(`\\bimport\\s*\\{([^}]*)\\}\\s*from\\s*["'](${WEVU_RUNTIME_MODULE_ID_PATTERN})["'];?`, "g");
22049
22346
  const WEVU_RUNTIME_REQUIRE_RE = new RegExp(`\\brequire\\(\\s*(\`(?:${WEVU_RUNTIME_MODULE_ID_PATTERN})\`|'(?:${WEVU_RUNTIME_MODULE_ID_PATTERN})'|"(?:${WEVU_RUNTIME_MODULE_ID_PATTERN})")\\s*\\)`, "g");
@@ -22262,14 +22559,11 @@ function collectExistingExportNames(code) {
22262
22559
  function collectChunkExportNames(chunk) {
22263
22560
  return collectExistingExportNames(chunk.code);
22264
22561
  }
22265
- function isWevuRuntimeModuleId(value) {
22266
- return WEVU_RUNTIME_MODULE_IDS.includes(value);
22267
- }
22268
22562
  function normalizeWevuRuntimeModuleId(value) {
22269
22563
  if (value === WEAPP_VITE_RUNTIME_VIRTUAL_ID) return "wevu/internal-runtime";
22270
22564
  if (value === WEAPP_VITE_RUNTIME_REACTIVITY_VIRTUAL_ID) return "wevu/internal-reactivity";
22271
22565
  if (value === WEAPP_VITE_RUNTIME_TEMPLATE_VIRTUAL_ID) return "wevu/internal-template";
22272
- return isWevuRuntimeModuleId(value) ? value : void 0;
22566
+ return resolveWevuRuntimeModuleId(value);
22273
22567
  }
22274
22568
  function resolveWevuInternalChunk(bundleOrSnapshot, importNames) {
22275
22569
  const requiredNames = new Set(importNames);
@@ -22288,6 +22582,10 @@ function createWevuRuntimeChunkIndex(bundle, snapshot = createBundleChunkSnapsho
22288
22582
  if (typeof chunk.code !== "string") continue;
22289
22583
  vendorChunks.push(chunk);
22290
22584
  const normalizedFileName = chunk.fileName.replace(/\\/g, "/");
22585
+ const resolvedModuleIds = [chunk.facadeModuleId, ...chunk.moduleIds ?? []].filter((id) => typeof id === "string").map((id) => resolveWevuRuntimeModuleId(id)).filter((id) => Boolean(id));
22586
+ for (const moduleId of resolvedModuleIds) if (!chunksByModuleId.has(moduleId)) chunksByModuleId.set(moduleId, chunk);
22587
+ const stableModuleId = resolveWevuRuntimeModuleIdFromStableVendorFileName(normalizedFileName);
22588
+ if (stableModuleId && !chunksByModuleId.has(stableModuleId)) chunksByModuleId.set(stableModuleId, chunk);
22291
22589
  for (const moduleId of WEVU_RUNTIME_MODULE_IDS) {
22292
22590
  const chunkFileName = moduleId.replace(/\//g, "-");
22293
22591
  if ((moduleId === "wevu" ? normalizedFileName.endsWith(`${chunkFileName}.js`) : normalizedFileName.endsWith(`${chunkFileName}.js`) || normalizedFileName.includes(`/${chunkFileName}-`)) && !chunksByModuleId.has(moduleId)) chunksByModuleId.set(moduleId, chunk);
@@ -22362,12 +22660,20 @@ function resolveRootWevuInternalModuleId(importedName) {
22362
22660
  if (WEVU_INTERNAL_RUNTIME_EXPORT_SET.has(importedName)) return "wevu/internal-runtime";
22363
22661
  }
22364
22662
  function resolveWevuRuntimeChunkForModuleId(index, moduleId, importedNames) {
22365
- return index.chunksByModuleId.get(moduleId) ?? resolveIndexedWevuInternalChunk(index, importedNames);
22663
+ const names = [...importedNames];
22664
+ const exactChunk = index.chunksByModuleId.get(moduleId);
22665
+ if (exactChunk) {
22666
+ const exports = getWevuRuntimeChunkExportNames(index, exactChunk);
22667
+ if (names.every((name) => exports.has(name))) return exactChunk;
22668
+ }
22669
+ return resolveIndexedWevuInternalChunk(index, names);
22366
22670
  }
22367
22671
  function resolveRememberedWevuRuntimeFileName(moduleId, importedNames, options) {
22368
22672
  const names = [...importedNames];
22369
22673
  const canUseLegacyRuntimeFileName = moduleId === "wevu/internal-runtime" && names.every((importedName) => WEVU_INTERNAL_RUNTIME_EXPORT_SET.has(importedName));
22370
- return options.runtimeFileNames?.get(moduleId) ?? (canUseLegacyRuntimeFileName ? options.runtimeFileName : void 0);
22674
+ const rememberedFileName = options.runtimeFileNames?.get(moduleId) ?? (canUseLegacyRuntimeFileName ? options.runtimeFileName : void 0);
22675
+ if (rememberedFileName && options.isRuntimeFileNameAvailable && !options.isRuntimeFileNameAvailable(rememberedFileName)) return;
22676
+ return rememberedFileName;
22371
22677
  }
22372
22678
  function formatWevuRuntimeRequire(fileName, runtimeFileName, bindings) {
22373
22679
  const specifier = normalizeRelativeRequireSpecifier(fileName, runtimeFileName);
@@ -23429,6 +23735,38 @@ const IFDEF = "#ifdef";
23429
23735
  const IFNDEF = "#ifndef";
23430
23736
  //#endregion
23431
23737
  //#region src/postcss/post.ts
23738
+ const UNI_APP_PLATFORM_DEFINES = {
23739
+ weapp: [
23740
+ "mp",
23741
+ "mp-weixin",
23742
+ "vue3"
23743
+ ],
23744
+ alipay: [
23745
+ "mp",
23746
+ "mp-alipay",
23747
+ "vue3"
23748
+ ],
23749
+ tt: [
23750
+ "mp",
23751
+ "mp-toutiao",
23752
+ "vue3"
23753
+ ],
23754
+ swan: [
23755
+ "mp",
23756
+ "mp-baidu",
23757
+ "vue3"
23758
+ ],
23759
+ jd: [
23760
+ "mp",
23761
+ "mp-jd",
23762
+ "vue3"
23763
+ ],
23764
+ xhs: [
23765
+ "mp",
23766
+ "mp-xhs",
23767
+ "vue3"
23768
+ ]
23769
+ };
23432
23770
  function normalizeTargets(values) {
23433
23771
  return values.map((value) => value.trim().toLowerCase()).filter(Boolean);
23434
23772
  }
@@ -23478,6 +23816,7 @@ function removeConditionalBlock(start) {
23478
23816
  const postCreator = (options = { platform: "weapp" }) => {
23479
23817
  const atRulePrefixRegExp = new RegExp(`^wv-`);
23480
23818
  const platform = options.platform.toLowerCase();
23819
+ const activeTargets = /* @__PURE__ */ new Set([platform, ...UNI_APP_PLATFORM_DEFINES[options.platform]]);
23481
23820
  return {
23482
23821
  postcssPlugin: "postcss-weapp-vite-plugin-post",
23483
23822
  prepare() {
@@ -23503,7 +23842,7 @@ const postCreator = (options = { platform: "weapp" }) => {
23503
23842
  comment.remove();
23504
23843
  return;
23505
23844
  }
23506
- const hasPlatform = directive.targets.includes(platform);
23845
+ const hasPlatform = directive.targets.some((target) => activeTargets.has(target));
23507
23846
  if (!(directive.type === "ifdef" ? hasPlatform : !hasPlatform)) {
23508
23847
  removeConditionalBlock(comment);
23509
23848
  comment.remove();
@@ -23518,10 +23857,11 @@ const postCreator = (options = { platform: "weapp" }) => {
23518
23857
  postCreator.postcss = true;
23519
23858
  //#endregion
23520
23859
  //#region src/postcss/index.ts
23521
- const NEEDS_PROCESS_RE = new RegExp(`@wv-|${IFDEF}|${IFNDEF}`);
23860
+ const NEEDS_CONDITIONAL_PROCESS_RE = new RegExp(`@wv-|${IFDEF}|${IFNDEF}`);
23522
23861
  async function cssPostProcess(code, options) {
23523
- if (!NEEDS_PROCESS_RE.test(code)) return code;
23524
- return (await postcss([postCreator(options)]).process(code, { from: void 0 })).css;
23862
+ let processed = code;
23863
+ if (NEEDS_CONDITIONAL_PROCESS_RE.test(processed)) processed = (await postcss([postCreator(options)]).process(processed, { from: void 0 })).css;
23864
+ return options.platform === "weapp" ? transformNestedWxssVars(transformVueDeepSelectors(processed)) : processed;
23525
23865
  }
23526
23866
  //#endregion
23527
23867
  //#region src/plugins/css/shared/preprocessor.ts
@@ -24302,6 +24642,9 @@ function createOutputFinalizerPlugin(ctx) {
24302
24642
  get runtimeFileNames() {
24303
24643
  return ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileNames;
24304
24644
  },
24645
+ isRuntimeFileNameAvailable(fileName) {
24646
+ return ctx.runtimeState?.build?.output?.emittedSource.has(fileName) === true;
24647
+ },
24305
24648
  onRuntimeFileName(fileName) {
24306
24649
  const outputState = ctx.runtimeState?.build?.output;
24307
24650
  if (outputState) outputState.wevuInternalRuntimeFileName = fileName;
@@ -24602,7 +24945,7 @@ function rewriteMiniProgramPlatformApiAccess(code, globalName, _options) {
24602
24945
  OptionalMemberExpression: rewritePath
24603
24946
  });
24604
24947
  if (!mutated) return code;
24605
- const transformedCode = generate(ast).code;
24948
+ const transformedCode = generate$1(ast).code;
24606
24949
  return `${`var ${injectedApiIdentifier} = ${createWeapiAccessExpression(globalName)};`}\n${transformedCode}`;
24607
24950
  } catch {
24608
24951
  return code;
@@ -24692,7 +25035,7 @@ function rewriteChunkNpmImportsByPlatform(platform, code, dependencies, mode, op
24692
25035
  mutated = true;
24693
25036
  } });
24694
25037
  if (!mutated) return code;
24695
- return generate(ast).code;
25038
+ return generate$1(ast).code;
24696
25039
  } catch {
24697
25040
  return code;
24698
25041
  }
@@ -24766,6 +25109,43 @@ function matchesSubPackageDependency(dependencies, importee, fallbackDependencie
24766
25109
  return hasNpmDependencyPrefix(fallbackDependencies, normalized);
24767
25110
  }
24768
25111
  //#endregion
25112
+ //#region src/utils/sourcemap.ts
25113
+ function isEncodedSourceMapLike(value) {
25114
+ return Boolean(value && typeof value === "object" && "version" in value && typeof value.version === "number" && "mappings" in value && "names" in value && "sources" in value);
25115
+ }
25116
+ function normalizeEncodedSourceMapLike(value) {
25117
+ if (!value || typeof value !== "object") return null;
25118
+ const sourceMap = value;
25119
+ const numericVersion = typeof sourceMap.version === "number" ? sourceMap.version : typeof sourceMap.version === "string" ? Number(sourceMap.version) : NaN;
25120
+ if (!Number.isFinite(numericVersion)) return null;
25121
+ const normalized = {
25122
+ ...sourceMap,
25123
+ version: numericVersion
25124
+ };
25125
+ return isEncodedSourceMapLike(normalized) ? normalized : null;
25126
+ }
25127
+ function composeSourceMaps(transformedMap, originalMap) {
25128
+ if (isEncodedSourceMapLike(transformedMap) && isEncodedSourceMapLike(originalMap)) return remapping([transformedMap, originalMap], () => null);
25129
+ if (isEncodedSourceMapLike(transformedMap)) return transformedMap;
25130
+ if (isEncodedSourceMapLike(originalMap)) return originalMap;
25131
+ return null;
25132
+ }
25133
+ //#endregion
25134
+ //#region src/plugins/core/lifecycle/emit/rewrite/sourcemap.ts
25135
+ function applyMagicStringChunkRewrite(chunk, magicString) {
25136
+ const previousCode = chunk.code;
25137
+ const nextCode = magicString.toString();
25138
+ if (nextCode === previousCode) return false;
25139
+ const previousMap = normalizeEncodedSourceMapLike(chunk.map);
25140
+ chunk.code = nextCode;
25141
+ if (previousMap) chunk.map = composeSourceMaps(magicString.generateMap({
25142
+ hires: "boundary",
25143
+ includeContent: true,
25144
+ source: chunk.fileName
25145
+ }), previousMap);
25146
+ return true;
25147
+ }
25148
+ //#endregion
24769
25149
  //#region src/plugins/core/lifecycle/emit/rewrite/localRoot.ts
24770
25150
  function isRelativeMiniprogramNpmImport(importee) {
24771
25151
  return importee === "miniprogram_npm" || importee.startsWith("./miniprogram_npm/") || importee.startsWith("../miniprogram_npm/") || importee.includes("/miniprogram_npm/");
@@ -24779,6 +25159,17 @@ function isToEsmCall(node) {
24779
25159
  function isNumericOneLiteral(node) {
24780
25160
  return (node?.type === "NumericLiteral" || node?.type === "Literal") && node.value === 1;
24781
25161
  }
25162
+ function hasNodeRange(node) {
25163
+ return Number.isInteger(node?.start) && Number.isInteger(node?.end) && node.start >= 0 && node.end >= node.start;
25164
+ }
25165
+ function findPreviousCommaIndex(code, start) {
25166
+ for (let index = start - 1; index >= 0; index--) {
25167
+ const char = code[index];
25168
+ if (char === ",") return index;
25169
+ if (!/\s/.test(char)) return start;
25170
+ }
25171
+ return start;
25172
+ }
24782
25173
  function getLocalizedBindingNameFromExpression(node, localizedRequireBindings) {
24783
25174
  if (!node) return;
24784
25175
  if (node.type === "Identifier" && localizedRequireBindings.has(node.name)) return node.name;
@@ -24801,6 +25192,7 @@ function rewriteChunkNpmImportsToLocalRoot(chunk, root, dependencyPatterns, depe
24801
25192
  if (!analysis.hasStaticRequireLiteral) return;
24802
25193
  try {
24803
25194
  const ast = parseJsLike(chunk.code);
25195
+ const magicString = new MagicString(chunk.code);
24804
25196
  let mutated = false;
24805
25197
  const localizedRequireBindings = /* @__PURE__ */ new Set();
24806
25198
  traverse(ast, {
@@ -24831,7 +25223,8 @@ function rewriteChunkNpmImportsToLocalRoot(chunk, root, dependencyPatterns, depe
24831
25223
  if (typeof currentValue !== "string" || !matchesSubPackageDependency(dependencyPatterns, currentValue, dependencies)) return;
24832
25224
  const nextValue = toRelativeRuntimeNpmImport(chunk.fileName, root, currentValue, options?.basedir);
24833
25225
  if (nextValue === currentValue) return;
24834
- setRequireImportLiteral(firstArg, nextValue);
25226
+ if (!hasNodeRange(firstArg)) return;
25227
+ magicString.update(firstArg.start, firstArg.end, JSON.stringify(nextValue));
24835
25228
  if (isRelativeMiniprogramNpmImport(nextValue) && path.parentPath?.node?.type === "VariableDeclarator" && path.parentPath.node.id?.type === "Identifier") localizedRequireBindings.add(path.parentPath.node.id.name);
24836
25229
  if (isRelativeMiniprogramNpmImport(nextValue) && path.parentPath?.node?.type === "AssignmentExpression" && path.parentPath.node.left?.type === "Identifier") localizedRequireBindings.add(path.parentPath.node.left.name);
24837
25230
  mutated = true;
@@ -24842,12 +25235,14 @@ function rewriteChunkNpmImportsToLocalRoot(chunk, root, dependencyPatterns, depe
24842
25235
  if (!Array.isArray(args) || args.length < 2 || !isNumericOneLiteral(args[1])) return;
24843
25236
  const firstArg = args[0];
24844
25237
  if (!Boolean(getLocalizedBindingNameFromExpression(firstArg, localizedRequireBindings))) return;
24845
- path.node.arguments = [firstArg];
25238
+ const secondArg = args[1];
25239
+ if (!hasNodeRange(firstArg) || !hasNodeRange(secondArg)) return;
25240
+ magicString.remove(findPreviousCommaIndex(chunk.code, secondArg.start), secondArg.end);
24846
25241
  mutated = true;
24847
25242
  }
24848
25243
  });
24849
25244
  if (mutated) {
24850
- chunk.code = generate(ast).code;
25245
+ applyMagicStringChunkRewrite(chunk, magicString);
24851
25246
  rememberChunkScriptAnalysis(chunk, analysis, { cache: options?.analysisCache });
24852
25247
  }
24853
25248
  } catch {}
@@ -24956,19 +25351,20 @@ function resolveRequestGlobalsInstallerName(code) {
24956
25351
  let installerName = null;
24957
25352
  const isInstallerFunctionNode = (node) => {
24958
25353
  if (!node) return false;
24959
- const functionCode = generate(node).code;
25354
+ if (Array.isArray(node.params) && node.params.length > 1) return false;
25355
+ const functionCode = generate$1(node).code;
24960
25356
  return FULL_REQUEST_GLOBAL_TARGETS.every((target) => functionCode.includes(target));
24961
25357
  };
24962
25358
  traverse(ast, {
24963
25359
  FunctionDeclaration(path) {
24964
25360
  if (installerName || !path.node?.id?.name) return;
24965
- if (isInstallerFunctionNode(path.node.body)) installerName = path.node.id.name;
25361
+ if (isInstallerFunctionNode(path.node)) installerName = path.node.id.name;
24966
25362
  },
24967
25363
  VariableDeclarator(path) {
24968
25364
  if (installerName || path.node?.id?.type !== "Identifier") return;
24969
25365
  const init = path.node.init;
24970
25366
  if (!init || init.type !== "FunctionExpression" && init.type !== "ArrowFunctionExpression") return;
24971
- if (isInstallerFunctionNode(init.body)) installerName = path.node.id.name;
25367
+ if (isInstallerFunctionNode(init)) installerName = path.node.id.name;
24972
25368
  }
24973
25369
  });
24974
25370
  return installerName;
@@ -25034,13 +25430,7 @@ function injectRequestGlobalsBundleRuntime(bundle, targets, mode, networkDefault
25034
25430
  ...bindingTargets.map((target) => `${REQUEST_GLOBAL_ACTUALS_KEY}[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_BUNDLE_HOST_REF}.${target}`),
25035
25431
  ...bindingTargets.map((target) => `try{globalThis[${JSON.stringify(target)}]=${REQUEST_GLOBAL_BUNDLE_HOST_REF}.${target}}catch{}`)
25036
25432
  ].join(";");
25037
- const bundlePrelude = `/* ${REQUEST_GLOBAL_BUNDLE_MARKER} */ ${passiveBindingsCode ? `${passiveBindingsCode}\n` : ""}`;
25038
- const firstRequireMatch = chunk.code.match(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE);
25039
- if (firstRequireMatch?.[0]) {
25040
- chunk.code = `${bundlePrelude}${chunk.code.replace(firstRequireMatch[0], (match) => `${match};${syntheticExportCode}${runtimeBindingCode}`)}\n`;
25041
- continue;
25042
- }
25043
- chunk.code = `${bundlePrelude}${syntheticExportCode}${chunk.code}\n;${runtimeBindingCode};\n`;
25433
+ chunk.code = `${`/* ${REQUEST_GLOBAL_BUNDLE_MARKER} */ ${passiveBindingsCode ? `${passiveBindingsCode}\n` : ""}`}${syntheticExportCode}${chunk.code}\n;${runtimeBindingCode};\n`;
25044
25434
  }
25045
25435
  return installerChunks;
25046
25436
  }
@@ -25585,7 +25975,7 @@ function isStableHmrSharedChunk(fileName) {
25585
25975
  return fileName.startsWith("weapp-vendors/") || !fileName.includes("/") && fileName !== "app.js";
25586
25976
  }
25587
25977
  function isRuntimeVendorSharedChunk(fileName) {
25588
- return fileName.startsWith("weapp-vendors/") && /(?:^|[-/])[\w-]*runtime[\w-]*(?:[-.]|$)/.test(fileName);
25978
+ return !isWevuStableVendorFileName(fileName) && fileName.startsWith("weapp-vendors/") && /(?:^|[-/])[\w-]*runtime[\w-]*(?:[-.]|$)/.test(fileName);
25589
25979
  }
25590
25980
  function addEmittedChunkFileName(emittedChunkFileNames, fileName, chunk) {
25591
25981
  if (!emittedChunkFileNames) return;
@@ -25993,6 +26383,9 @@ function createGenerateBundleHook(state, isPluginBuild) {
25993
26383
  rewriteWevuInternalRuntimeImports(runtimeRewriteBundle, {
25994
26384
  runtimeFileName: state.ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileName,
25995
26385
  runtimeFileNames: state.ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileNames,
26386
+ isRuntimeFileNameAvailable(fileName) {
26387
+ return state.ctx.runtimeState?.build?.output?.emittedSource.has(fileName) === true;
26388
+ },
25996
26389
  onRuntimeFileName(fileName) {
25997
26390
  const outputState = state.ctx.runtimeState?.build?.output;
25998
26391
  if (outputState) outputState.wevuInternalRuntimeFileName = fileName;
@@ -27354,23 +27747,120 @@ function createCoreLifecyclePlugin(state) {
27354
27747
  //#endregion
27355
27748
  //#region src/plugins/core/requireAnalysis.ts
27356
27749
  const REQUIRE_ANALYSIS_FILTER_RE = /\.[jt]s$/;
27750
+ const URL_SUFFIX_RE = /[?#].*$/;
27751
+ function cleanModuleId(id) {
27752
+ return id.replace(URL_SUFFIX_RE, "");
27753
+ }
27754
+ function createRelativeModuleSpecifier(importerFileName, targetFileName) {
27755
+ const relativePath = path.relative(path.dirname(importerFileName), targetFileName);
27756
+ return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
27757
+ }
27758
+ function resolveModulePackageRoot(id, relativeAbsoluteSrcRoot, subPackageRoots) {
27759
+ return resolveSubPackagePrefix(relativeAbsoluteSrcRoot(cleanModuleId(id)), subPackageRoots);
27760
+ }
27761
+ /**
27762
+ * 判断静态导入是否能安全交给微信普通分包的原生异步加载器。
27763
+ */
27764
+ function isNativeSubPackageImport(options) {
27765
+ return options.dynamicImports === "native" && options.platform === "weapp" && options.request.startsWith(".") && Boolean(options.targetPackageRoot) && options.targetPackageRoot !== options.importerPackageRoot && !options.independentTarget;
27766
+ }
27767
+ function rewriteAsyncDependencies(code, options) {
27768
+ const { dependencyRewrites = [], nativeImportTokens = [], requireCallbackTokens = [] } = options;
27769
+ if (dependencyRewrites.length === 0 && nativeImportTokens.length === 0 && requireCallbackTokens.length === 0) return null;
27770
+ const source = new MagicString(code);
27771
+ for (const token of requireCallbackTokens) {
27772
+ source.overwrite(token.callStart, token.start, "void require.async(");
27773
+ source.overwrite(token.end, token.successCallbackStart, ").then(");
27774
+ }
27775
+ for (const token of nativeImportTokens) source.overwrite(token.callStart, token.start, "require.async(");
27776
+ for (const rewrite of dependencyRewrites) source.overwrite(rewrite.start, rewrite.end, JSON.stringify(rewrite.value));
27777
+ return {
27778
+ code: source.toString(),
27779
+ map: source.generateMap({ hires: "boundary" })
27780
+ };
27781
+ }
27357
27782
  function createRequireAnalysisPlugin(state) {
27358
27783
  const { ctx, requireAsyncEmittedChunks } = state;
27359
- const { configService } = ctx;
27784
+ const { configService, scanService } = ctx;
27785
+ const resolveDynamicImports = () => configService.weappViteConfig?.chunks?.dynamicImports ?? "preserve";
27786
+ let warnedInlineFallback = false;
27360
27787
  return {
27361
27788
  name: "weapp-vite:post",
27362
27789
  enforce: "post",
27790
+ buildStart() {
27791
+ if (resolveDynamicImports() === "inline" && state.buildTarget === "app" && !warnedInlineFallback) {
27792
+ warnedInlineFallback = true;
27793
+ logger_default.warn("`weapp.chunks.dynamicImports: \"inline\"` 已废弃,当前会回退为 `preserve`;请改用 `preserve`,或在微信分包场景使用 `native`。");
27794
+ }
27795
+ },
27363
27796
  transform: {
27364
27797
  filter: { id: REQUIRE_ANALYSIS_FILTER_RE },
27365
- handler(code) {
27798
+ async handler(code, id) {
27366
27799
  try {
27800
+ const dynamicImports = resolveDynamicImports();
27367
27801
  const ast = this.parse(code);
27368
- const { requireTokens } = collectRequireTokens(ast);
27802
+ const { dynamicImportTokens, requireCallbackTokens, requireTokens } = collectRequireTokens(ast);
27803
+ const dependencyRewrites = [];
27804
+ const nativeImportTokens = [];
27805
+ const resolvedDependencies = [];
27806
+ const importerFileName = resolveRelativeOutputFileNameWithExtension(configService, cleanModuleId(id), ".js");
27807
+ const subPackageRoots = [...scanService.subPackageMap.keys()].filter(Boolean).sort((left, right) => right.length - left.length);
27808
+ const importerPackageRoot = resolveModulePackageRoot(id, configService.relativeAbsoluteSrcRoot, subPackageRoots);
27809
+ const resolveDependency = async (token) => {
27810
+ if (!token.value.startsWith(".")) return null;
27811
+ const absoluteRequest = path.resolve(path.dirname(cleanModuleId(id)), token.value);
27812
+ const resolved = await this.resolve(absoluteRequest, id);
27813
+ if (!resolved || resolved.external) return null;
27814
+ const resolvedId = cleanModuleId(resolved.id);
27815
+ const fileName = resolveRelativeOutputFileNameWithExtension(configService, resolvedId, ".js");
27816
+ return {
27817
+ dependency: {
27818
+ fileName,
27819
+ id: resolvedId
27820
+ },
27821
+ specifier: createRelativeModuleSpecifier(importerFileName, fileName)
27822
+ };
27823
+ };
27824
+ for (const token of requireTokens) {
27825
+ const resolved = await resolveDependency(token);
27826
+ if (!resolved) continue;
27827
+ dependencyRewrites.push({
27828
+ end: token.end,
27829
+ start: token.start,
27830
+ value: resolved.specifier
27831
+ });
27832
+ resolvedDependencies.push(resolved.dependency);
27833
+ }
27834
+ if (dynamicImports === "native" && configService.platform === "weapp") for (const token of dynamicImportTokens) {
27835
+ const resolved = await resolveDependency(token);
27836
+ if (!resolved) continue;
27837
+ const targetPackageRoot = resolveModulePackageRoot(resolved.dependency.id, configService.relativeAbsoluteSrcRoot, subPackageRoots);
27838
+ if (!isNativeSubPackageImport({
27839
+ dynamicImports,
27840
+ importerPackageRoot,
27841
+ independentTarget: scanService.independentSubPackageMap.has(targetPackageRoot),
27842
+ platform: configService.platform,
27843
+ request: token.value,
27844
+ targetPackageRoot
27845
+ })) continue;
27846
+ dependencyRewrites.push({
27847
+ end: token.end,
27848
+ start: token.start,
27849
+ value: resolved.specifier
27850
+ });
27851
+ nativeImportTokens.push(token);
27852
+ resolvedDependencies.push(resolved.dependency);
27853
+ }
27854
+ const rewritten = rewriteAsyncDependencies(code, {
27855
+ dependencyRewrites,
27856
+ nativeImportTokens,
27857
+ requireCallbackTokens
27858
+ });
27369
27859
  return {
27370
- code,
27371
- ast,
27372
- map: null,
27373
- meta: { requireTokens }
27860
+ code: rewritten?.code ?? code,
27861
+ ...rewritten ? {} : { ast },
27862
+ map: rewritten?.map ?? null,
27863
+ meta: { requireAsyncDependencies: resolvedDependencies }
27374
27864
  };
27375
27865
  } catch (error) {
27376
27866
  logger_default.error(error);
@@ -27378,19 +27868,16 @@ function createRequireAnalysisPlugin(state) {
27378
27868
  }
27379
27869
  },
27380
27870
  async moduleParsed(moduleInfo) {
27381
- const requireTokens = moduleInfo.meta.requireTokens;
27382
- if (!Array.isArray(requireTokens)) return;
27383
- for (const requireModule of requireTokens) {
27384
- const absPath = path.resolve(path.dirname(moduleInfo.id), requireModule.value);
27385
- const resolved = await this.resolve(absPath, moduleInfo.id);
27386
- if (!resolved) continue;
27387
- await this.load(resolved);
27388
- if (requireAsyncEmittedChunks.has(resolved.id)) continue;
27389
- requireAsyncEmittedChunks.add(resolved.id);
27871
+ const dependencies = moduleInfo.meta.requireAsyncDependencies;
27872
+ if (!Array.isArray(dependencies)) return;
27873
+ for (const dependency of dependencies) {
27874
+ await this.load({ id: dependency.id });
27875
+ if (requireAsyncEmittedChunks.has(dependency.id)) continue;
27876
+ requireAsyncEmittedChunks.add(dependency.id);
27390
27877
  this.emitFile({
27391
27878
  type: "chunk",
27392
- id: resolved.id,
27393
- fileName: resolveRelativeOutputFileNameWithExtension(configService, resolved.id, ".js"),
27879
+ id: dependency.id,
27880
+ fileName: dependency.fileName,
27394
27881
  preserveSignature: "exports-only"
27395
27882
  });
27396
27883
  }
@@ -27525,6 +28012,49 @@ function preflight(ctx) {
27525
28012
  return [createPluginPruner(), createEnvSynchronizer(ctx)];
27526
28013
  }
27527
28014
  //#endregion
28015
+ //#region src/plugins/uniApp.ts
28016
+ const SUPPORTED_SOURCE_RE = /(?:\.vue|\.[cm]?[jt]sx?|\.(?:css|less|sass|scss|styl|stylus))(?:\?.*)?$/i;
28017
+ function resolveVirtualBlockType(id) {
28018
+ const queryIndex = id.indexOf("?");
28019
+ if (queryIndex < 0) return;
28020
+ const query = new URLSearchParams(id.slice(queryIndex + 1));
28021
+ const block = query.get("weapp-vite-sidecar") ?? (query.has("weapp-vite-vue") ? query.get("type") : void 0);
28022
+ return block === "script" || block === "template" || block === "style" ? block : block ? null : void 0;
28023
+ }
28024
+ function resolveIncludedPackage(id, include) {
28025
+ const normalized = id.replace(/\\/g, "/");
28026
+ return include.find((packageName) => normalized.includes(`/node_modules/${packageName}/`));
28027
+ }
28028
+ function uniAppCompatibility(ctx) {
28029
+ const configService = ctx.configService;
28030
+ const config = configService.weappViteConfig?.uniApp;
28031
+ if (!config || configService.platform !== "weapp") return [];
28032
+ return [{
28033
+ name: "weapp-vite:uni-app-compatibility",
28034
+ enforce: "pre",
28035
+ transform(code, id) {
28036
+ const blockType = resolveVirtualBlockType(id);
28037
+ if (id.startsWith("\0") || parseSidecarSourceRequest(id) || !SUPPORTED_SOURCE_RE.test(id) || blockType === null || !isUniAppCompatibilityFile(id, configService.absoluteSrcRoot, config.include)) return null;
28038
+ try {
28039
+ const result = transformUniAppSource(code, {
28040
+ blockType: blockType ?? void 0,
28041
+ filename: id,
28042
+ target: "mp-weixin"
28043
+ });
28044
+ return result.changed ? {
28045
+ code: result.code,
28046
+ map: null
28047
+ } : null;
28048
+ } catch (error) {
28049
+ const packageName = resolveIncludedPackage(id, config.include) ?? "<project-source>";
28050
+ const filename = id.split("?", 1)[0];
28051
+ const section = blockType ?? (filename.endsWith(".vue") ? "sfc" : "source");
28052
+ throw new Error(`[uni-app] package=${packageName} file=${filename} block=${section}: ${error instanceof Error ? error.message : String(error)}`);
28053
+ }
28054
+ }
28055
+ }];
28056
+ }
28057
+ //#endregion
27528
28058
  //#region src/plugins/vue/transform/styleRequest.ts
27529
28059
  const WEAPP_VUE_STYLE_VIRTUAL_PREFIX = "\0weapp-vite:vue-style:";
27530
28060
  const WEAPP_VUE_STYLE_VIRTUAL_PREFIX_PLAIN = "weapp-vite:vue-style:";
@@ -27673,132 +28203,6 @@ function getSourceFromVirtualId(id) {
27673
28203
  return id;
27674
28204
  }
27675
28205
  //#endregion
27676
- //#region src/plugins/vue/transform/bundle/outputExtensions.ts
27677
- function resolveBundleOutputExtensions(outputExtensions) {
27678
- return resolveOutputExtensions(outputExtensions);
27679
- }
27680
- //#endregion
27681
- //#region src/plugins/vue/transform/slotFallbackWrapper.ts
27682
- const slotFallbackWrapperUsageByBundle = /* @__PURE__ */ new WeakMap();
27683
- const slotFallbackWrapperScriptByBundle = /* @__PURE__ */ new WeakMap();
27684
- function parseJsonSafely$1(source) {
27685
- if (!source) return {};
27686
- try {
27687
- const parsed = JSON.parse(source);
27688
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
27689
- } catch {
27690
- return {};
27691
- }
27692
- }
27693
- function stringifyJson(json) {
27694
- return JSON.stringify(json, null, 2);
27695
- }
27696
- function isAsset(value) {
27697
- return value?.type === "asset";
27698
- }
27699
- function getAssetSource(asset) {
27700
- return asset?.source?.toString?.() ?? "";
27701
- }
27702
- function upsertSlotFallbackWrapperUsingComponent(json) {
27703
- const usingComponents = json.usingComponents && typeof json.usingComponents === "object" && !Array.isArray(json.usingComponents) ? { ...json.usingComponents } : {};
27704
- usingComponents[WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME] = WEVU_SLOT_FALLBACK_VIRTUAL_HOST_GLOBAL_PATH;
27705
- json.usingComponents = usingComponents;
27706
- return json;
27707
- }
27708
- function normalizeJsonConfigForPlatform$1(json, compilerCtx) {
27709
- const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
27710
- if (!jsonPlatformOptions.normalizeUsingComponents) return json;
27711
- try {
27712
- const source = resolveJson({ json }, void 0, jsonPlatformOptions.platform, {
27713
- dependencies: jsonPlatformOptions.dependencies,
27714
- alipayNpmMode: jsonPlatformOptions.alipayNpmMode
27715
- });
27716
- return source ? JSON.parse(source) : json;
27717
- } catch {
27718
- return json;
27719
- }
27720
- }
27721
- function getSlotFallbackWrapperUsage(bundle) {
27722
- let usage = slotFallbackWrapperUsageByBundle.get(bundle);
27723
- if (!usage) {
27724
- usage = /* @__PURE__ */ new Set();
27725
- slotFallbackWrapperUsageByBundle.set(bundle, usage);
27726
- }
27727
- return usage;
27728
- }
27729
- function markSlotFallbackWrapperUsage(bundle, relativeBase) {
27730
- getSlotFallbackWrapperUsage(bundle).add(relativeBase);
27731
- }
27732
- function getSlotFallbackWrapperScriptCache(bundle) {
27733
- let cache = slotFallbackWrapperScriptByBundle.get(bundle);
27734
- if (!cache) {
27735
- cache = /* @__PURE__ */ new Map();
27736
- slotFallbackWrapperScriptByBundle.set(bundle, cache);
27737
- }
27738
- return cache;
27739
- }
27740
- function injectSlotFallbackWrapperIntoJsonAsset(bundle, jsonFileName, compilerCtx) {
27741
- const output = bundle[jsonFileName];
27742
- if (!isAsset(output)) return false;
27743
- output.source = stringifyJson(normalizeJsonConfigForPlatform$1(upsertSlotFallbackWrapperUsingComponent(parseJsonSafely$1(getAssetSource(output))), compilerCtx));
27744
- return true;
27745
- }
27746
- function injectGlobalSlotFallbackWrapperUsingComponent(bundle, compilerCtx, outputExtensions) {
27747
- const { jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
27748
- const usage = slotFallbackWrapperUsageByBundle.get(bundle);
27749
- if (!usage?.size) return false;
27750
- if (injectSlotFallbackWrapperIntoJsonAsset(bundle, `app.${jsonExtension}`, compilerCtx)) return true;
27751
- for (const relativeBase of usage) injectSlotFallbackWrapperIntoJsonAsset(bundle, `${relativeBase}.${jsonExtension}`, compilerCtx);
27752
- return false;
27753
- }
27754
- function hasGlobalSlotFallbackWrapperUsingComponentAsset(bundle, outputExtensions) {
27755
- const { jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
27756
- return isAsset(bundle[`app.${jsonExtension}`]);
27757
- }
27758
- function injectLocalSlotFallbackWrapperUsingComponentIfNeeded(options) {
27759
- if (!options.result.slotFallbackWrapperComponent || hasGlobalSlotFallbackWrapperUsingComponentAsset(options.bundle, options.outputExtensions)) return false;
27760
- const config = upsertSlotFallbackWrapperUsingComponent(parseJsonSafely$1(options.result.config));
27761
- options.result.config = stringifyJson(normalizeJsonConfigForPlatform$1(config, options.compilerCtx));
27762
- return true;
27763
- }
27764
- function emitSlotFallbackWrapperScriptIfMissing(ctx, bundle, fileName, script) {
27765
- const existing = bundle[fileName];
27766
- if (existing && existing.type === "asset") {
27767
- if ((existing.source?.toString?.() ?? "") !== script) existing.source = script;
27768
- return;
27769
- }
27770
- const cache = getSlotFallbackWrapperScriptCache(bundle);
27771
- if (cache.get(fileName) === script) return;
27772
- if (!existing) {
27773
- ctx.emitFile({
27774
- type: "asset",
27775
- fileName,
27776
- source: script
27777
- });
27778
- cache.set(fileName, script);
27779
- }
27780
- }
27781
- function emitSlotFallbackWrapperComponentAsset(options) {
27782
- const component = options.result.slotFallbackWrapperComponent;
27783
- if (!component) return;
27784
- const { templateExtension, jsonExtension, scriptExtension } = resolveBundleOutputExtensions(options.outputExtensions);
27785
- const componentBase = WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE;
27786
- markSlotFallbackWrapperUsage(options.bundle, options.relativeBase);
27787
- emitSfcTemplateIfMissing(options.ctx, options.bundle, componentBase, component.template, templateExtension);
27788
- const jsonFileName = `${componentBase}.${jsonExtension}`;
27789
- const mergeJson = createJsonMerger(options.jsonOptions?.mergeStrategy, {
27790
- filename: jsonFileName,
27791
- kind: "component"
27792
- });
27793
- let config = component.config;
27794
- if (options.jsonOptions?.defaults && Object.keys(options.jsonOptions.defaults).length > 0) config = mergeJson(config, options.jsonOptions.defaults, "defaults");
27795
- emitSfcJsonAsset(options.ctx, options.bundle, componentBase, { config: JSON.stringify(normalizeJsonConfigForPlatform$1(config, options.compilerCtx), null, 2) }, {
27796
- kind: "component",
27797
- extension: jsonExtension
27798
- });
27799
- emitSlotFallbackWrapperScriptIfMissing(options.ctx, options.bundle, `${componentBase}.${scriptExtension}`, component.script);
27800
- }
27801
- //#endregion
27802
28206
  //#region src/plugins/vue/transform/classStyle.ts
27803
28207
  function resolveClassStylePackageRoot(ctx, relativeBase, configService) {
27804
28208
  const currentRoot = normalizeRoot(configService.currentSubPackageRoot ?? "");
@@ -27824,11 +28228,16 @@ function resolveClassStyleWxsLocationForBase(ctx, relativeBase, extension, confi
27824
28228
  });
27825
28229
  }
27826
28230
  //#endregion
28231
+ //#region src/plugins/vue/transform/bundle/outputExtensions.ts
28232
+ function resolveBundleOutputExtensions(outputExtensions) {
28233
+ return resolveOutputExtensions(outputExtensions);
28234
+ }
28235
+ //#endregion
27827
28236
  //#region src/plugins/vue/transform/scopedSlot/assets.ts
27828
28237
  function hasOwn(source, key) {
27829
28238
  return Object.prototype.hasOwnProperty.call(source, key);
27830
28239
  }
27831
- function parseJsonSafely(source) {
28240
+ function parseJsonSafely$1(source) {
27832
28241
  if (!source) return;
27833
28242
  try {
27834
28243
  return JSON.parse(source);
@@ -27836,7 +28245,11 @@ function parseJsonSafely(source) {
27836
28245
  return;
27837
28246
  }
27838
28247
  }
27839
- function normalizeJsonConfigForPlatform(json, compilerCtx) {
28248
+ function resolveScopedSlotOwnerStyleImport(relativeBase, styleExtension) {
28249
+ const normalizedBase = toPosixPath(relativeBase);
28250
+ return `@import './${normalizedBase.slice(normalizedBase.lastIndexOf("/") + 1)}.${styleExtension}';\n`;
28251
+ }
28252
+ function normalizeJsonConfigForPlatform$1(json, compilerCtx) {
27840
28253
  const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
27841
28254
  if (!jsonPlatformOptions.normalizeUsingComponents) return json;
27842
28255
  try {
@@ -27909,8 +28322,10 @@ function registerScopedSlotHostGenerics(ctx, scopedSlots, baseUsingComponents) {
27909
28322
  function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, classStyleWxs, outputExtensions, jsonOptions) {
27910
28323
  const scopedSlots = result.scopedSlotComponents;
27911
28324
  if (!scopedSlots?.length) return;
27912
- const { templateExtension, jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
27913
- const configObj = parseJsonSafely(result.config) ?? {};
28325
+ const { templateExtension, styleExtension, jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
28326
+ const hasOwnerStyle = typeof result.style === "string" && result.style.trim().length > 0;
28327
+ if (hasOwnerStyle) emitSfcStyleIfMissing(ctx, bundle, relativeBase, "", styleExtension, { updateExisting: false });
28328
+ const configObj = parseJsonSafely$1(result.config) ?? {};
27914
28329
  const baseUsingComponents = configObj.usingComponents && typeof configObj.usingComponents === "object" && !Array.isArray(configObj.usingComponents) ? { ...configObj.usingComponents } : {};
27915
28330
  const usingComponents = { ...baseUsingComponents };
27916
28331
  registerScopedSlotHostGenerics(compilerCtx, scopedSlots, baseUsingComponents);
@@ -27919,6 +28334,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
27919
28334
  const componentPath = `/${toPosixPath(componentBase)}`;
27920
28335
  usingComponents[scopedSlot.componentName] = componentPath;
27921
28336
  const wxmlFile = `${componentBase}.${templateExtension}`;
28337
+ const styleFile = `${componentBase}.${styleExtension}`;
27922
28338
  const jsonFile = `${componentBase}.${jsonExtension}`;
27923
28339
  const scopedUsingComponents = resolveScopedSlotAutoImports(compilerCtx, baseUsingComponents, componentBase, scopedSlot.template);
27924
28340
  Object.assign(scopedUsingComponents, resolveNestedScopedSlotUsingComponents(scopedSlots, scopedSlot.componentName, relativeBase, scopedSlot.template));
@@ -27927,6 +28343,11 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
27927
28343
  fileName: wxmlFile,
27928
28344
  source: scopedSlot.template
27929
28345
  });
28346
+ if (hasOwnerStyle && !bundle[styleFile]) ctx.emitFile({
28347
+ type: "asset",
28348
+ fileName: styleFile,
28349
+ source: resolveScopedSlotOwnerStyleImport(relativeBase, styleExtension)
28350
+ });
27930
28351
  if (!bundle[jsonFile]) {
27931
28352
  const mergeJson = createJsonMerger(jsonOptions?.mergeStrategy, {
27932
28353
  filename: jsonFile,
@@ -27941,7 +28362,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
27941
28362
  };
27942
28363
  json = mergeJson(defaultConfig, json, "emit");
27943
28364
  if (hasOwn(defaultConfig, "component")) json.component = true;
27944
- const normalizedJson = normalizeJsonConfigForPlatform(json, compilerCtx);
28365
+ const normalizedJson = normalizeJsonConfigForPlatform$1(json, compilerCtx);
27945
28366
  ctx.emitFile({
27946
28367
  type: "asset",
27947
28368
  fileName: jsonFile,
@@ -27951,7 +28372,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
27951
28372
  if (scopedSlot.classStyleWxs && classStyleWxs) emitClassStyleWxsAssetIfMissing(ctx, bundle, classStyleWxs.fileName, classStyleWxs.source);
27952
28373
  }
27953
28374
  configObj.usingComponents = usingComponents;
27954
- result.config = JSON.stringify(normalizeJsonConfigForPlatform(configObj, compilerCtx), null, 2);
28375
+ result.config = JSON.stringify(normalizeJsonConfigForPlatform$1(configObj, compilerCtx), null, 2);
27955
28376
  }
27956
28377
  //#endregion
27957
28378
  //#region src/plugins/vue/transform/scopedSlot/module.ts
@@ -27963,20 +28384,31 @@ function buildInlineExpressionMapCode(inlineExpressions) {
27963
28384
  return `${JSON.stringify(entry.id)}:{keys:${keys},fn:(ctx,scope,$event)=>${entry.expression}}`;
27964
28385
  }).join(",")}}`;
27965
28386
  }
28387
+ function buildTemplateRefsCode(templateRefs) {
28388
+ if (!templateRefs?.length) return null;
28389
+ return `[${templateRefs.map((binding) => {
28390
+ const fields = [`selector:${JSON.stringify(binding.selector)}`, `inFor:${binding.inFor}`];
28391
+ if (binding.name) fields.push(`name:${JSON.stringify(binding.name)}`);
28392
+ if (binding.expAst) fields.push(`get:function(){return ${generate(binding.expAst, { compact: true }).code}}`);
28393
+ if (binding.kind) fields.push(`kind:${JSON.stringify(binding.kind)}`);
28394
+ return `{${fields.join(",")}}`;
28395
+ }).join(",")}]`;
28396
+ }
27966
28397
  function buildScopedSlotComponentModule(options) {
27967
28398
  const computedCode = options?.computedCode;
27968
28399
  const inlineMapCode = options?.inlineMapCode;
28400
+ const templateRefsCode = options?.templateRefsCode;
27969
28401
  const lines = [`import { ${WE_VU_RUNTIME_APIS.createWevuScopedSlotComponent} as _createWevuScopedSlotComponent } from '${WE_VU_COMPILER_RUNTIME_MODULE_ID}';`];
27970
- if (computedCode) {
27971
- lines.push(`import { normalizeClass as __wevuNormalizeClass, normalizeStyle as __wevuNormalizeStyle } from '${WE_VU_COMPILER_TEMPLATE_MODULE_ID}';`);
27972
- lines.push(`import { unref as __wevuUnref } from '${WE_VU_COMPILER_REACTIVITY_MODULE_ID}';`);
27973
- }
28402
+ if (computedCode) lines.push(`import { normalizeClass as __wevuNormalizeClass, normalizeStyle as __wevuNormalizeStyle } from '${WE_VU_COMPILER_TEMPLATE_MODULE_ID}';`);
28403
+ if (computedCode || templateRefsCode) lines.push(`import { unref as __wevuUnref } from '${WE_VU_COMPILER_REACTIVITY_MODULE_ID}';`);
27974
28404
  lines.push("const globalObject = typeof globalThis !== 'undefined' ? globalThis : undefined;", `const createWevuScopedSlotComponent = globalObject?.${WEVU_SCOPED_SLOT_CREATOR_KEY}`, " ?? _createWevuScopedSlotComponent;");
27975
28405
  if (computedCode) lines.push(`const __wevuComputed = ${computedCode};`);
27976
28406
  if (inlineMapCode) lines.push(`const __wevuInlineMap = ${inlineMapCode};`);
28407
+ if (templateRefsCode) lines.push(`const __wevuTemplateRefs = ${templateRefsCode};`);
27977
28408
  const overrideParts = [];
27978
28409
  if (computedCode) overrideParts.push("computed: __wevuComputed");
27979
28410
  if (inlineMapCode) overrideParts.push("inlineMap: __wevuInlineMap");
28411
+ if (templateRefsCode) overrideParts.push("templateRefs: __wevuTemplateRefs");
27980
28412
  const overrideArg = overrideParts.length ? `{ ${overrideParts.join(", ")} }` : "";
27981
28413
  lines.push("if (typeof createWevuScopedSlotComponent === 'function') {");
27982
28414
  if (overrideArg) lines.push(` createWevuScopedSlotComponent(${overrideArg});`);
@@ -28004,9 +28436,11 @@ function emitScopedSlotChunks(ctx, relativeBase, result, scopedSlotModules, emit
28004
28436
  unrefName: "__wevuUnref"
28005
28437
  }) : null;
28006
28438
  const inlineMapCode = buildInlineExpressionMapCode(scopedSlot.inlineExpressions);
28007
- scopedSlotModules.set(virtualId, buildScopedSlotComponentModule(computedCode || inlineMapCode ? {
28439
+ const templateRefsCode = buildTemplateRefsCode(scopedSlot.templateRefs);
28440
+ scopedSlotModules.set(virtualId, buildScopedSlotComponentModule(computedCode || inlineMapCode || templateRefsCode ? {
28008
28441
  computedCode: computedCode ?? void 0,
28009
- inlineMapCode: inlineMapCode ?? void 0
28442
+ inlineMapCode: inlineMapCode ?? void 0,
28443
+ templateRefsCode: templateRefsCode ?? void 0
28010
28444
  } : void 0));
28011
28445
  }
28012
28446
  ctx.emitFile({
@@ -28032,6 +28466,90 @@ function loadScopedSlotModule(id, scopedSlotModules) {
28032
28466
  };
28033
28467
  }
28034
28468
  //#endregion
28469
+ //#region src/plugins/vue/transform/slotFallbackWrapper.ts
28470
+ const slotFallbackWrapperScriptByBundle = /* @__PURE__ */ new WeakMap();
28471
+ function parseJsonSafely(source) {
28472
+ if (!source) return {};
28473
+ try {
28474
+ const parsed = JSON.parse(source);
28475
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
28476
+ } catch {
28477
+ return {};
28478
+ }
28479
+ }
28480
+ function stringifyJson(json) {
28481
+ return JSON.stringify(json, null, 2);
28482
+ }
28483
+ function upsertSlotFallbackWrapperUsingComponent(json) {
28484
+ const usingComponents = json.usingComponents && typeof json.usingComponents === "object" && !Array.isArray(json.usingComponents) ? { ...json.usingComponents } : {};
28485
+ usingComponents[WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME] = WEVU_SLOT_FALLBACK_VIRTUAL_HOST_GLOBAL_PATH;
28486
+ json.usingComponents = usingComponents;
28487
+ return json;
28488
+ }
28489
+ function normalizeJsonConfigForPlatform(json, compilerCtx) {
28490
+ const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
28491
+ if (!jsonPlatformOptions.normalizeUsingComponents) return json;
28492
+ try {
28493
+ const source = resolveJson({ json }, void 0, jsonPlatformOptions.platform, {
28494
+ dependencies: jsonPlatformOptions.dependencies,
28495
+ alipayNpmMode: jsonPlatformOptions.alipayNpmMode
28496
+ });
28497
+ return source ? JSON.parse(source) : json;
28498
+ } catch {
28499
+ return json;
28500
+ }
28501
+ }
28502
+ function getSlotFallbackWrapperScriptCache(bundle) {
28503
+ let cache = slotFallbackWrapperScriptByBundle.get(bundle);
28504
+ if (!cache) {
28505
+ cache = /* @__PURE__ */ new Map();
28506
+ slotFallbackWrapperScriptByBundle.set(bundle, cache);
28507
+ }
28508
+ return cache;
28509
+ }
28510
+ function injectLocalSlotFallbackWrapperUsingComponentIfNeeded(options) {
28511
+ if (!options.result.slotFallbackWrapperComponent) return false;
28512
+ const config = upsertSlotFallbackWrapperUsingComponent(parseJsonSafely(options.result.config));
28513
+ options.result.config = stringifyJson(normalizeJsonConfigForPlatform(config, options.compilerCtx));
28514
+ return true;
28515
+ }
28516
+ function emitSlotFallbackWrapperScriptIfMissing(ctx, bundle, fileName, script) {
28517
+ const existing = bundle[fileName];
28518
+ if (existing && existing.type === "asset") {
28519
+ if ((existing.source?.toString?.() ?? "") !== script) existing.source = script;
28520
+ return;
28521
+ }
28522
+ const cache = getSlotFallbackWrapperScriptCache(bundle);
28523
+ if (cache.get(fileName) === script) return;
28524
+ if (!existing) {
28525
+ ctx.emitFile({
28526
+ type: "asset",
28527
+ fileName,
28528
+ source: script
28529
+ });
28530
+ cache.set(fileName, script);
28531
+ }
28532
+ }
28533
+ function emitSlotFallbackWrapperComponentAsset(options) {
28534
+ const component = options.result.slotFallbackWrapperComponent;
28535
+ if (!component) return;
28536
+ const { templateExtension, jsonExtension, scriptExtension } = resolveBundleOutputExtensions(options.outputExtensions);
28537
+ const componentBase = WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE;
28538
+ emitSfcTemplateIfMissing(options.ctx, options.bundle, componentBase, component.template, templateExtension);
28539
+ const jsonFileName = `${componentBase}.${jsonExtension}`;
28540
+ const mergeJson = createJsonMerger(options.jsonOptions?.mergeStrategy, {
28541
+ filename: jsonFileName,
28542
+ kind: "component"
28543
+ });
28544
+ let config = component.config;
28545
+ if (options.jsonOptions?.defaults && Object.keys(options.jsonOptions.defaults).length > 0) config = mergeJson(config, options.jsonOptions.defaults, "defaults");
28546
+ emitSfcJsonAsset(options.ctx, options.bundle, componentBase, { config: JSON.stringify(normalizeJsonConfigForPlatform(config, options.compilerCtx), null, 2) }, {
28547
+ kind: "component",
28548
+ extension: jsonExtension
28549
+ });
28550
+ emitSlotFallbackWrapperScriptIfMissing(options.ctx, options.bundle, `${componentBase}.${scriptExtension}`, component.script);
28551
+ }
28552
+ //#endregion
28035
28553
  //#region src/plugins/vue/transform/bundle/shared/assets.ts
28036
28554
  const APP_VUE_LIKE_FILE_RE$1 = /[\\/]app\.(?:vue|jsx|tsx)$/;
28037
28555
  async function processVueResultStyle(style, configService) {
@@ -28215,8 +28733,11 @@ async function emitCompiledEntryBundleAssets(options) {
28215
28733
  function hasVueExtension(id) {
28216
28734
  return Boolean(id?.endsWith(".vue"));
28217
28735
  }
28218
- function getCompileVueFileOptionsCacheKey(vuePath, isPage, isApp) {
28219
- return `${vuePath}::${isPage ? "page" : "component"}::${isApp ? "app" : "entry"}`;
28736
+ function getCompileVueFileOptionsCacheKey(vuePath, isPage, isApp, delegatesComponentRegistration = false) {
28737
+ return `${vuePath}::${isPage ? "page" : "component"}::${isApp ? "app" : "entry"}::${delegatesComponentRegistration ? "logical-registration" : "module-registration"}`;
28738
+ }
28739
+ function shouldDelegateComponentRegistration(ctx, vuePath, isPage, isApp, configService) {
28740
+ return !isPage && !isApp && !configService.weappLibConfig?.enabled && !ctx.moduleGraphService?.isLogicalLayoutEntry?.(vuePath);
28220
28741
  }
28221
28742
  function isVueTransformSourceMapEnabled(configService) {
28222
28743
  return Boolean(configService.inlineConfig?.build?.sourcemap);
@@ -28240,7 +28761,7 @@ function resolveVueTemplatePlatformOptions(options) {
28240
28761
  classStyleRuntime
28241
28762
  };
28242
28763
  }
28243
- function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, configService, state) {
28764
+ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, configService, state, delegatesComponentRegistration) {
28244
28765
  const importerBaseName = removeExtensionDeep(vuePath);
28245
28766
  const autoImportResolveCache = /* @__PURE__ */ new Map();
28246
28767
  const scopedSlotsCompiler = configService.weappViteConfig?.vue?.template?.scopedSlotsCompiler ?? "auto";
@@ -28333,6 +28854,7 @@ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, conf
28333
28854
  return {
28334
28855
  isPage,
28335
28856
  isApp,
28857
+ skipComponentTransform: delegatesComponentRegistration,
28336
28858
  warn: (message) => logger_default.warn(message),
28337
28859
  autoUsingComponents: {
28338
28860
  enabled: true,
@@ -28354,9 +28876,12 @@ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, conf
28354
28876
  });
28355
28877
  if (!match?.value) return;
28356
28878
  const sourceInfo = await resolveAutoImportComponentSourceType(match);
28879
+ const stableFrom = sourceInfo.sourceType === "wevu-sfc" ? usingComponentFromResolvedFile(sourceInfo.resolvedId, configService) : void 0;
28880
+ if (stableFrom && sourceInfo.resolvedId) ctx.runtimeState?.build?.hmr?.externalComponentEntryMap?.set(removeExtensionDeep(stableFrom).replace(/^\/+/, ""), sourceInfo.resolvedId);
28357
28881
  return {
28358
28882
  ...match.value,
28359
- ...sourceInfo
28883
+ ...sourceInfo,
28884
+ ...stableFrom ? { from: stableFrom } : {}
28360
28885
  };
28361
28886
  }
28362
28887
  },
@@ -28391,36 +28916,15 @@ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, conf
28391
28916
  };
28392
28917
  }
28393
28918
  function createCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, configService, state) {
28394
- const cacheKey = getCompileVueFileOptionsCacheKey(vuePath, isPage, isApp);
28919
+ const delegatesComponentRegistration = shouldDelegateComponentRegistration(ctx, vuePath, isPage, isApp, configService);
28920
+ const cacheKey = getCompileVueFileOptionsCacheKey(vuePath, isPage, isApp, delegatesComponentRegistration);
28395
28921
  const cached = state.compileOptionsCache?.get(cacheKey);
28396
28922
  if (cached) return cached;
28397
- const created = buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, configService, state);
28923
+ const created = buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, configService, state, delegatesComponentRegistration);
28398
28924
  state.compileOptionsCache?.set(cacheKey, created);
28399
28925
  return created;
28400
28926
  }
28401
28927
  //#endregion
28402
- //#region src/utils/sourcemap.ts
28403
- function isEncodedSourceMapLike(value) {
28404
- return Boolean(value && typeof value === "object" && "version" in value && typeof value.version === "number" && "mappings" in value && "names" in value && "sources" in value);
28405
- }
28406
- function normalizeEncodedSourceMapLike(value) {
28407
- if (!value || typeof value !== "object") return null;
28408
- const sourceMap = value;
28409
- const numericVersion = typeof sourceMap.version === "number" ? sourceMap.version : typeof sourceMap.version === "string" ? Number(sourceMap.version) : NaN;
28410
- if (!Number.isFinite(numericVersion)) return null;
28411
- const normalized = {
28412
- ...sourceMap,
28413
- version: numericVersion
28414
- };
28415
- return isEncodedSourceMapLike(normalized) ? normalized : null;
28416
- }
28417
- function composeSourceMaps(transformedMap, originalMap) {
28418
- if (isEncodedSourceMapLike(transformedMap) && isEncodedSourceMapLike(originalMap)) return remapping([transformedMap, originalMap], () => null);
28419
- if (isEncodedSourceMapLike(transformedMap)) return transformedMap;
28420
- if (isEncodedSourceMapLike(originalMap)) return originalMap;
28421
- return null;
28422
- }
28423
- //#endregion
28424
28928
  //#region src/plugins/utils/viteResolverAdapter.ts
28425
28929
  const WINDOWS_ABSOLUTE_PATH_RE = /^[A-Z]:[\\/]/i;
28426
28930
  function isExplicitFileRequest(id) {
@@ -29310,7 +29814,11 @@ async function emitBundlePageLayoutsIfNeeded(options) {
29310
29814
  emitVueLayout: layoutEmitters.emitVueLayout
29311
29815
  });
29312
29816
  }
29313
- function resolveAppShellComponentConfig(config) {
29817
+ function resolveAppShellUsingComponents(template, usingComponents) {
29818
+ const templateComponents = scanWxml(template, { excludeComponent: () => false }).autoImportComponents ?? {};
29819
+ return Object.fromEntries(Object.entries(usingComponents).filter(([name]) => Reflect.has(templateComponents, name)));
29820
+ }
29821
+ function resolveAppShellComponentConfig(config, template) {
29314
29822
  const shellConfig = { styleIsolation: "apply-shared" };
29315
29823
  if (!config) return JSON.stringify(shellConfig, null, 2);
29316
29824
  try {
@@ -29318,7 +29826,10 @@ function resolveAppShellComponentConfig(config) {
29318
29826
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return JSON.stringify(shellConfig, null, 2);
29319
29827
  for (const key of ["usingComponents", "componentGenerics"]) {
29320
29828
  const value = parsed[key];
29321
- if (value && typeof value === "object" && !Array.isArray(value)) shellConfig[key] = value;
29829
+ if (value && typeof value === "object" && !Array.isArray(value)) {
29830
+ const normalizedValue = key === "usingComponents" ? resolveAppShellUsingComponents(template, value) : value;
29831
+ if (Object.keys(normalizedValue).length > 0) shellConfig[key] = normalizedValue;
29832
+ }
29322
29833
  }
29323
29834
  return Object.keys(shellConfig).length ? JSON.stringify(shellConfig, null, 2) : void 0;
29324
29835
  } catch {
@@ -29350,7 +29861,7 @@ function emitAppShellAssetsIfNeeded(options) {
29350
29861
  bundle: options.bundle,
29351
29862
  pluginCtx: options.pluginCtx,
29352
29863
  relativeBase,
29353
- config: resolveAppShellComponentConfig(result.config),
29864
+ config: resolveAppShellComponentConfig(result.config, result.template),
29354
29865
  outputExtensions: options.outputExtensions,
29355
29866
  platformAssetOptions: options.platformAssetOptions,
29356
29867
  jsonOptions: {
@@ -29684,7 +30195,6 @@ async function emitVueBundleAssets(bundle, state) {
29684
30195
  if (!emitState) return;
29685
30196
  await emitCompiledBundleEntries(bundle, state, emitState.compilationEntries);
29686
30197
  await emitFallbackPageAssets(bundle, state, { emittedEntryIds: emitState.emittedEntryIds });
29687
- injectGlobalSlotFallbackWrapperUsingComponent(bundle, state.ctx, state.ctx.configService.outputExtensions);
29688
30198
  }
29689
30199
  //#endregion
29690
30200
  //#region src/plugins/wevu.ts
@@ -30440,7 +30950,7 @@ async function transformWxsFile(state, wxsPath) {
30440
30950
  const dirname = path.dirname(wxsPath);
30441
30951
  const importeePaths = importees.map(({ source }) => path.resolve(dirname, source));
30442
30952
  await Promise.all(importeePaths.map((importeePath) => transformWxsFile.call(this, state, importeePath)));
30443
- if (code === void 0) return;
30953
+ if (code == null) return;
30444
30954
  const emittedFile = {
30445
30955
  type: "asset",
30446
30956
  fileName: resolveWxsOutputFileName(ctx, wxsPath, scriptModuleExtension),
@@ -30554,6 +31064,7 @@ function vitePluginWeapp(ctx, subPackageMeta) {
30554
31064
  const groups = [
30555
31065
  [createContextPlugin(ctx), createSelectedRuntimeProviderPlugin(runtimeProvider, ctx.configService.isDev)],
30556
31066
  preflight(ctx),
31067
+ uniAppCompatibility(ctx),
30557
31068
  vue(ctx, { enable: vueEnabled })
30558
31069
  ];
30559
31070
  if (vueEnabled && !libModeEnabled) groups.push(wevu(ctx));
@@ -30705,6 +31216,7 @@ function mergeMiniprogram(options, ...configs) {
30705
31216
  const npmBuildCandidates = packageJson ? resolveNpmBuildCandidateDependenciesSync(ctx, packageJson) : [];
30706
31217
  if (npmBuildCandidates.length > 0) {
30707
31218
  const builtinAliases = resolveBuiltinPackageAliases({
31219
+ cwd,
30708
31220
  isDev,
30709
31221
  wevuRuntime: config.weapp?.wevu?.runtime
30710
31222
  });
@@ -30836,11 +31348,13 @@ function mergeWeb(options, ...configs) {
30836
31348
  stripRollupOptions(inline);
30837
31349
  inline.root = web.root;
30838
31350
  inline.configFile = false;
30839
- inline.mode = inline.mode ?? mode;
30840
31351
  const runtimeProvider = resolveRuntimeProvider("web", "web");
30841
31352
  const runtimeProviderPlugin = createSelectedRuntimeProviderPlugin(runtimeProvider, isDev);
30842
31353
  const webPlugin = weappWebPlugin({
30843
31354
  ...web.pluginOptions,
31355
+ __uniApp: options.uniApp || void 0,
31356
+ __autoImportResolvers: options.autoImportResolvers,
31357
+ __resolveAppConfig: options.resolveAppConfig,
30844
31358
  __runtimeProvider: {
30845
31359
  moduleId: WEAPP_VITE_RUNTIME_VIRTUAL_ID,
30846
31360
  hmrAcceptCode: resolveRuntimeProviderHmrFooter(runtimeProvider)
@@ -30851,8 +31365,19 @@ function mergeWeb(options, ...configs) {
30851
31365
  inline.build.outDir = web.outDir;
30852
31366
  inline.build.emptyOutDir ??= !isDev;
30853
31367
  applyWeappViteHostMeta(inline, "web", "web");
30854
- inline.define = defu(inline.define ?? {}, getDefineImportMetaEnv());
30855
- injectBuiltinAliases(inline);
31368
+ inline.define = defu(inline.define, getDefineImportMetaEnv());
31369
+ injectBuiltinAliases(inline, "build");
31370
+ const runtimeAlias = {
31371
+ find: "weapp-vite/runtime",
31372
+ replacement: WEAPP_VITE_RUNTIME_VIRTUAL_ID
31373
+ };
31374
+ inline.resolve ??= {};
31375
+ const aliases = inline.resolve.alias;
31376
+ if (Array.isArray(aliases)) inline.resolve.alias = [runtimeAlias, ...aliases.filter((alias) => !(typeof alias === "object" && alias !== null && "find" in alias && alias.find === runtimeAlias.find))];
31377
+ else inline.resolve.alias = [runtimeAlias, ...Object.entries(aliases ?? {}).filter(([find]) => find !== runtimeAlias.find).map(([find, replacement]) => ({
31378
+ find,
31379
+ replacement
31380
+ }))];
30856
31381
  return inline;
30857
31382
  }
30858
31383
  //#endregion
@@ -30902,7 +31427,7 @@ function createMergeFactories(options) {
30902
31427
  ensureConfigService(ctx);
30903
31428
  const currentOptions = getOptions();
30904
31429
  const configService = ctx.configService;
30905
- const subPackageRoots = Object.keys(configService.weappViteConfig?.subPackages ?? {});
31430
+ const subPackageRoots = Object.keys(configService.weappViteConfig.subPackages ?? {});
30906
31431
  const sharedOutput = configService.options.chunksConfigured ? createSharedBuildOutput(configService, () => subPackageRoots) : void 0;
30907
31432
  return mergeWorkers({
30908
31433
  ctx,
@@ -30946,7 +31471,7 @@ function createMergeFactories(options) {
30946
31471
  const currentOptions = getOptions();
30947
31472
  const configService = ctx.configService;
30948
31473
  const subPackageRoots = Object.keys(configService.weappViteConfig?.subPackages ?? {});
30949
- const sharedOutput = configService.options.chunksConfigured ? createSharedBuildOutput(configService, () => subPackageRoots) : void 0;
31474
+ const sharedOutput = configService.options.chunksConfigured ? createSharedBuildOutput(configService, () => subPackageRoots, { runtime: "web" }) : void 0;
30950
31475
  return backend.driver.mergeConfig({ merge: (...backendConfigs) => mergeWeb({
30951
31476
  config: currentOptions.config,
30952
31477
  web: currentOptions.weappWeb,
@@ -30954,7 +31479,10 @@ function createMergeFactories(options) {
30954
31479
  isDev: currentOptions.isDev,
30955
31480
  applyRuntimePlatform,
30956
31481
  injectBuiltinAliases,
30957
- getDefineImportMetaEnv
31482
+ getDefineImportMetaEnv,
31483
+ uniApp: configService.weappViteConfig.uniApp,
31484
+ autoImportResolvers: typeof configService.weappViteConfig.autoImportComponents === "object" ? configService.weappViteConfig.autoImportComponents.resolvers : void 0,
31485
+ resolveAppConfig: async () => (await ctx.scanService.loadAppEntry()).json
30958
31486
  }, sharedOutput ? { build: { rolldownOptions: { output: sharedOutput } } } : {}, ...backendConfigs) }, ...configs);
30959
31487
  }
30960
31488
  function mergeInlineFactory(...configs) {
@@ -30977,11 +31505,12 @@ function createConfigService(ctx) {
30977
31505
  let options = configState.options;
30978
31506
  let loadingOptions;
30979
31507
  const oxcRuntimeSupport = createOxcRuntimeSupport();
30980
- const aliasManager = createAliasManager(oxcRuntimeSupport.alias, resolveBuiltinPackageAliases());
30981
- function injectBuiltinAliases(config) {
31508
+ const aliasManager = createAliasManager(oxcRuntimeSupport.alias, resolveBuiltinPackageAliases({ cwd: options.cwd }));
31509
+ function injectBuiltinAliases(config, wevuRuntime) {
30982
31510
  aliasManager.injectBuiltinAliases(config, resolveBuiltinPackageAliases({
31511
+ cwd: loadingOptions?.cwd ?? options.cwd,
30983
31512
  isDev: loadingOptions?.isDev ?? options.isDev,
30984
- wevuRuntime: config.weapp?.wevu?.runtime
31513
+ wevuRuntime: wevuRuntime ?? config.weapp?.wevu?.runtime
30985
31514
  }));
30986
31515
  }
30987
31516
  const normalizeComparablePath = (input) => {
@@ -31049,9 +31578,14 @@ function createConfigService(ctx) {
31049
31578
  };
31050
31579
  const resolveExternalOutputPath = (filePath) => {
31051
31580
  const normalizedPath = normalizeComparablePath(filePath);
31581
+ const nodeModulesIndex = normalizedPath.lastIndexOf("/node_modules/");
31582
+ if (nodeModulesIndex >= 0) {
31583
+ const packageRelative = normalizedPath.slice(nodeModulesIndex + 14);
31584
+ return normalizeRelativePath$1(path.join(WEAPP_VITE_EXTERNAL_OUTPUT_DIRECTORY, packageRelative));
31585
+ }
31052
31586
  const normalizedDir = path.dirname(normalizedPath);
31053
31587
  const dirHash = createHash("sha256").update(normalizedDir).digest("hex").slice(0, 10);
31054
- return normalizeRelativePath$1(path.join("__weapp_vite_external__", dirHash, path.basename(normalizedPath)));
31588
+ return normalizeRelativePath$1(path.join(WEAPP_VITE_EXTERNAL_OUTPUT_DIRECTORY, dirHash, path.basename(normalizedPath)));
31055
31589
  };
31056
31590
  function setOptions(value) {
31057
31591
  options = value;
@@ -31546,7 +32080,7 @@ async function loadAppEntry(ctx, scanState) {
31546
32080
  const { path: appEntryPath } = appEntry;
31547
32081
  let configFromVue;
31548
32082
  if (!appConfigFile && vueAppPath) {
31549
- const { extractConfigFromVue } = await import("./file-CWBCL2N8.mjs");
32083
+ const { extractConfigFromVue } = await import("./file-DDpy9efy.mjs");
31550
32084
  configFromVue = await extractConfigFromVue(vueAppPath);
31551
32085
  if (configFromVue) appConfigFile = vueAppPath;
31552
32086
  }