weapp-vite 6.20.1 → 6.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
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 templateExtensions, 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 scriptExtensions, x as vueExtensions, y as supportedCssLangs } from "./file-Bwxu2veP.mjs";
3
+ import { C as isNativeTemplateSource, S as ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS, T as MINI_PROGRAM_PLATFORM_ADAPTERS, _ as jsExtensions, a as findJsonEntry, b as templateExtensions, 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 scriptExtensions, w as isSourceStyleExtension, x as vueExtensions, y as supportedCssLangs } from "./file-AiMZtyLe.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";
@@ -8,13 +8,13 @@ import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MA
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
- 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";
11
+ import { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, 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
13
  import { BABEL_TS_MODULE_PARSER_OPTIONS, analyzeScript, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parse, 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
- import { compileScript, parse as parse$1 } from "vue/compiler-sfc";
17
16
  import { BABEL_TS_MODULE_PARSER_OPTIONS as BABEL_TS_MODULE_PARSER_OPTIONS$1, generate as generate$1, getVisitorKeys, parse as parse$3, parseJsLike, traverse } from "@weapp-vite/ast/babel";
17
+ import { compileScript, parse as parse$1 } from "vue/compiler-sfc";
18
18
  import pm from "picomatch";
19
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";
@@ -36,6 +36,7 @@ import { spawn } from "node:child_process";
36
36
  import PQueue from "p-queue";
37
37
  import { Buffer } from "node:buffer";
38
38
  import MagicString from "magic-string";
39
+ import remapping from "@jridgewell/remapping";
39
40
  import * as t from "@weapp-vite/ast/babelTypes";
40
41
  import babelPresetEnv from "@babel/preset-env";
41
42
  import babelPresetTypescript from "@babel/preset-typescript";
@@ -47,7 +48,6 @@ import { objectHash } from "@weapp-core/shared/node";
47
48
  import { wrapPlugin } from "vite-plugin-performance";
48
49
  import { performance as performance$1 } from "node:perf_hooks";
49
50
  import postcss from "postcss";
50
- import remapping from "@jridgewell/remapping";
51
51
  import { weappWebPlugin } from "@weapp-vite/web";
52
52
  import { bundleRequire } from "rolldown-require";
53
53
  //#region src/debugger.ts
@@ -1373,12 +1373,8 @@ function extractComponentPropsFromDts(code) {
1373
1373
  return props;
1374
1374
  }
1375
1375
  function extractInlinePropsTypeFromCode(code) {
1376
- const source = code.includes("<script") ? (() => {
1377
- const parsed = parse$1(code, { filename: "layout.vue" });
1378
- return parsed.descriptor.scriptSetup?.content ?? parsed.descriptor.script?.content ?? code;
1379
- })() : code;
1380
1376
  const props = /* @__PURE__ */ new Map();
1381
- const ast = parse$3(source, {
1377
+ const ast = parse$3(code, {
1382
1378
  ...BABEL_TS_MODULE_PARSER_OPTIONS$1,
1383
1379
  errorRecovery: true
1384
1380
  });
@@ -2214,10 +2210,10 @@ function createVueComponentsDefinition(componentNames, getMetadata, options = {}
2214
2210
  //#region src/runtime/autoImport/vueProps.ts
2215
2211
  /** 提取 Vue SFC 组件 props,避免为了类型支持文件走完整 SFC 编译。 */
2216
2212
  function extractVueComponentProps(source, filename, options = {}) {
2217
- const inlineProps = extractInlinePropsTypeFromCode(source);
2218
- if (inlineProps.size > 0) return inlineProps;
2219
2213
  const { descriptor, errors } = parse$1(source, { filename });
2220
2214
  if (errors.length || !descriptor.script && !descriptor.scriptSetup) return /* @__PURE__ */ new Map();
2215
+ const inlineProps = extractInlinePropsTypeFromCode(descriptor.scriptSetup?.content ?? descriptor.script?.content ?? "");
2216
+ if (inlineProps.size > 0) return inlineProps;
2221
2217
  const compiled = compileScript(descriptor, {
2222
2218
  id: filename,
2223
2219
  isProd: false
@@ -4859,9 +4855,8 @@ async function collectLayoutSyncState(ctx) {
4859
4855
  }
4860
4856
  else try {
4861
4857
  const source = await fs$1.readFile(full, "utf8");
4862
- const inlineProps = extractInlinePropsTypeFromCode(source);
4863
- if (inlineProps.size > 0) propMap = inlineProps;
4864
- else propMap = extractVueComponentProps(source, full, { astEngine: resolveAstEngine(configService.weappViteConfig) });
4858
+ if (ext === ".vue") propMap = extractVueComponentProps(source, full, { astEngine: resolveAstEngine(configService.weappViteConfig) });
4859
+ else propMap = extractInlinePropsTypeFromCode(source);
4865
4860
  } catch {
4866
4861
  propMap = /* @__PURE__ */ new Map();
4867
4862
  }
@@ -5615,7 +5610,7 @@ function createRegistryHelpers(state) {
5615
5610
  const [{ path: jsEntry }, { path: jsonPath }, { path: templatePath }] = await Promise.all([
5616
5611
  findJsEntry(baseName),
5617
5612
  findJsonEntry(baseName),
5618
- findTemplateEntry(baseName)
5613
+ findTemplateEntry(baseName, state.ctx.configService.platform)
5619
5614
  ]);
5620
5615
  let vueEntry = filePath.endsWith(".vue") ? filePath : void 0;
5621
5616
  if ((!jsEntry || !jsonPath || !templatePath) && !vueEntry) vueEntry = await findVueEntry(baseName);
@@ -6445,7 +6440,7 @@ const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
6445
6440
  ".turbo"
6446
6441
  ]);
6447
6442
  const SCRIPT_SIDECAR_PATTERN = /\.(?:wxs|sjs)\.[jt]s$/i;
6448
- const TEMPLATE_SIDECAR_PATTERN = /\.wxml\.[jt]s$/i;
6443
+ const TEMPLATE_SIDECAR_PATTERN = new RegExp(`\\.(?:${templateExtensions.join("|")})\\.[jt]s$`, "i");
6449
6444
  function isConfigFile(filePath) {
6450
6445
  return CONFIG_SUFFIXES.some((ext) => filePath.endsWith(ext));
6451
6446
  }
@@ -7312,7 +7307,7 @@ function matchesRouteFile(ctx, candidate) {
7312
7307
  if (isVueFile(resolvedPath.absolutePath) || isScriptFile(resolvedPath.absolutePath) || isTemplateFile(resolvedPath.absolutePath) || isStyleFile(resolvedPath.absolutePath)) return true;
7313
7308
  return false;
7314
7309
  }
7315
- async function rebuildCandidateForBase(base) {
7310
+ async function rebuildCandidateForBase(base, platform) {
7316
7311
  const files = /* @__PURE__ */ new Set();
7317
7312
  let hasScript = false;
7318
7313
  let hasTemplate = false;
@@ -7320,8 +7315,8 @@ async function rebuildCandidateForBase(base) {
7320
7315
  const [vueEntry, jsEntry, templateEntry, styleEntry, jsonEntry] = await Promise.all([
7321
7316
  findVueEntry(base),
7322
7317
  findJsEntry(base),
7323
- findTemplateEntry(base),
7324
- findCssEntry(base),
7318
+ findTemplateEntry(base, platform),
7319
+ findCssEntry(base, platform),
7325
7320
  findJsonEntry(base)
7326
7321
  ]);
7327
7322
  if (vueEntry) {
@@ -7382,7 +7377,7 @@ async function updateCandidateFromFile(ctx, stateCandidates, filePath, event, ma
7382
7377
  matchesInclude,
7383
7378
  hasCandidateEntry: stateCandidates.has(base)
7384
7379
  })) return stateCandidates.delete(base);
7385
- const candidate = await rebuildCandidateForBase(base);
7380
+ const candidate = await rebuildCandidateForBase(base, ctx.configService.platform);
7386
7381
  if (!candidate) return stateCandidates.delete(base);
7387
7382
  if (isAutoRoutesCandidateUnchanged(stateCandidates.get(base), candidate)) return false;
7388
7383
  stateCandidates.set(base, candidate);
@@ -9072,17 +9067,174 @@ function setCachedSharedChunkName(moduleId, value) {
9072
9067
  sharedChunkNameCache.set(moduleId, value ?? null);
9073
9068
  }
9074
9069
  //#endregion
9075
- //#region src/runtime/chunkStrategy/utils.ts
9076
- function replaceAll(source, searchValue, replaceValue) {
9077
- if (!searchValue) return source;
9078
- if (source.includes(searchValue)) return source.split(searchValue).join(replaceValue);
9079
- if (searchValue.startsWith("./") && replaceValue.startsWith("./")) {
9080
- const trimmedSearch = searchValue.slice(2);
9081
- const trimmedReplace = replaceValue.slice(2);
9082
- if (trimmedSearch && source.includes(trimmedSearch)) return source.split(trimmedSearch).join(trimmedReplace);
9070
+ //#region src/utils/sourcemap.ts
9071
+ function isEncodedSourceMapLike(value) {
9072
+ return Boolean(value && typeof value === "object" && "version" in value && typeof value.version === "number" && "mappings" in value && "names" in value && "sources" in value);
9073
+ }
9074
+ function normalizeEncodedSourceMapLike(value) {
9075
+ if (!value || typeof value !== "object") return null;
9076
+ const sourceMap = value;
9077
+ const numericVersion = typeof sourceMap.version === "number" ? sourceMap.version : typeof sourceMap.version === "string" ? Number(sourceMap.version) : NaN;
9078
+ if (!Number.isFinite(numericVersion)) return null;
9079
+ const normalized = {
9080
+ ...sourceMap,
9081
+ version: numericVersion
9082
+ };
9083
+ return isEncodedSourceMapLike(normalized) ? normalized : null;
9084
+ }
9085
+ function composeSourceMaps(transformedMap, originalMap) {
9086
+ if (isEncodedSourceMapLike(transformedMap) && isEncodedSourceMapLike(originalMap)) return remapping([transformedMap, originalMap], () => null);
9087
+ if (isEncodedSourceMapLike(transformedMap)) return transformedMap;
9088
+ if (isEncodedSourceMapLike(originalMap)) return originalMap;
9089
+ return null;
9090
+ }
9091
+ //#endregion
9092
+ //#region src/utils/outputChunk.ts
9093
+ const INLINE_SOURCE_MAP_RE = /\n?\/\/[#@]\s*sourceMappingURL=(data:application\/json\S*)\s*$/u;
9094
+ function resolveInlineSourceMap(code) {
9095
+ const match = INLINE_SOURCE_MAP_RE.exec(code);
9096
+ if (typeof match?.index !== "number") return null;
9097
+ const dataUrl = match[1];
9098
+ const commaIndex = dataUrl.indexOf(",");
9099
+ if (commaIndex < 0) return null;
9100
+ try {
9101
+ const metadata = dataUrl.slice(0, commaIndex);
9102
+ const payload = dataUrl.slice(commaIndex + 1);
9103
+ const json = metadata.includes(";base64") ? Buffer.from(payload, "base64").toString("utf8") : decodeURIComponent(payload);
9104
+ const map = normalizeEncodedSourceMapLike(JSON.parse(json));
9105
+ return map ? {
9106
+ code: code.slice(0, match.index),
9107
+ map,
9108
+ start: match.index
9109
+ } : null;
9110
+ } catch {
9111
+ return null;
9083
9112
  }
9084
- return source;
9085
9113
  }
9114
+ function appendInlineSourceMap(code, map) {
9115
+ return `${code}${code.endsWith("\n") ? "" : "\n"}//# sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map)).toString("base64")}`;
9116
+ }
9117
+ /**
9118
+ * 返回不含 inline sourcemap 数据 URI 的实际脚本,供 AST 转换使用。
9119
+ */
9120
+ function resolveOutputChunkTransformCode(chunk) {
9121
+ return resolveInlineSourceMap(chunk.code)?.code ?? chunk.code;
9122
+ }
9123
+ /**
9124
+ * 应用 MagicString 改写,并把本轮映射与 chunk 既有映射组合。
9125
+ */
9126
+ function applyMagicStringChunkRewrite(chunk, magicString, options) {
9127
+ const previousCode = chunk.code;
9128
+ const inlineSourceMap = resolveInlineSourceMap(previousCode);
9129
+ if (inlineSourceMap) magicString.remove(inlineSourceMap.start, previousCode.length);
9130
+ const nextCode = magicString.toString();
9131
+ if (nextCode === (inlineSourceMap?.code ?? previousCode)) return false;
9132
+ const previousMap = normalizeEncodedSourceMapLike(chunk.map) ?? inlineSourceMap?.map;
9133
+ if (previousMap) {
9134
+ const composedMap = composeSourceMaps(magicString.generateMap({
9135
+ hires: options?.hires ?? "boundary",
9136
+ includeContent: true,
9137
+ source: chunk.fileName
9138
+ }), previousMap);
9139
+ chunk.map = composedMap;
9140
+ chunk.code = inlineSourceMap && composedMap ? appendInlineSourceMap(nextCode, composedMap) : nextCode;
9141
+ } else chunk.code = nextCode;
9142
+ return true;
9143
+ }
9144
+ /**
9145
+ * 在 chunk 当前代码上执行一次可追踪编辑。
9146
+ */
9147
+ function editOutputChunkCode(chunk, edit, options) {
9148
+ const code = chunk.code;
9149
+ const magicString = new MagicString(code);
9150
+ edit(magicString, code);
9151
+ return applyMagicStringChunkRewrite(chunk, magicString, options);
9152
+ }
9153
+ /**
9154
+ * 在 chunk 前方插入无源代码,同时保留原代码映射。
9155
+ */
9156
+ function prependOutputChunkCode(chunk, code) {
9157
+ if (!code) return false;
9158
+ return editOutputChunkCode(chunk, (magicString) => magicString.prepend(code));
9159
+ }
9160
+ /**
9161
+ * 在 chunk 后方插入无源代码,同时保留原代码映射。
9162
+ */
9163
+ function appendOutputChunkCode(chunk, code) {
9164
+ if (!code) return false;
9165
+ return editOutputChunkCode(chunk, (magicString) => magicString.append(code));
9166
+ }
9167
+ /**
9168
+ * 按原始代码坐标批量替换互不重叠的区间。
9169
+ */
9170
+ function replaceOutputChunkCodeRanges(chunk, replacements) {
9171
+ if (replacements.length === 0) return false;
9172
+ const sorted = [...replacements].sort((left, right) => left.start - right.start);
9173
+ let previousEnd = -1;
9174
+ for (const replacement of sorted) {
9175
+ if (replacement.start < 0 || replacement.end < replacement.start || replacement.end > chunk.code.length || replacement.start < previousEnd) throw new RangeError(`Invalid or overlapping output chunk replacement: ${replacement.start}-${replacement.end}`);
9176
+ previousEnd = replacement.end;
9177
+ }
9178
+ return editOutputChunkCode(chunk, (magicString) => {
9179
+ for (const replacement of sorted) magicString.overwrite(replacement.start, replacement.end, replacement.content);
9180
+ });
9181
+ }
9182
+ /**
9183
+ * 使用正则匹配的原始坐标改写 chunk,避免整段字符串替换破坏映射。
9184
+ */
9185
+ function replaceOutputChunkCode(chunk, pattern, replace) {
9186
+ const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
9187
+ const matcher = new RegExp(pattern.source, flags);
9188
+ const replacements = [];
9189
+ for (const match of chunk.code.matchAll(matcher)) {
9190
+ if (typeof match.index !== "number") continue;
9191
+ const content = replace(match);
9192
+ if (content == null || content === match[0]) continue;
9193
+ replacements.push({
9194
+ content,
9195
+ end: match.index + match[0].length,
9196
+ start: match.index
9197
+ });
9198
+ }
9199
+ return replaceOutputChunkCodeRanges(chunk, replacements);
9200
+ }
9201
+ /**
9202
+ * 应用自带映射的完整代码转换,并组合 chunk 既有映射。
9203
+ */
9204
+ function applyOutputChunkTransform(chunk, code, map) {
9205
+ const previousInlineSourceMap = resolveInlineSourceMap(chunk.code);
9206
+ const transformedInlineSourceMap = resolveInlineSourceMap(code);
9207
+ const previousCode = previousInlineSourceMap?.code ?? chunk.code;
9208
+ const transformedCode = transformedInlineSourceMap?.code ?? code;
9209
+ if (transformedCode === previousCode) return false;
9210
+ const previousMap = normalizeEncodedSourceMapLike(chunk.map) ?? previousInlineSourceMap?.map;
9211
+ const transformedMap = normalizeEncodedSourceMapLike(map);
9212
+ if (previousMap && !transformedMap) throw new Error(`Output chunk transform for ${chunk.fileName} must provide a source map`);
9213
+ if (previousMap && transformedMap) {
9214
+ const composedMap = composeSourceMaps(transformedMap, previousMap);
9215
+ chunk.map = composedMap;
9216
+ chunk.code = previousInlineSourceMap && composedMap ? appendInlineSourceMap(transformedCode, composedMap) : transformedCode;
9217
+ } else chunk.code = transformedCode;
9218
+ return true;
9219
+ }
9220
+ /**
9221
+ * 将 generateBundle 阶段组合后的 chunk map 提交到 Rolldown 管理的 map asset。
9222
+ */
9223
+ function syncOutputChunkSourceMapAssets(bundle) {
9224
+ let synced = 0;
9225
+ for (const output of Object.values(bundle)) {
9226
+ if (output?.type !== "chunk") continue;
9227
+ const map = normalizeEncodedSourceMapLike(output.map);
9228
+ if (!map) continue;
9229
+ const mapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
9230
+ if (!mapAsset || mapAsset.type !== "asset") continue;
9231
+ mapAsset.source = JSON.stringify(map);
9232
+ synced += 1;
9233
+ }
9234
+ return synced;
9235
+ }
9236
+ //#endregion
9237
+ //#region src/runtime/chunkStrategy/utils.ts
9086
9238
  function createRelativeImport(fromFile, toFile) {
9087
9239
  const relative = posix.relative(posix.dirname(fromFile), toFile);
9088
9240
  if (!relative || relative.startsWith(".")) return relative || "./";
@@ -9090,6 +9242,20 @@ function createRelativeImport(fromFile, toFile) {
9090
9242
  }
9091
9243
  //#endregion
9092
9244
  //#region src/runtime/chunkStrategy/bundle.ts
9245
+ function escapeRegExp$2(value) {
9246
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9247
+ }
9248
+ function replaceChunkCodeAll(chunk, searchValue, replaceValue) {
9249
+ if (!searchValue) return false;
9250
+ const replaceExact = () => replaceOutputChunkCode(chunk, new RegExp(escapeRegExp$2(searchValue), "g"), () => replaceValue);
9251
+ if (chunk.code.includes(searchValue)) return replaceExact();
9252
+ if (searchValue.startsWith("./") && replaceValue.startsWith("./")) {
9253
+ const trimmedSearch = searchValue.slice(2);
9254
+ const trimmedReplace = replaceValue.slice(2);
9255
+ if (trimmedSearch && chunk.code.includes(trimmedSearch)) return replaceOutputChunkCode(chunk, new RegExp(escapeRegExp$2(trimmedSearch), "g"), () => trimmedReplace);
9256
+ }
9257
+ return false;
9258
+ }
9093
9259
  function addDirectImporter(directImporters, imported, importer) {
9094
9260
  if (typeof imported !== "string" || !imported || imported === importer) return;
9095
9261
  let importers = directImporters.get(imported);
@@ -9351,11 +9517,7 @@ function updateImporters(bundle, importerToChunk, originalFileName, index) {
9351
9517
  for (const originalFileName of originalFileNames) {
9352
9518
  const originalImportPath = createRelativeImport(importerFile, originalFileName);
9353
9519
  if (originalImportPath === newImportPath) continue;
9354
- const updated = replaceAll(importerChunk.code, originalImportPath, newImportPath);
9355
- if (updated !== importerChunk.code) {
9356
- importerChunk.code = updated;
9357
- codeUpdated = true;
9358
- }
9520
+ codeUpdated = replaceChunkCodeAll(importerChunk, originalImportPath, newImportPath) || codeUpdated;
9359
9521
  }
9360
9522
  importerChunk.imports = replaceInArray(importerChunk.imports, originalFileNames, newChunkFile, codeUpdated);
9361
9523
  importerChunk.dynamicImports = replaceInArray(importerChunk.dynamicImports, originalFileNames, newChunkFile, codeUpdated);
@@ -9531,6 +9693,17 @@ function resolveSourceMapSource(originalMap, assetSource) {
9531
9693
  }
9532
9694
  if (isSourceLike(assetSource)) return cloneSourceLike(assetSource);
9533
9695
  }
9696
+ function resolveEncodedSourceMap(originalMap, assetSource) {
9697
+ const chunkMap = normalizeEncodedSourceMapLike(originalMap);
9698
+ if (chunkMap) return chunkMap;
9699
+ if (!isSourceLike(assetSource)) return null;
9700
+ try {
9701
+ const source = typeof assetSource === "string" ? assetSource : Buffer.from(assetSource).toString("utf8");
9702
+ return normalizeEncodedSourceMapLike(JSON.parse(source));
9703
+ } catch {
9704
+ return null;
9705
+ }
9706
+ }
9534
9707
  function emitSourceMapAsset(ctx, targetFileName, sourceMapAssetInfo, fallbackSource) {
9535
9708
  if (!targetFileName) return;
9536
9709
  if (sourceMapAssetInfo?.asset && isSourceLike(sourceMapAssetInfo.asset.source)) {
@@ -9688,29 +9861,39 @@ function reserveUniqueFileName(reservedFileNames, fileName) {
9688
9861
  reservedFileNames.add(candidate);
9689
9862
  return candidate;
9690
9863
  }
9691
- function rewriteChunkImportSpecifiersInCode(sourceCode, options) {
9864
+ function createChunkImportSpecifiersRewrite(sourceCode, options) {
9692
9865
  const { sourceFileName, sourceFileNames, targetFileName, imports, dynamicImports, runtimeFileName, resolveImportTarget } = options;
9693
9866
  const sourceFileNameCandidates = (sourceFileNames ?? [sourceFileName ?? ""]).filter(Boolean);
9694
9867
  const specifiers = new Set([...imports, ...dynamicImports].filter(Boolean));
9695
- let rewrittenCode = sourceCode;
9868
+ const magicString = new MagicString(sourceCode);
9869
+ const rewrittenRanges = /* @__PURE__ */ new Set();
9696
9870
  for (const specifier of specifiers) {
9697
9871
  const targetImportPath = createRelativeImportPath(targetFileName, posix.basename(specifier) === ROLLDOWN_RUNTIME_FILE_NAME$1 ? runtimeFileName : resolveImportTarget?.(specifier) ?? specifier);
9698
9872
  if (!targetImportPath) continue;
9699
9873
  for (const sourceCandidate of sourceFileNameCandidates) {
9700
9874
  const sourceImportPath = createRelativeImportPath(sourceCandidate, specifier);
9701
9875
  if (!sourceImportPath || sourceImportPath === targetImportPath) continue;
9702
- rewrittenCode = replaceQuotedImportLiteralValue(rewrittenCode, sourceImportPath, targetImportPath);
9876
+ replaceQuotedImportLiteralValue(magicString, sourceCode, sourceImportPath, targetImportPath, rewrittenRanges);
9703
9877
  }
9704
9878
  }
9705
- return rewrittenCode;
9879
+ return magicString;
9706
9880
  }
9707
9881
  function resolveChunkSourceFileNameForRewrite(fileName) {
9708
9882
  if (!fileName.startsWith(`weapp_shared_virtual/`)) return fileName;
9709
9883
  return fileName.slice(21);
9710
9884
  }
9711
- function replaceQuotedImportLiteralValue(sourceCode, sourcePath, targetPath) {
9885
+ function replaceQuotedImportLiteralValue(magicString, sourceCode, sourcePath, targetPath, rewrittenRanges) {
9712
9886
  const escapedSourcePath = escapeRegExpForPattern(sourcePath);
9713
- return sourceCode.replace(new RegExp(`(['"\`])${escapedSourcePath}\\1`, "g"), (_match, quote) => `${quote}${targetPath}${quote}`);
9887
+ const pattern = new RegExp(`(['"\`])${escapedSourcePath}\\1`, "g");
9888
+ for (const match of sourceCode.matchAll(pattern)) {
9889
+ if (typeof match.index !== "number") continue;
9890
+ const end = match.index + match[0].length;
9891
+ const rangeKey = `${match.index}:${end}`;
9892
+ if (rewrittenRanges.has(rangeKey)) continue;
9893
+ const quote = match[1];
9894
+ magicString.overwrite(match.index, end, `${quote}${targetPath}${quote}`);
9895
+ rewrittenRanges.add(rangeKey);
9896
+ }
9714
9897
  }
9715
9898
  function escapeRegExpForPattern(value) {
9716
9899
  return value.replace(REGEXP_ESCAPE_PATTERN, "\\$&");
@@ -9749,7 +9932,13 @@ function ensureLocalizedDuplicate(args) {
9749
9932
  }
9750
9933
  function rewriteDuplicatedChunkSource(args) {
9751
9934
  const runtimeFileName = posix.join(args.root, ROLLDOWN_RUNTIME_FILE_NAME);
9752
- let rewrittenSource = rewriteChunkImportSpecifiersInCode(args.chunk.code ?? "", {
9935
+ const sourceMapKeys = collectSourceMapKeys(args.sourceFileName, args.chunk);
9936
+ const sourceMapAssetInfo = findSourceMapAsset(args.runtimeContext.bundle, sourceMapKeys);
9937
+ const rewrittenChunk = {
9938
+ ...args.chunk,
9939
+ map: resolveEncodedSourceMap(args.chunk.map, sourceMapAssetInfo?.asset.source)
9940
+ };
9941
+ applyMagicStringChunkRewrite(rewrittenChunk, createChunkImportSpecifiersRewrite(rewrittenChunk.code ?? "", {
9753
9942
  sourceFileNames: createChunkSourceFileNameCandidates(args.sourceFileName),
9754
9943
  targetFileName: args.targetFileName,
9755
9944
  imports: args.chunk.imports,
@@ -9763,7 +9952,7 @@ function rewriteDuplicatedChunkSource(args) {
9763
9952
  sourceFileName: specifier
9764
9953
  });
9765
9954
  }
9766
- });
9955
+ }));
9767
9956
  for (const specifier of [...args.chunk.imports, ...args.chunk.dynamicImports]) {
9768
9957
  const localizedSpecifier = ensureLocalizedDuplicate({
9769
9958
  runtimeContext: args.runtimeContext,
@@ -9772,20 +9961,20 @@ function rewriteDuplicatedChunkSource(args) {
9772
9961
  sourceFileName: specifier
9773
9962
  });
9774
9963
  if (!localizedSpecifier || localizedSpecifier === specifier) continue;
9775
- rewrittenSource = rewriteChunkImportSpecifiersInCode(rewrittenSource, {
9964
+ applyMagicStringChunkRewrite(rewrittenChunk, createChunkImportSpecifiersRewrite(rewrittenChunk.code, {
9776
9965
  sourceFileName: args.targetFileName,
9777
9966
  targetFileName: args.targetFileName,
9778
9967
  imports: [specifier],
9779
9968
  dynamicImports: [],
9780
9969
  runtimeFileName,
9781
9970
  resolveImportTarget: () => localizedSpecifier
9782
- });
9971
+ }));
9783
9972
  }
9784
- return rewrittenSource;
9973
+ return rewrittenChunk;
9785
9974
  }
9786
9975
  function emitDuplicatedChunkAsset(args) {
9787
9976
  if (args.emittedLocalizedDuplicateFiles.has(args.targetFileName)) return;
9788
- const duplicatedSource = rewriteDuplicatedChunkSource({
9977
+ const duplicatedChunk = rewriteDuplicatedChunkSource({
9789
9978
  runtimeContext: args.runtimeContext,
9790
9979
  pendingLocalizedDuplicates: args.pendingLocalizedDuplicates,
9791
9980
  root: args.root,
@@ -9796,17 +9985,24 @@ function emitDuplicatedChunkAsset(args) {
9796
9985
  args.runtimeContext.pluginContext.emitFile({
9797
9986
  type: "asset",
9798
9987
  fileName: args.targetFileName,
9799
- source: duplicatedSource
9988
+ source: duplicatedChunk.code
9800
9989
  });
9801
9990
  const sourceMapKeys = collectSourceMapKeys(args.sourceFileName, args.chunk);
9802
9991
  const sourceMapAssetInfo = findSourceMapAsset(args.runtimeContext.bundle, sourceMapKeys);
9803
- const resolvedSourceMap = resolveSourceMapSource(args.chunk.map, sourceMapAssetInfo?.asset.source);
9804
- if (resolvedSourceMap) {
9992
+ const unchangedSourceMap = duplicatedChunk.code === args.chunk.code ? resolveSourceMapSource(args.chunk.map, sourceMapAssetInfo?.asset.source) : void 0;
9993
+ if (duplicatedChunk.map) {
9994
+ const sourceMapFileName = reserveUniqueFileName(args.runtimeContext.reservedFileNames, `${args.targetFileName}.map`);
9995
+ args.runtimeContext.pluginContext.emitFile({
9996
+ type: "asset",
9997
+ fileName: sourceMapFileName,
9998
+ source: JSON.stringify(duplicatedChunk.map)
9999
+ });
10000
+ } else if (unchangedSourceMap) {
9805
10001
  const sourceMapFileName = reserveUniqueFileName(args.runtimeContext.reservedFileNames, `${args.targetFileName}.map`);
9806
10002
  args.runtimeContext.pluginContext.emitFile({
9807
10003
  type: "asset",
9808
10004
  fileName: sourceMapFileName,
9809
- source: cloneSourceLike(resolvedSourceMap)
10005
+ source: cloneSourceLike(unchangedSourceMap)
9810
10006
  });
9811
10007
  }
9812
10008
  args.emittedLocalizedDuplicateFiles.add(args.targetFileName);
@@ -9845,7 +10041,7 @@ function localizeCrossSubPackageChunkLeaks(bundle, options) {
9845
10041
  if (crossRootImporters.size === 0) continue;
9846
10042
  const chunk = output;
9847
10043
  const sourceMapAssetInfo = findSourceMapAsset(bundle, collectSourceMapKeys(fileName, chunk));
9848
- const resolvedSourceMap = resolveSourceMapSource(chunk.map, sourceMapAssetInfo?.asset.source);
10044
+ const resolvedSourceMap = resolveEncodedSourceMap(chunk.map, sourceMapAssetInfo?.asset.source);
9849
10045
  const importerToChunk = /* @__PURE__ */ new Map();
9850
10046
  const duplicates = [];
9851
10047
  for (const [targetRoot, importerFiles] of crossRootImporters.entries()) {
@@ -9860,25 +10056,39 @@ function localizeCrossSubPackageChunkLeaks(bundle, options) {
9860
10056
  })();
9861
10057
  const runtimeFileName = posix.join(targetRoot, ROLLDOWN_RUNTIME_FILE_NAME);
9862
10058
  if (!existingDuplicateFileName) {
9863
- const duplicatedSource = rewriteChunkImportSpecifiersInCode(chunk.code ?? "", {
10059
+ const duplicatedChunk = {
10060
+ ...chunk,
10061
+ map: resolvedSourceMap
10062
+ };
10063
+ applyMagicStringChunkRewrite(duplicatedChunk, createChunkImportSpecifiersRewrite(duplicatedChunk.code ?? "", {
9864
10064
  sourceFileName: fileName,
9865
10065
  targetFileName: uniqueFileName,
9866
10066
  imports: chunk.imports,
9867
10067
  dynamicImports: chunk.dynamicImports,
9868
10068
  runtimeFileName
9869
- });
10069
+ }));
9870
10070
  this.emitFile({
9871
10071
  type: "asset",
9872
10072
  fileName: uniqueFileName,
9873
- source: duplicatedSource
10073
+ source: duplicatedChunk.code
9874
10074
  });
9875
- if (resolvedSourceMap) {
10075
+ if (duplicatedChunk.map) {
9876
10076
  const sourceMapFileName = reserveUniqueFileName(reservedFileNames, `${uniqueFileName}.map`);
9877
10077
  this.emitFile({
9878
10078
  type: "asset",
9879
10079
  fileName: sourceMapFileName,
9880
- source: cloneSourceLike(resolvedSourceMap)
10080
+ source: JSON.stringify(duplicatedChunk.map)
9881
10081
  });
10082
+ } else if (duplicatedChunk.code === chunk.code) {
10083
+ const unchangedSourceMap = resolveSourceMapSource(chunk.map, sourceMapAssetInfo?.asset.source);
10084
+ if (unchangedSourceMap) {
10085
+ const sourceMapFileName = reserveUniqueFileName(reservedFileNames, `${uniqueFileName}.map`);
10086
+ this.emitFile({
10087
+ type: "asset",
10088
+ fileName: sourceMapFileName,
10089
+ source: cloneSourceLike(unchangedSourceMap)
10090
+ });
10091
+ }
9882
10092
  }
9883
10093
  }
9884
10094
  for (const importerFile of importerFiles) importerToChunk.set(importerFile, uniqueFileName);
@@ -9928,12 +10138,12 @@ function applySharedChunkStrategy(bundle, options) {
9928
10138
  if (!isSharedVirtualChunk(fileName, output)) continue;
9929
10139
  const originalSharedFileName = fileName;
9930
10140
  const chunk = output;
9931
- const originalMap = chunk.map;
9932
10141
  const importers = findChunkImporters(bundle, fileName, importerIndex);
9933
10142
  if (importers.length === 0) continue;
9934
10143
  const sourceMapKeys = collectSourceMapKeys(fileName, chunk);
9935
10144
  const sourceMapAssetInfo = findSourceMapAsset(bundle, sourceMapKeys);
9936
- const resolvedSourceMap = resolveSourceMapSource(originalMap, sourceMapAssetInfo?.asset.source);
10145
+ const resolvedSourceMap = resolveEncodedSourceMap(chunk.map, sourceMapAssetInfo?.asset.source);
10146
+ if (resolvedSourceMap) chunk.map = resolvedSourceMap;
9937
10147
  const importerMap = /* @__PURE__ */ new Map();
9938
10148
  const mainImporters = [];
9939
10149
  let hasMainImporter = false;
@@ -9962,17 +10172,17 @@ function applySharedChunkStrategy(bundle, options) {
9962
10172
  let finalFileName = chunk.fileName;
9963
10173
  if (fileName.startsWith(`weapp_shared_virtual/`)) {
9964
10174
  const newFileName = fileName.slice(21);
9965
- chunk.code = rewriteChunkImportSpecifiersInCode(chunk.code ?? "", {
10175
+ const codeRewritten = applyMagicStringChunkRewrite(chunk, createChunkImportSpecifiersRewrite(chunk.code ?? "", {
9966
10176
  sourceFileNames: createChunkSourceFileNameCandidates(fileName),
9967
10177
  targetFileName: newFileName,
9968
10178
  imports: chunk.imports,
9969
10179
  dynamicImports: chunk.dynamicImports,
9970
10180
  runtimeFileName: ROLLDOWN_RUNTIME_FILE_NAME
9971
- });
10181
+ }));
9972
10182
  chunk.fileName = newFileName;
9973
10183
  if (typeof chunk.sourcemapFileName === "string" && chunk.sourcemapFileName) chunk.sourcemapFileName = `${newFileName}.map`;
9974
10184
  const targetKey = `${newFileName}.map`;
9975
- emitSourceMapAsset(this, targetKey, sourceMapAssetInfo, resolvedSourceMap);
10185
+ emitSourceMapAsset(this, targetKey, codeRewritten ? void 0 : sourceMapAssetInfo, resolveSourceMapSource(chunk.map, void 0));
9976
10186
  for (const mapKey of sourceMapKeys) {
9977
10187
  if (!mapKey || mapKey === targetKey) continue;
9978
10188
  if (bundle[mapKey]) delete bundle[mapKey];
@@ -9994,17 +10204,17 @@ function applySharedChunkStrategy(bundle, options) {
9994
10204
  }
9995
10205
  if (shouldRetainOriginalChunk && fileName.startsWith(`weapp_shared_virtual/`)) {
9996
10206
  const newFileName = fileName.slice(21);
9997
- chunk.code = rewriteChunkImportSpecifiersInCode(chunk.code ?? "", {
10207
+ const codeRewritten = applyMagicStringChunkRewrite(chunk, createChunkImportSpecifiersRewrite(chunk.code ?? "", {
9998
10208
  sourceFileNames: createChunkSourceFileNameCandidates(fileName),
9999
10209
  targetFileName: newFileName,
10000
10210
  imports: chunk.imports,
10001
10211
  dynamicImports: chunk.dynamicImports,
10002
10212
  runtimeFileName: ROLLDOWN_RUNTIME_FILE_NAME
10003
- });
10213
+ }));
10004
10214
  chunk.fileName = newFileName;
10005
10215
  if (typeof chunk.sourcemapFileName === "string" && chunk.sourcemapFileName) chunk.sourcemapFileName = `${newFileName}.map`;
10006
10216
  const targetKey = `${newFileName}.map`;
10007
- emitSourceMapAsset(this, targetKey, sourceMapAssetInfo, resolvedSourceMap);
10217
+ emitSourceMapAsset(this, targetKey, codeRewritten ? void 0 : sourceMapAssetInfo, resolveSourceMapSource(chunk.map, void 0));
10008
10218
  for (const mapKey of sourceMapKeys) {
10009
10219
  if (!mapKey || mapKey === targetKey) continue;
10010
10220
  if (bundle[mapKey]) delete bundle[mapKey];
@@ -10639,6 +10849,7 @@ class WeappViteDevRuntime extends BaseDevRuntime {
10639
10849
  createModuleHotContext(moduleId) {
10640
10850
  const previous = this.contexts.get(moduleId);
10641
10851
  const context = new WeappViteHotContext(moduleId);
10852
+ this.registrationModuleId = moduleId;
10642
10853
  if (previous) {
10643
10854
  context.callbacks = previous.callbacks;
10644
10855
  context.data = previous.data;
@@ -10734,6 +10945,10 @@ function rememberInstanceState(instance, moduleId) {
10734
10945
  function trackInstance(instance, moduleId) {
10735
10946
  getInstances(moduleId).add(instance);
10736
10947
  if (instanceSnapshots.has(instance)) return;
10948
+ if ((wevuRefreshGenerations.get(moduleId) || 0) > 0) {
10949
+ rememberInstanceState(instance, moduleId);
10950
+ return;
10951
+ }
10737
10952
  const snapshot = moduleSnapshots.get(moduleId);
10738
10953
  if (snapshot) {
10739
10954
  instanceSnapshots.set(instance, snapshot);
@@ -10761,7 +10976,11 @@ function rememberTrackedInstances() {
10761
10976
  }
10762
10977
  function restoreTrackedInstances() {
10763
10978
  for (const [moduleId, values] of instances) {
10764
- for (const instance of values) restoreInstanceState(instance, moduleId);
10979
+ for (const instance of values) {
10980
+ const generation = wevuRefreshGenerations.get(moduleId) || 0;
10981
+ if (generation > 0 && wevuInstanceGenerations.get(instance)?.get(moduleId) === generation) continue;
10982
+ restoreInstanceState(instance, moduleId);
10983
+ }
10765
10984
  }
10766
10985
  }
10767
10986
  function refreshWevuInstance(instance, moduleId) {
@@ -10836,63 +11055,81 @@ function decorateObject(value, moduleId, prefix = '', trackLifecycle = false) {
10836
11055
  }
10837
11056
  function decorateWevuComponent(definition, moduleId) {
10838
11057
  const result = { ...definition };
11058
+ const resolveWevuDefinition = () => definitions.get(moduleId) || definition;
11059
+ const callLatestWevuFunction = (instance, path, fallback, args) => {
11060
+ const segments = path.split('.');
11061
+ let value = resolveWevuDefinition();
11062
+ for (const segment of segments) value = value && value[segment];
11063
+ return (typeof value === 'function' ? value : fallback)?.apply(instance, args);
11064
+ };
10839
11065
  const methods = { ...(definition.methods || {}) };
10840
- for (const [name, method] of Object.entries(methods)) {
10841
- if (typeof method !== 'function') continue;
11066
+ for (const name of Object.keys(methods)) {
11067
+ const fallback = methods[name];
11068
+ if (typeof fallback !== 'function') continue;
10842
11069
  methods[name] = function (...args) {
10843
11070
  trackInstance(this, moduleId);
10844
11071
  refreshWevuInstance(this, moduleId);
10845
11072
  try {
10846
- return method.apply(this, args);
11073
+ return callLatestWevuFunction(this, 'methods.' + name, fallback, args);
10847
11074
  } finally {
10848
11075
  rememberInstanceState(this, moduleId);
10849
11076
  }
10850
11077
  };
10851
11078
  }
10852
11079
  result.methods = methods;
10853
- const onLoad = definition.onLoad;
10854
- const onUnload = definition.onUnload;
10855
- if (typeof onLoad === 'function') {
10856
- result.onLoad = function (...args) {
11080
+ const pageHookNames = ['onLoad', 'onShow', 'onReady', 'onHide', 'onResize', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites'];
11081
+ for (const name of pageHookNames) {
11082
+ const fallback = result[name];
11083
+ if (typeof fallback !== 'function') continue;
11084
+ result[name] = function (...args) {
10857
11085
  trackInstance(this, moduleId);
10858
11086
  refreshWevuInstance(this, moduleId);
10859
- if (suppressLifecycles) return;
10860
- return onLoad.apply(this, args);
11087
+ if (suppressLifecycles && /^(?:onLoad|onShow|onHide|onUnload)$/.test(name)) return;
11088
+ try {
11089
+ return callLatestWevuFunction(this, name, fallback, args);
11090
+ } finally {
11091
+ rememberInstanceState(this, moduleId);
11092
+ if (name === 'onUnload') forgetInstance(this, moduleId);
11093
+ }
10861
11094
  };
10862
11095
  }
10863
- if (typeof onUnload === 'function') {
10864
- result.onUnload = function (...args) {
11096
+ const lifetimes = { ...(definition.lifetimes || {}) };
11097
+ for (const name of Object.keys(lifetimes)) {
11098
+ const fallback = lifetimes[name];
11099
+ if (typeof fallback !== 'function') continue;
11100
+ lifetimes[name] = function (...args) {
10865
11101
  if (suppressLifecycles) return;
11102
+ if (name === 'created' || name === 'attached') {
11103
+ trackInstance(this, moduleId);
11104
+ refreshWevuInstance(this, moduleId);
11105
+ }
10866
11106
  try {
10867
- return onUnload.apply(this, args);
11107
+ return callLatestWevuFunction(this, 'lifetimes.' + name, fallback, args);
10868
11108
  } finally {
10869
- forgetInstance(this, moduleId);
11109
+ if (name === 'detached') forgetInstance(this, moduleId);
10870
11110
  }
10871
11111
  };
10872
11112
  }
10873
- const lifetimes = { ...(definition.lifetimes || {}) };
10874
- const attached = lifetimes.attached;
10875
- const detached = lifetimes.detached;
10876
- lifetimes.attached = function (...args) {
10877
- trackInstance(this, moduleId);
10878
- refreshWevuInstance(this, moduleId);
10879
- if (suppressLifecycles) return;
10880
- return attached?.apply(this, args);
10881
- };
10882
- lifetimes.detached = function (...args) {
10883
- if (suppressLifecycles) return;
10884
- try {
10885
- return detached?.apply(this, args);
10886
- } finally {
10887
- forgetInstance(this, moduleId);
10888
- }
10889
- };
10890
- return { ...result, lifetimes };
11113
+ const pageLifetimes = { ...(definition.pageLifetimes || {}) };
11114
+ for (const name of Object.keys(pageLifetimes)) {
11115
+ const fallback = pageLifetimes[name];
11116
+ if (typeof fallback !== 'function') continue;
11117
+ pageLifetimes[name] = function (...args) {
11118
+ trackInstance(this, moduleId);
11119
+ refreshWevuInstance(this, moduleId);
11120
+ try {
11121
+ return callLatestWevuFunction(this, 'pageLifetimes.' + name, fallback, args);
11122
+ } finally {
11123
+ rememberInstanceState(this, moduleId);
11124
+ }
11125
+ };
11126
+ }
11127
+ return { ...result, lifetimes, pageLifetimes };
10891
11128
  }
10892
11129
  function registerDefinition(name, definition, nativeRegistration) {
10893
11130
  const moduleId = runtime.currentModuleId || runtime.registrationModuleId || name;
10894
11131
  if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) return;
10895
- definitions.set(moduleId, definition);
11132
+ if (!wevuRefreshes.has(moduleId)) definitions.set(moduleId, definition);
10896
11133
  if (registered.has(moduleId)) {
10897
11134
  return;
10898
11135
  }
@@ -10921,8 +11158,17 @@ globalThis[bridgeKey] = {
10921
11158
  return pending;
10922
11159
  },
10923
11160
  isApplying() { return runtime.applyingPatch; },
11161
+ getDebugSnapshot() {
11162
+ return {
11163
+ definitions: [...definitions.keys()],
11164
+ instances: [...instances.entries()].map(([moduleId, values]) => ({ moduleId, count: values.size })),
11165
+ registered: [...registered.values()],
11166
+ refreshes: [...wevuRefreshes.keys()],
11167
+ refreshGenerations: [...wevuRefreshGenerations.entries()],
11168
+ };
11169
+ },
10924
11170
  trackWevuComponent(definition, refresh) {
10925
- const moduleId = runtime.registrationModuleId || runtime.currentModuleId || 'Component';
11171
+ const moduleId = runtime.currentModuleId || runtime.registrationModuleId || 'Component';
10926
11172
  if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) {
10927
11173
  return decorateWevuComponent(definition, moduleId);
10928
11174
  }
@@ -10947,6 +11193,8 @@ globalThis[bridgeKey] = {
10947
11193
  setTimeout(() => { suppressLifecycles = false; });
10948
11194
  }
10949
11195
  };
11196
+ const runtimeGlobal = globalThis.wx || globalThis.my || globalThis.swan || globalThis.tt || globalThis.ali || globalThis.hd || globalThis.qq || globalThis.ks || globalThis.zfb || globalThis.jd || globalThis.xhs;
11197
+ if (runtimeGlobal && !runtimeGlobal[bridgeKey]) runtimeGlobal[bridgeKey] = globalThis[bridgeKey];
10950
11198
  `;
10951
11199
  function createStatefulHmrControlSource(control) {
10952
11200
  return `
@@ -12269,6 +12517,7 @@ function createStatefulHmrBanner(chunk) {
12269
12517
  return [
12270
12518
  `require(${JSON.stringify(`${prefix}rolldown-runtime.js`)});`,
12271
12519
  `globalThis[${JSON.stringify(WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY)}].installNative('Page', definition => Page(definition));`,
12520
+ `globalThis[${JSON.stringify(WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY)}].installNative('Component', definition => Component(definition));`,
12272
12521
  `require(${JSON.stringify(`${prefix}${WEAPP_VITE_STATEFUL_HMR_PRELOAD_FILE}`)});`,
12273
12522
  `require(${JSON.stringify(`${prefix}${WEAPP_VITE_STATEFUL_HMR_UPDATE_FILE}`)});`
12274
12523
  ].join("");
@@ -13105,8 +13354,8 @@ async function collectMiniappConfigFile(pluginCtx, id, configService, jsonServic
13105
13354
  type: "page"
13106
13355
  });
13107
13356
  }
13108
- async function ensureTemplateScanned(pluginCtx, id, scanTemplateEntry, existsCache, ttlMs) {
13109
- const { path: templateEntry, predictions } = await findTemplateEntry(id);
13357
+ async function ensureTemplateScanned(pluginCtx, id, scanTemplateEntry, existsCache, ttlMs, platform) {
13358
+ const { path: templateEntry, predictions } = await findTemplateEntry(id, platform);
13110
13359
  await addPredictedWatchTargets(pluginCtx, predictions, existsCache, ttlMs, templateEntry);
13111
13360
  if (!templateEntry) return "";
13112
13361
  await scanTemplateEntry(templateEntry);
@@ -13160,8 +13409,8 @@ function collectVueTemplateAutoImportTags(template, filename) {
13160
13409
  function collectScriptSetupImports(scriptSetup, templateComponentNames, options) {
13161
13410
  return collectScriptSetupImportsFromCode(scriptSetup, templateComponentNames, options);
13162
13411
  }
13163
- async function scanTemplateEntry(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs) {
13164
- return ensureTemplateScanned(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs);
13412
+ async function scanTemplateEntry(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs, platform) {
13413
+ return ensureTemplateScanned(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs, platform);
13165
13414
  }
13166
13415
  async function applyScriptSetupUsingComponents(options) {
13167
13416
  const { pluginCtx, vueEntryPath, source, templatePath, json, configService, wxmlService, reExportResolutionCache, externalComponentEntryMap } = options;
@@ -13379,6 +13628,7 @@ function normalizeWxsFilename(value, extension = "wxs") {
13379
13628
  function transformWxsCode(code, options) {
13380
13629
  const filename = options?.filename ?? "script.ts";
13381
13630
  const extension = options?.extension ?? "wxs";
13631
+ const preserveEsmExports = extension.replace(/^\./, "") === "sjs";
13382
13632
  const importees = [];
13383
13633
  const maybePushImportee = (value) => {
13384
13634
  if (typeof value !== "string" || !value) return;
@@ -13405,7 +13655,7 @@ function transformWxsCode(code, options) {
13405
13655
  babelrc: false,
13406
13656
  configFile: false,
13407
13657
  presets: [[babelPresetEnv, {
13408
- modules: "commonjs",
13658
+ modules: preserveEsmExports ? false : "commonjs",
13409
13659
  targets: { ie: "11" }
13410
13660
  }], babelPresetTypescript],
13411
13661
  filename,
@@ -13437,6 +13687,7 @@ function transformWxsCode(code, options) {
13437
13687
  p.replaceWith(t.callExpression(t.identifier("getRegExp"), args));
13438
13688
  } },
13439
13689
  MemberExpression: { enter(p) {
13690
+ if (preserveEsmExports) return;
13440
13691
  const node = p.node;
13441
13692
  if (!t.isIdentifier(node.object, { name: "exports" })) return;
13442
13693
  const moduleExports = t.memberExpression(t.identifier("module"), t.identifier("exports"));
@@ -13558,7 +13809,7 @@ function createCacheKey$1(options) {
13558
13809
  const importMetaExtension = options.importMetaExtension ?? "";
13559
13810
  const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(options);
13560
13811
  const defineKeys = resolvedDefineImportMetaEnv ? Object.keys(resolvedDefineImportMetaEnv).sort().map((key) => `${key}:${String(resolvedDefineImportMetaEnv[key])}`).join(",") : "";
13561
- return `${options.removeComment ? 1 : 0}|${options.transformEvent ? 1 : 0}|${extension}|${tag}|${templateExt}|${importMetaExtension}|${importMetaRelativePath}|${defineKeys}`;
13812
+ return `${options.removeComment ? 1 : 0}|${options.transformEvent ? 1 : 0}|${options.transformPlatformSyntax ? 1 : 0}|${extension}|${tag}|${templateExt}|${importMetaExtension}|${importMetaRelativePath}|${defineKeys}`;
13562
13813
  }
13563
13814
  function getCachedResult(data, cacheKey) {
13564
13815
  return handleCache.get(data)?.get(cacheKey);
@@ -13596,6 +13847,7 @@ function handleWxml(data, options) {
13596
13847
  importMetaExtension: void 0,
13597
13848
  removeComment: true,
13598
13849
  transformEvent: true,
13850
+ transformPlatformSyntax: true,
13599
13851
  scriptModuleExtension: void 0,
13600
13852
  scriptModuleTag: void 0,
13601
13853
  templateExtension: void 0
@@ -13610,14 +13862,15 @@ function handleWxml(data, options) {
13610
13862
  scriptModuleExtension: normalizedScriptExtension,
13611
13863
  scriptModuleTag: opts.scriptModuleTag
13612
13864
  });
13613
- const shouldNormalizeImports = wxsImportNormalizeTokens.length > 0;
13614
- const shouldNormalizeTemplateImports = templateImportNormalizeTokens.length > 0 && normalizedTemplateExtension;
13615
- const shouldRemoveLang = removeWxsLangAttrTokens.length > 0;
13616
- const shouldTransformInlineWxs = inlineWxsTokens.length > 0;
13617
- const shouldTransformEvents = opts.transformEvent && eventTokens.length > 0;
13618
- const shouldTransformDirectives = directiveTokens.length > 0;
13619
- const shouldTransformTagNames = tagNameTokens.length > 0;
13620
- const shouldTransformScriptModuleTags = resolvedScriptTag !== "wxs" && scriptModuleTagTokens.length > 0;
13865
+ const shouldTransformPlatformSyntax = opts.transformPlatformSyntax;
13866
+ const shouldNormalizeImports = shouldTransformPlatformSyntax && wxsImportNormalizeTokens.length > 0;
13867
+ const shouldNormalizeTemplateImports = shouldTransformPlatformSyntax && templateImportNormalizeTokens.length > 0 && normalizedTemplateExtension;
13868
+ const shouldRemoveLang = shouldTransformPlatformSyntax && removeWxsLangAttrTokens.length > 0;
13869
+ const shouldTransformInlineWxs = shouldTransformPlatformSyntax && inlineWxsTokens.length > 0;
13870
+ const shouldTransformEvents = shouldTransformPlatformSyntax && opts.transformEvent && eventTokens.length > 0;
13871
+ const shouldTransformDirectives = shouldTransformPlatformSyntax && directiveTokens.length > 0;
13872
+ const shouldTransformTagNames = shouldTransformPlatformSyntax && tagNameTokens.length > 0;
13873
+ const shouldTransformScriptModuleTags = shouldTransformPlatformSyntax && resolvedScriptTag !== "wxs" && scriptModuleTagTokens.length > 0;
13621
13874
  const shouldRemoveConditionals = removalRanges.length > 0;
13622
13875
  const shouldRemoveComments = opts.removeComment && commentTokens.length > 0;
13623
13876
  const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(opts);
@@ -13656,7 +13909,7 @@ function handleWxml(data, options) {
13656
13909
  }
13657
13910
  if (shouldRemoveComments) for (const { end, start } of commentTokens) ms.remove(start, end);
13658
13911
  return setCachedResult(data, cacheKey, {
13659
- code: replaceDefineImportMetaEnv(shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(), resolvedDefineImportMetaEnv),
13912
+ code: replaceDefineImportMetaEnv(shouldTransformPlatformSyntax && shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(), resolvedDefineImportMetaEnv),
13660
13913
  components,
13661
13914
  deps
13662
13915
  });
@@ -14449,7 +14702,7 @@ async function collectAutoImportTemplateTags(ctx) {
14449
14702
  const files = await new fdir({
14450
14703
  includeDirs: false,
14451
14704
  pathSeparator: "/"
14452
- }).withFullPaths().filter((filePath) => filePath.endsWith(".vue") || filePath.endsWith(".wxml")).crawl(srcRoot).withPromise();
14705
+ }).withFullPaths().filter((filePath) => filePath.endsWith(".vue") || filePath.endsWith(".wxml") || filePath.endsWith(".axml")).crawl(srcRoot).withPromise();
14453
14706
  const tags = /* @__PURE__ */ new Map();
14454
14707
  const platform = resolveMiniPlatformWithDefault(ctx.configService?.platform);
14455
14708
  await Promise.all(files.map(async (filePath) => {
@@ -19555,10 +19808,12 @@ function patchScopedSlotHostAssetForBundle(ctx, fileName, output) {
19555
19808
  if (output.type === "chunk") {
19556
19809
  const current = output.code;
19557
19810
  if (typeof current !== "string") return false;
19558
- const next = withScopedSlotHostProperties(ctx, fileName, current);
19559
- if (next === current) return false;
19560
- output.code = next;
19561
- return true;
19811
+ if (!getScopedSlotGenericKeys(ctx, fileName)?.size || ctx.configService.platform !== "weapp" || current.includes(WEVU_SLOT_OWNER_ID_PROP)) return false;
19812
+ const transformCode = resolveOutputChunkTransformCode(output);
19813
+ const injected = injectScopedSlotHostPropertiesInJs(transformCode, { sourceMap: Boolean(normalizeEncodedSourceMapLike(output.map)) || transformCode !== current });
19814
+ if (injected.transformed) return applyOutputChunkTransform(output, injected.code, injected.map);
19815
+ const propertySource = createScopedSlotHostPropertiesSource();
19816
+ return replaceOutputChunkCode(output, /Component\(\s*\{/, (match) => `${match[0]} properties: { ${propertySource} },`);
19562
19817
  }
19563
19818
  const current = output.source;
19564
19819
  if (typeof current !== "string" && !Buffer.isBuffer(current) && !(current instanceof Uint8Array)) return false;
@@ -21150,11 +21405,11 @@ function isLayoutFile(filename, configService) {
21150
21405
  const layoutsRoot = `${normalizeWatchPath(path.join(configService.absoluteSrcRoot, "layouts"))}/`;
21151
21406
  return normalizeWatchPath(filename).startsWith(layoutsRoot);
21152
21407
  }
21153
- async function collectNativeLayoutAssets(basePath) {
21408
+ async function collectNativeLayoutAssets(basePath, platform) {
21154
21409
  const [jsonEntry, templateEntry, styleEntry, scriptEntry] = await Promise.all([
21155
21410
  findJsonEntry(basePath),
21156
- findTemplateEntry(basePath),
21157
- findCssEntry(basePath),
21411
+ findTemplateEntry(basePath, platform),
21412
+ findCssEntry(basePath, platform),
21158
21413
  findJsEntry(basePath)
21159
21414
  ]);
21160
21415
  return {
@@ -21184,10 +21439,10 @@ function assertTemplateHasDefaultSlot(options) {
21184
21439
  //#endregion
21185
21440
  //#region src/plugins/utils/layoutEntries.ts
21186
21441
  async function registerResolvedPageLayoutEntries(options) {
21187
- const { layouts, entries, explicitEntryTypes, nativeScriptEntries, normalizeEntry, jsonPath } = options;
21442
+ const { layouts, entries, explicitEntryTypes, nativeScriptEntries, normalizeEntry, jsonPath, platform } = options;
21188
21443
  for (const layout of layouts) {
21189
21444
  if (layout.kind === "native") {
21190
- if (!(await collectNativeLayoutAssets(layout.file)).script) continue;
21445
+ if (!(await collectNativeLayoutAssets(layout.file, platform)).script) continue;
21191
21446
  }
21192
21447
  entries.push(layout.importPath);
21193
21448
  const normalizedEntry = normalizeEntry(layout.importPath, jsonPath);
@@ -21203,20 +21458,20 @@ function markComponentEntries(entriesMap, entries) {
21203
21458
  }
21204
21459
  //#endregion
21205
21460
  //#region src/plugins/utils/pageLayout.ts
21206
- async function expandResolvedPageLayoutFiles(layouts) {
21461
+ async function expandResolvedPageLayoutFiles(layouts, platform) {
21207
21462
  const files = [];
21208
21463
  for (const layout of layouts) {
21209
21464
  if (layout.kind !== "native") {
21210
21465
  files.push(layout.file);
21211
21466
  continue;
21212
21467
  }
21213
- const nativeAssets = await collectNativeLayoutAssets(layout.file);
21468
+ const nativeAssets = await collectNativeLayoutAssets(layout.file, platform);
21214
21469
  for (const asset of Object.values(nativeAssets)) if (asset) files.push(asset);
21215
21470
  }
21216
21471
  return files;
21217
21472
  }
21218
21473
  async function registerResolvedPageLayoutDependencies(ctx, ownerId, layouts) {
21219
- const dependencies = await expandResolvedPageLayoutFiles(layouts);
21474
+ const dependencies = await expandResolvedPageLayoutFiles(layouts, ctx.configService.platform);
21220
21475
  const transitiveDependencies = new Set(dependencies);
21221
21476
  for (const file of dependencies) {
21222
21477
  if (!isTemplate(file)) continue;
@@ -21864,7 +22119,7 @@ function resolveWxmlEmitTargets(options) {
21864
22119
  return Array.from(wxmlService.tokenMap.entries()).map(([id, token]) => resolveTarget(id, token)).filter((target) => Boolean(target));
21865
22120
  }
21866
22121
  function emitWxmlAssetFile(options) {
21867
- const { runtime, id, fileName, token, deps, emittedCodeCache, importMetaDefineRegistry, scriptModuleExtension, scriptModuleTag, templateExtension } = options;
22122
+ const { runtime, id, fileName, token, deps, emittedCodeCache, importMetaDefineRegistry, scriptModuleExtension, scriptModuleTag, templateExtension, platform } = options;
21868
22123
  runtime.addWatchFile?.(normalizeWatchPath(id));
21869
22124
  if (deps) for (const dep of deps) runtime.addWatchFile?.(normalizeWatchPath(dep));
21870
22125
  const result = handleWxml(token, {
@@ -21873,7 +22128,8 @@ function emitWxmlAssetFile(options) {
21873
22128
  importMetaRelativePath: fileName,
21874
22129
  scriptModuleExtension,
21875
22130
  scriptModuleTag,
21876
- templateExtension
22131
+ templateExtension,
22132
+ transformPlatformSyntax: !isNativeTemplateSource(id, platform)
21877
22133
  });
21878
22134
  if (emittedCodeCache.get(fileName) === result.code) return false;
21879
22135
  emittedCodeCache.set(fileName, result.code);
@@ -21906,7 +22162,8 @@ function emitWxmlAssetsWithCache(options) {
21906
22162
  importMetaDefineRegistry: configService.importMetaDefineRegistry,
21907
22163
  scriptModuleExtension,
21908
22164
  scriptModuleTag,
21909
- templateExtension
22165
+ templateExtension,
22166
+ platform: configService.platform
21910
22167
  });
21911
22168
  }
21912
22169
  return emittedFiles;
@@ -22009,7 +22266,7 @@ async function emitEntryOutput(options) {
22009
22266
  outputExtensions: configService.outputExtensions
22010
22267
  });
22011
22268
  if (!resolvedOptions) return;
22012
- const assets = await collectNativeLayoutAssets(layoutBasePath);
22269
+ const assets = await collectNativeLayoutAssets(layoutBasePath, configService.platform);
22013
22270
  const emittedLayoutAssets = pluginCtx.__weappViteNativeLayoutAssets ?? (pluginCtx.__weappViteNativeLayoutAssets = /* @__PURE__ */ new Set());
22014
22271
  if (assets.json) registerJsonAsset({
22015
22272
  jsonPath: assets.json,
@@ -22135,7 +22392,7 @@ async function emitEntryOutput(options) {
22135
22392
  });
22136
22393
  if (layoutPlan) {
22137
22394
  const layoutDependencies = /* @__PURE__ */ new Set();
22138
- for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts)) layoutDependencies.add(normalizeFsResolvedId(file));
22395
+ for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts, configService.platform)) layoutDependencies.add(normalizeFsResolvedId(file));
22139
22396
  replaceLayoutDependencies(id, layoutDependencies);
22140
22397
  const nativeTemplate = await readFile$1(templatePath, { checkMtime: configService.isDev });
22141
22398
  const transformed = applyPageLayoutPlanToNativePage({
@@ -22179,7 +22436,13 @@ async function emitEntryOutput(options) {
22179
22436
  if (styleImports.length === 0) return { code };
22180
22437
  const ms = new MagicString(code);
22181
22438
  for (const styleImport of styleImports) ms.prepend(`import '${styleImport}';\n`);
22182
- return { code: ms.toString() };
22439
+ const result = { code: ms.toString() };
22440
+ if (configService.inlineConfig?.build?.sourcemap) result.map = ms.generateMap({
22441
+ hires: true,
22442
+ includeContent: true,
22443
+ source: id
22444
+ });
22445
+ return result;
22183
22446
  }
22184
22447
  //#endregion
22185
22448
  //#region src/plugins/hooks/useLoadEntry/loadEntry/resolve.ts
@@ -22439,7 +22702,7 @@ function createEntryLoader(options) {
22439
22702
  const registerPageLayoutComponentEntries = async (layoutPlan, options) => {
22440
22703
  if (options?.trackLayoutDependencies) {
22441
22704
  const layoutDependencies = /* @__PURE__ */ new Set();
22442
- for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts)) layoutDependencies.add(normalizeFsResolvedId(file));
22705
+ for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts, configService.platform)) layoutDependencies.add(normalizeFsResolvedId(file));
22443
22706
  replaceLayoutDependencies(normalizedId, layoutDependencies);
22444
22707
  }
22445
22708
  await registerResolvedPageLayoutDependencies(ctx, normalizedId, layoutPlan.layouts);
@@ -22449,7 +22712,8 @@ function createEntryLoader(options) {
22449
22712
  explicitEntryTypes,
22450
22713
  nativeScriptEntries: nativeLayoutScriptEntries,
22451
22714
  normalizeEntry,
22452
- jsonPath
22715
+ jsonPath,
22716
+ platform: configService.platform
22453
22717
  });
22454
22718
  for (const layout of layoutPlan.layouts) {
22455
22719
  if (layout.kind === "native") continue;
@@ -22523,7 +22787,7 @@ function createEntryLoader(options) {
22523
22787
  } else {
22524
22788
  const templateScanStartedAt = performance$1.now();
22525
22789
  try {
22526
- templatePath = (isJsonStableHmr ? templateEntryPathCache.get(normalizedId) : void 0) ?? await scanTemplateEntry(this, id, scanTemplateEntryFn, existsCache, pathExistsTtlMs);
22790
+ templatePath = (isJsonStableHmr ? templateEntryPathCache.get(normalizedId) : void 0) ?? await scanTemplateEntry(this, id, scanTemplateEntryFn, existsCache, pathExistsTtlMs, configService.platform);
22527
22791
  templateEntryPathCache.set(normalizedId, templatePath);
22528
22792
  } finally {
22529
22793
  recordEntryDuration("entryTemplateScanMs", templateScanStartedAt);
@@ -22531,7 +22795,7 @@ function createEntryLoader(options) {
22531
22795
  if (libEntry && libConfig) {
22532
22796
  const componentJson = libConfig.componentJson ?? "auto";
22533
22797
  const hasTemplate = Boolean(templatePath) || id.endsWith(".vue");
22534
- const styleEntry = await findCssEntry(baseName);
22798
+ const styleEntry = await findCssEntry(baseName, configService.platform);
22535
22799
  const hasStyle = Boolean(styleEntry.path);
22536
22800
  const shouldTreatAsComponent = hasTemplate || hasStyle || Boolean(json?.component);
22537
22801
  if (!hasJsonEntry && shouldTreatAsComponent) {
@@ -23539,9 +23803,9 @@ function removeImplicitPagePreloads(bundle, options, snapshot = createBundleChun
23539
23803
  const targets = targetSet;
23540
23804
  const ranges = findImplicitRequireRemovalRanges(chunk, targets);
23541
23805
  if (!ranges.length) continue;
23542
- const ms = new MagicString(chunk.code);
23543
- for (const { start, end } of ranges) ms.remove(start, end);
23544
- chunk.code = ms.toString();
23806
+ editOutputChunkCode(chunk, (magicString) => {
23807
+ for (const { start, end } of ranges) magicString.remove(start, end);
23808
+ });
23545
23809
  if (Array.isArray(chunk.imports) && chunk.imports.length) chunk.imports = chunk.imports.filter((name) => !targets.has(name));
23546
23810
  if (implicitlyLoaded && implicitlyLoaded.length) chunk.implicitlyLoadedBefore = implicitlyLoaded.filter((name) => !targets.has(name));
23547
23811
  }
@@ -23667,12 +23931,23 @@ function resolveOutputCode(output) {
23667
23931
  if (output.source == null) return;
23668
23932
  return Buffer.from(output.source).toString();
23669
23933
  }
23670
- function updateOutputCode(output, code) {
23671
- if (output.type === "chunk") {
23672
- output.code = code;
23673
- return;
23934
+ function replaceOutputCode(output, pattern, replace) {
23935
+ if (output.type === "chunk") return replaceOutputChunkCode(output, pattern, replace);
23936
+ const code = resolveOutputCode(output);
23937
+ if (typeof code !== "string") return false;
23938
+ const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
23939
+ const matcher = new RegExp(pattern.source, flags);
23940
+ const magicString = new MagicString(code);
23941
+ let changed = false;
23942
+ for (const match of code.matchAll(matcher)) {
23943
+ if (typeof match.index !== "number") continue;
23944
+ const content = replace(match);
23945
+ if (content == null || content === match[0]) continue;
23946
+ magicString.overwrite(match.index, match.index + match[0].length, content);
23947
+ changed = true;
23674
23948
  }
23675
- output.source = code;
23949
+ if (changed) output.source = magicString.toString();
23950
+ return changed;
23676
23951
  }
23677
23952
  function formatNamedRequireBindings(bindings) {
23678
23953
  return bindings.map(({ importedName, localName }) => {
@@ -23756,45 +24031,41 @@ function rewriteWevuInternalRuntimeImports(bundle, options = {}, snapshot = crea
23756
24031
  const fileName = output.fileName;
23757
24032
  if (!fileName.endsWith(".js")) continue;
23758
24033
  if (!mayContainWevuRuntimeImport(code)) continue;
23759
- let rewritten = code;
23760
- let changed = false;
23761
24034
  const requiredRuntimeFileNames = /* @__PURE__ */ new Set();
23762
24035
  let containsRootWevuRuntimeExport;
23763
- rewritten = rewritten.replace(WEVU_RUNTIME_NAMED_IMPORT_RE, (full, importClause, source) => {
24036
+ const changedNamedImports = replaceOutputCode(output, WEVU_RUNTIME_NAMED_IMPORT_RE, (match) => {
24037
+ const [full, importClause, source] = match;
23764
24038
  const bindings = parseNamedImportBindings(importClause);
23765
24039
  const importedNames = bindings.map((binding) => binding.importedName);
23766
24040
  if (source === "wevu") {
23767
24041
  const result = rewriteRootWevuImport(runtimeChunkIndex, fileName, full, bindings, options, requiredRuntimeFileNames);
23768
- changed ||= result.changed;
23769
- return result.code;
24042
+ return result.changed ? result.code : void 0;
23770
24043
  }
23771
24044
  const resolvedInternalModuleId = normalizeWevuRuntimeModuleId(source);
23772
- if (!resolvedInternalModuleId) return full;
24045
+ if (!resolvedInternalModuleId) return;
23773
24046
  const runtimeChunk = resolveWevuRuntimeChunkForModuleId(runtimeChunkIndex, resolvedInternalModuleId, importedNames);
23774
24047
  const rememberedRuntimeFileName = resolveRememberedWevuRuntimeFileName(resolvedInternalModuleId, importedNames, options);
23775
24048
  const runtimeFileName = runtimeChunk?.fileName ?? rememberedRuntimeFileName;
23776
- if (!runtimeFileName) return full;
24049
+ if (!runtimeFileName) return;
23777
24050
  rememberWevuRuntimeChunk(resolvedInternalModuleId, runtimeChunk, options);
23778
- changed = true;
23779
24051
  requiredRuntimeFileNames.add(runtimeFileName);
23780
24052
  const specifier = normalizeRelativeRequireSpecifier(fileName, runtimeFileName);
23781
24053
  return `const { ${formatNamedRequireBindings(bindings)} } = require(${JSON.stringify(specifier)});`;
23782
24054
  });
23783
- rewritten = rewritten.replace(WEVU_RUNTIME_REQUIRE_RE, (full, rawSpecifier) => {
24055
+ const changedRequires = replaceOutputCode(output, WEVU_RUNTIME_REQUIRE_RE, (match) => {
24056
+ const rawSpecifier = match[1];
23784
24057
  const specifierValue = stripQuotes(rawSpecifier);
23785
24058
  if (specifierValue === "wevu" && containsRootWevuRuntimeExport === void 0) containsRootWevuRuntimeExport = containsWevuInternalRuntimeExportReference(code);
23786
24059
  const normalizedModuleId = normalizeWevuRuntimeModuleId(specifierValue);
23787
24060
  const canUseRememberedRuntime = normalizedModuleId === "wevu/internal-runtime" || specifierValue === "wevu" && containsRootWevuRuntimeExport === true;
23788
24061
  const rememberedRuntimeFileName = normalizedModuleId ? options.runtimeFileNames?.get(normalizedModuleId) : void 0;
23789
24062
  const runtimeFileName = canUseRememberedRuntime ? currentRuntimeChunk?.fileName ?? rememberedRuntimeFileName ?? options.runtimeFileName : rememberedRuntimeFileName;
23790
- if (!runtimeFileName) return full;
23791
- changed = true;
24063
+ if (!runtimeFileName) return;
23792
24064
  requiredRuntimeFileNames.add(runtimeFileName);
23793
24065
  const specifier = normalizeRelativeRequireSpecifier(fileName, runtimeFileName);
23794
24066
  return `require(${JSON.stringify(specifier)})`;
23795
24067
  });
23796
- if (!changed) continue;
23797
- updateOutputCode(output, rewritten);
24068
+ if (!changedNamedImports && !changedRequires) continue;
23798
24069
  if (output.type !== "chunk") continue;
23799
24070
  const chunk = output;
23800
24071
  const nextImports = new Set(Array.isArray(chunk.imports) ? chunk.imports : []);
@@ -23929,7 +24200,7 @@ function appendWevuRuntimeExports(chunk, aliases, importedMembers) {
23929
24200
  lines.push(`Object.defineProperty(exports, ${JSON.stringify(member)}, { enumerable: true, get: function() { return ${member}; } });`);
23930
24201
  existingExports.add(member);
23931
24202
  }
23932
- if (lines.length) chunk.code = `${chunk.code}\n${lines.join("\n")}`;
24203
+ if (lines.length) appendOutputChunkCode(chunk, `\n${lines.join("\n")}`);
23933
24204
  }
23934
24205
  function formatSyntheticSinglePageHookExport(exportName) {
23935
24206
  return [
@@ -23949,7 +24220,7 @@ function appendSyntheticWevuHookExports(chunk, importedMembers) {
23949
24220
  lines.push(formatSyntheticSinglePageHookExport(exportName));
23950
24221
  existingExports.add(exportName);
23951
24222
  }
23952
- if (lines.length) chunk.code = `${chunk.code}\n${lines.join("\n")}`;
24223
+ if (lines.length) appendOutputChunkCode(chunk, `\n${lines.join("\n")}`);
23953
24224
  }
23954
24225
  function resolveWevuBaseChunk(bundleOrSnapshot) {
23955
24226
  return resolveWevuInternalChunk(bundleOrSnapshot, ["assertInSetup", "pushHook"]);
@@ -23964,44 +24235,37 @@ function rewriteSyntheticWevuHookAccess(chunk, wevuChunkFileName, baseChunkFileN
23964
24235
  });
23965
24236
  if (!hookNames.length) return;
23966
24237
  const baseRequireSpecifier = normalizeRelativeRequireSpecifier(chunk.fileName, baseChunkFileName);
23967
- let nextCode = chunk.code;
23968
24238
  for (const hookName of hookNames) {
23969
- for (const ref of usage.runtimeRefs) {
23970
- const memberRe = new RegExp(`\\b${escapeRegExp(ref)}\\.${hookName}\\s*\\(`, "g");
23971
- nextCode = nextCode.replace(memberRe, () => {
23972
- return formatSyntheticSinglePageHookFallback(hookName, `${ref}.${hookName}`, baseRequireSpecifier);
23973
- });
23974
- }
24239
+ for (const ref of usage.runtimeRefs) replaceOutputChunkCode(chunk, new RegExp(`\\b${escapeRegExp(ref)}\\.${hookName}\\s*\\(`, "g"), () => {
24240
+ return formatSyntheticSinglePageHookFallback(hookName, `${ref}.${hookName}`, baseRequireSpecifier);
24241
+ });
23975
24242
  if (!usage.inlineMembers.has(hookName)) continue;
23976
- nextCode = nextCode.replace(/require\((`[^`]+`|'[^']+'|"[^"]+")\)\.([A-Za-z_$][\w$]*)\s*\(/g, (full, rawSpecifier, property) => {
23977
- if (property !== hookName) return full;
23978
- if (resolveRequireTarget(chunk.fileName, stripQuotes(rawSpecifier)) !== wevuChunkFileName) return full;
24243
+ replaceOutputChunkCode(chunk, /require\((`[^`]+`|'[^']+'|"[^"]+")\)\.([A-Za-z_$][\w$]*)\s*\(/g, (match) => {
24244
+ const rawSpecifier = match[1];
24245
+ if (match[2] !== hookName) return;
24246
+ if (resolveRequireTarget(chunk.fileName, stripQuotes(rawSpecifier)) !== wevuChunkFileName) return;
23979
24247
  return formatSyntheticSinglePageHookFallback(hookName, `require(${rawSpecifier}).${hookName}`, baseRequireSpecifier);
23980
24248
  });
23981
24249
  }
23982
- chunk.code = nextCode;
23983
24250
  }
23984
24251
  function rewriteStableWevuRuntimeAccess(chunk, wevuChunkFileName, aliases, usage) {
23985
24252
  if (!aliases.size) return;
23986
- let nextCode = chunk.code;
23987
24253
  for (const [exportName, stableName] of WEVU_EXPORT_ALIASES) {
23988
24254
  const localName = aliases.get(exportName);
23989
24255
  if (!localName) continue;
23990
- if (usage.inlineMembers.has(localName) || usage.inlineMembers.has(stableName)) nextCode = nextCode.replace(/require\((`[^`]+`|'[^']+'|"[^"]+")\)\.([A-Za-z_$][\w$]*)\s*\(/g, (full, rawSpecifier, property) => {
23991
- if (property !== localName && property !== stableName) return full;
23992
- if (resolveRequireTarget(chunk.fileName, stripQuotes(rawSpecifier)) !== wevuChunkFileName) return full;
24256
+ if (usage.inlineMembers.has(localName) || usage.inlineMembers.has(stableName)) replaceOutputChunkCode(chunk, /require\((`[^`]+`|'[^']+'|"[^"]+")\)\.([A-Za-z_$][\w$]*)\s*\(/g, (match) => {
24257
+ const rawSpecifier = match[1];
24258
+ const property = match[2];
24259
+ if (property !== localName && property !== stableName) return;
24260
+ if (resolveRequireTarget(chunk.fileName, stripQuotes(rawSpecifier)) !== wevuChunkFileName) return;
23993
24261
  return `(require(${rawSpecifier}).${stableName} || require(${rawSpecifier}).${property})(`;
23994
24262
  });
23995
24263
  if (!usage.members.has(localName) && !usage.members.has(stableName)) continue;
23996
- for (const ref of usage.runtimeRefs) {
23997
- const memberRe = new RegExp(`\\b${escapeRegExp(ref)}\\.(?:${stableName}|${localName})\\s*\\(`, "g");
23998
- nextCode = nextCode.replace(memberRe, (full) => {
23999
- const property = full.includes(`.${stableName}`) ? stableName : localName;
24000
- return `(${ref}.${stableName} || ${ref}.${property})(`;
24001
- });
24002
- }
24264
+ for (const ref of usage.runtimeRefs) replaceOutputChunkCode(chunk, new RegExp(`\\b${escapeRegExp(ref)}\\.(?:${stableName}|${localName})\\s*\\(`, "g"), (match) => {
24265
+ const property = match[0].includes(`.${stableName}`) ? stableName : localName;
24266
+ return `(${ref}.${stableName} || ${ref}.${property})(`;
24267
+ });
24003
24268
  }
24004
- chunk.code = nextCode;
24005
24269
  }
24006
24270
  function stabilizeWevuRuntimeChunkAccess(bundle, snapshot = createBundleChunkSnapshot(bundle)) {
24007
24271
  const wevuChunks = snapshot.wevuChunks;
@@ -24731,14 +24995,8 @@ function createInjectRequestGlobalsCode(targets, options) {
24731
24995
  function createInjectRequestGlobalsSfcCode(targets, options) {
24732
24996
  return `<script${options?.setup ? " setup lang=\"ts\"" : " lang=\"ts\""}>\n${createInjectRequestGlobalsCode(targets, options)}<\/script>\n`;
24733
24997
  }
24734
- function injectCodeIntoSfcBlock(source, startOffset, injection) {
24735
- return `${source.slice(0, startOffset)}${injection}${source.slice(startOffset)}`;
24736
- }
24737
- /**
24738
- * @description 将请求全局对象注入到现有 SFC 脚本块,避免生成额外的重复 `<script>`。
24739
- */
24740
- function injectRequestGlobalsIntoSfc(source, targets, options) {
24741
- if (targets.length === 0) return source;
24998
+ function resolveRequestGlobalsSfcInjection(source, targets, options) {
24999
+ if (targets.length === 0) return null;
24742
25000
  const { descriptor, errors } = parse$1(source, {
24743
25001
  filename: "request-globals.vue",
24744
25002
  ignoreEmpty: false
@@ -24748,19 +25006,42 @@ function injectRequestGlobalsIntoSfc(source, targets, options) {
24748
25006
  localBindings: false
24749
25007
  } : options;
24750
25008
  const injection = createInjectRequestGlobalsCode(targets, injectionOptions);
24751
- if (errors.length > 0) return `${createInjectRequestGlobalsSfcCode(targets, source.includes("<script setup") ? {
24752
- ...options,
24753
- localBindings: false
24754
- } : options)}${source}`;
25009
+ if (errors.length > 0) return {
25010
+ code: createInjectRequestGlobalsSfcCode(targets, source.includes("<script setup") ? {
25011
+ ...options,
25012
+ localBindings: false
25013
+ } : options),
25014
+ index: 0
25015
+ };
24755
25016
  const inlineScript = descriptor.script && !descriptor.script.src ? descriptor.script : void 0;
24756
- if (inlineScript) return injectCodeIntoSfcBlock(source, inlineScript.loc.start.offset, injection);
24757
- if (descriptor.scriptSetup && !descriptor.scriptSetup.src ? descriptor.scriptSetup : void 0) return `${createInjectRequestGlobalsSfcCode(targets, injectionOptions)}${source}`;
24758
- if (!descriptor.script) return `${createInjectRequestGlobalsSfcCode(targets, injectionOptions)}${source}`;
24759
- if (!descriptor.scriptSetup) return `${createInjectRequestGlobalsSfcCode(targets, {
24760
- ...options,
24761
- setup: true
24762
- })}${source}`;
24763
- return source;
25017
+ if (inlineScript) return {
25018
+ code: injection,
25019
+ index: inlineScript.loc.start.offset
25020
+ };
25021
+ if (descriptor.scriptSetup && !descriptor.scriptSetup.src ? descriptor.scriptSetup : void 0) return {
25022
+ code: createInjectRequestGlobalsSfcCode(targets, injectionOptions),
25023
+ index: 0
25024
+ };
25025
+ if (!descriptor.script) return {
25026
+ code: createInjectRequestGlobalsSfcCode(targets, injectionOptions),
25027
+ index: 0
25028
+ };
25029
+ if (!descriptor.scriptSetup) return {
25030
+ code: createInjectRequestGlobalsSfcCode(targets, {
25031
+ ...options,
25032
+ setup: true
25033
+ }),
25034
+ index: 0
25035
+ };
25036
+ return null;
25037
+ }
25038
+ /**
25039
+ * @description 将请求全局对象注入到现有 SFC 脚本块,避免生成额外的重复 `<script>`。
25040
+ */
25041
+ function injectRequestGlobalsIntoSfc(source, targets, options) {
25042
+ const injection = resolveRequestGlobalsSfcInjection(source, targets, options);
25043
+ if (!injection) return source;
25044
+ return `${source.slice(0, injection.index)}${injection.code}${source.slice(injection.index)}`;
24764
25045
  }
24765
25046
  //#endregion
24766
25047
  //#region src/postcss/constants.ts
@@ -25134,13 +25415,13 @@ function injectSharedStyleImports(css, modulePath, fileName, sharedStyles, confi
25134
25415
  //#region src/plugins/css.ts
25135
25416
  const LEADING_BLANK_LINES_RE = /^(?:[ \t]*\r?\n)+/;
25136
25417
  const TAILWIND_CONTENT_HMR_NONCE_RE = /\n\/\* weapp-vite tailwind-content [^*\n]+ \*\/$/;
25137
- const SOURCE_STYLE_ASSET_RE = /\.(?:wxss|css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
25138
- const VITE_PREPROCESS_STYLE_RE = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
25418
+ const VITE_PREPROCESS_STYLE_RE = /\.(?:acss|css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
25139
25419
  function stripLeadingBlankLines(code) {
25140
25420
  return code.replace(LEADING_BLANK_LINES_RE, "");
25141
25421
  }
25142
25422
  function isSourceStyleAsset(fileName) {
25143
- return SOURCE_STYLE_ASSET_RE.test(fileName);
25423
+ const extension = path.extname(fileName);
25424
+ return isSourceStyleExtension(extension) || /\.(?:stylus|pcss|postcss|sss)$/.test(fileName);
25144
25425
  }
25145
25426
  function hasStyleDirtyReason(dirtyReasonSummary) {
25146
25427
  return dirtyReasonSummary.some((reason) => reason.startsWith("style-sidecar:") || reason.startsWith("css-importer:") || reason.startsWith("css-importer-fallback:") || reason.startsWith("entry-style-only:") || reason.startsWith("tailwind-content:"));
@@ -25157,8 +25438,7 @@ function stripTailwindContentHmrNonce(source) {
25157
25438
  }
25158
25439
  function isStyleBundleAsset(output, bundleKey) {
25159
25440
  if (output.type !== "asset") return false;
25160
- const fileName = output.fileName || bundleKey;
25161
- return fileName.endsWith(".css") || fileName.endsWith(".wxss") || isSourceStyleAsset(fileName);
25441
+ return isSourceStyleAsset(output.fileName || bundleKey);
25162
25442
  }
25163
25443
  function hasStyleBundleAsset(bundle) {
25164
25444
  for (const [bundleKey, output] of Object.entries(bundle)) if (isStyleBundleAsset(output, bundleKey)) return true;
@@ -25665,6 +25945,10 @@ function normalizeTemplateAssetEntries(ctx, entries) {
25665
25945
  if (!mayNeedTemplateNormalization(code, configService?.platform)) continue;
25666
25946
  const result = handleWxml(scanWxml(code, { platform: configService?.platform }), {
25667
25947
  scriptModuleExtension: configService?.outputExtensions?.wxs,
25948
+ scriptModuleTag: resolveScriptModuleTagName({
25949
+ platform: configService?.platform,
25950
+ scriptModuleExtension: configService?.outputExtensions?.wxs
25951
+ }),
25668
25952
  templateExtension: configService?.outputExtensions?.wxml
25669
25953
  });
25670
25954
  if (result.code !== code) output.source = result.code;
@@ -25736,6 +26020,7 @@ function createOutputFinalizerPlugin(ctx) {
25736
26020
  normalizePreprocessorStyleAssetEntries(outputBundle, assetEntries.preprocessorStyleAssets, ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
25737
26021
  normalizeTemplateAssetEntries(ctx, assetEntries.templateAssets);
25738
26022
  pruneUnchangedDevHmrOutputs(ctx, outputBundle, wevuRuntimeRewriteOptions, { runtimeRewriteDone: true });
26023
+ syncOutputChunkSourceMapAssets(outputBundle);
25739
26024
  }
25740
26025
  }
25741
26026
  };
@@ -26001,43 +26286,6 @@ function rewriteMiniProgramPlatformApiAccess(code, globalName, options) {
26001
26286
  return createMiniProgramPlatformApiRewrite(code, globalName, options)?.toString() ?? code;
26002
26287
  }
26003
26288
  //#endregion
26004
- //#region src/utils/sourcemap.ts
26005
- function isEncodedSourceMapLike(value) {
26006
- return Boolean(value && typeof value === "object" && "version" in value && typeof value.version === "number" && "mappings" in value && "names" in value && "sources" in value);
26007
- }
26008
- function normalizeEncodedSourceMapLike(value) {
26009
- if (!value || typeof value !== "object") return null;
26010
- const sourceMap = value;
26011
- const numericVersion = typeof sourceMap.version === "number" ? sourceMap.version : typeof sourceMap.version === "string" ? Number(sourceMap.version) : NaN;
26012
- if (!Number.isFinite(numericVersion)) return null;
26013
- const normalized = {
26014
- ...sourceMap,
26015
- version: numericVersion
26016
- };
26017
- return isEncodedSourceMapLike(normalized) ? normalized : null;
26018
- }
26019
- function composeSourceMaps(transformedMap, originalMap) {
26020
- if (isEncodedSourceMapLike(transformedMap) && isEncodedSourceMapLike(originalMap)) return remapping([transformedMap, originalMap], () => null);
26021
- if (isEncodedSourceMapLike(transformedMap)) return transformedMap;
26022
- if (isEncodedSourceMapLike(originalMap)) return originalMap;
26023
- return null;
26024
- }
26025
- //#endregion
26026
- //#region src/plugins/core/lifecycle/emit/rewrite/sourcemap.ts
26027
- function applyMagicStringChunkRewrite(chunk, magicString, options) {
26028
- const previousCode = chunk.code;
26029
- const nextCode = magicString.toString();
26030
- if (nextCode === previousCode) return false;
26031
- const previousMap = normalizeEncodedSourceMapLike(chunk.map);
26032
- chunk.code = nextCode;
26033
- if (previousMap) chunk.map = composeSourceMaps(magicString.generateMap({
26034
- hires: options?.hires ?? "boundary",
26035
- includeContent: true,
26036
- source: chunk.fileName
26037
- }), previousMap);
26038
- return true;
26039
- }
26040
- //#endregion
26041
26289
  //#region src/plugins/core/lifecycle/emit/rewrite/platform.ts
26042
26290
  function mayNeedChunkScriptAnalysis(code) {
26043
26291
  if (code.includes("require")) return true;
@@ -26482,7 +26730,11 @@ function injectRequestGlobalsBundleRuntime(bundle, targets, mode, networkDefault
26482
26730
  ...bindingTargets.map((target) => `${REQUEST_GLOBAL_ACTUALS_KEY}[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_BUNDLE_HOST_REF}.${target}`),
26483
26731
  ...bindingTargets.map((target) => `try{globalThis[${JSON.stringify(target)}]=${REQUEST_GLOBAL_BUNDLE_HOST_REF}.${target}}catch{}`)
26484
26732
  ].join(";");
26485
- chunk.code = `${`/* ${REQUEST_GLOBAL_BUNDLE_MARKER} */ ${passiveBindingsCode ? `${passiveBindingsCode}\n` : ""}`}${syntheticExportCode}${chunk.code}\n;${runtimeBindingCode};\n`;
26733
+ const bundlePrelude = `/* ${REQUEST_GLOBAL_BUNDLE_MARKER} */ ${passiveBindingsCode ? `${passiveBindingsCode}\n` : ""}`;
26734
+ editOutputChunkCode(chunk, (magicString) => {
26735
+ magicString.prepend(`${bundlePrelude}${syntheticExportCode}`);
26736
+ magicString.append(`\n;${runtimeBindingCode};\n`);
26737
+ });
26486
26738
  }
26487
26739
  return installerChunks;
26488
26740
  }
@@ -26500,7 +26752,7 @@ function injectRequestGlobalsPassiveBindings(bundle, installerChunks, targets, m
26500
26752
  if (chunkTargets.length === 0) continue;
26501
26753
  const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(chunkTargets, resolveRequestGlobalsBindingTargets(chunkTargets));
26502
26754
  if (!passiveBindingsCode) continue;
26503
- chunk.code = `/* ${REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER} */ ${passiveBindingsCode}\n${chunk.code}`;
26755
+ prependOutputChunkCode(chunk, `/* ${REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER} */ ${passiveBindingsCode}\n`);
26504
26756
  }
26505
26757
  }
26506
26758
  function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, mode, entriesMap, networkDefaults) {
@@ -26517,7 +26769,7 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, mod
26517
26769
  const bindingTargets = resolveRequestGlobalsBindingTargets(chunkTargets);
26518
26770
  if (bindingTargets.length === 0) continue;
26519
26771
  const inlineInstallerName = resolveRequestGlobalsInstallerName(chunk.code);
26520
- const firstRequireMatch = chunk.code.match(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE);
26772
+ const firstRequireMatch = chunk.code.matchAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE).next().value;
26521
26773
  let requireImportLiteral = null;
26522
26774
  let exportName;
26523
26775
  for (const requireMatch of chunk.code.matchAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE)) {
@@ -26534,7 +26786,7 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, mod
26534
26786
  if (!installerHostExpression) {
26535
26787
  const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(chunkTargets);
26536
26788
  if (!passiveBindingsCode) continue;
26537
- chunk.code = `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${passiveBindingsCode}\n${chunk.code}`;
26789
+ prependOutputChunkCode(chunk, `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${passiveBindingsCode}\n`);
26538
26790
  continue;
26539
26791
  }
26540
26792
  const injectionCode = [
@@ -26545,11 +26797,16 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, mod
26545
26797
  ...bindingTargets.map((target) => `try{globalThis[${JSON.stringify(target)}]=${REQUEST_GLOBAL_CHUNK_HOST_REF}.${target}}catch{}`),
26546
26798
  ...bindingTargets.map((target) => `var ${target} = ${REQUEST_GLOBAL_CHUNK_HOST_REF}.${target}`)
26547
26799
  ].join(";");
26548
- if (inlineInstallerName && firstRequireMatch?.[0]) {
26549
- chunk.code = `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${chunk.code.replace(firstRequireMatch[0], (match) => `${match};${injectionCode}`)}\n`;
26800
+ if (inlineInstallerName && firstRequireMatch?.[0] && typeof firstRequireMatch.index === "number") {
26801
+ const firstRequireIndex = firstRequireMatch.index;
26802
+ editOutputChunkCode(chunk, (magicString) => {
26803
+ magicString.prepend(`/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ `);
26804
+ magicString.overwrite(firstRequireIndex, firstRequireIndex + firstRequireMatch[0].length, `${firstRequireMatch[0]};${injectionCode}`);
26805
+ magicString.append("\n");
26806
+ });
26550
26807
  continue;
26551
26808
  }
26552
- chunk.code = `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${injectionCode};\n${chunk.code}`;
26809
+ prependOutputChunkCode(chunk, `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${injectionCode};\n`);
26553
26810
  }
26554
26811
  }
26555
26812
  function resolveRequestGlobalsInstallerImport(chunk, installerChunks) {
@@ -26587,18 +26844,18 @@ function toRequireRequestPath(fromFileName, toFileName) {
26587
26844
  const relativePath = toPosixPath(path.relative(path.dirname(fromFileName), toFileName));
26588
26845
  return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
26589
26846
  }
26847
+ function isRequestGlobalsSupportChunkFileName(fileName) {
26848
+ const baseName = path.basename(toPosixPath(fileName));
26849
+ return baseName.startsWith("request-globals-") || baseName === "web-apis-shared.js";
26850
+ }
26590
26851
  function rewriteChunkRequireLiteral(chunk, fromFileName, toFileName) {
26591
- let didRewrite = false;
26592
- const nextCode = chunk.code.replaceAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE, (...args) => {
26593
- const match = args[0];
26594
- const requireLiteral = args[2];
26595
- const importee = args[3] ?? args[4] ?? args[5];
26596
- if (!requireLiteral || !importee) return match;
26597
- if (normalizeRelativeChunkImport(chunk.fileName, importee) !== fromFileName) return match;
26598
- didRewrite = true;
26599
- return match.replace(requireLiteral, JSON.stringify(toRequireRequestPath(chunk.fileName, toFileName)));
26852
+ replaceOutputChunkCode(chunk, REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE, (match) => {
26853
+ const requireLiteral = match[2];
26854
+ const importee = match[3] ?? match[4] ?? match[5];
26855
+ if (!requireLiteral || !importee) return;
26856
+ if (normalizeRelativeChunkImport(chunk.fileName, importee) !== fromFileName) return;
26857
+ return match[0].replace(requireLiteral, JSON.stringify(toRequireRequestPath(chunk.fileName, toFileName)));
26600
26858
  });
26601
- if (didRewrite) chunk.code = nextCode;
26602
26859
  }
26603
26860
  function hasBareRequireRegistration(code, requirePath) {
26604
26861
  const escapedRequireLiteral = JSON.stringify(requirePath).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -26623,14 +26880,12 @@ function rewriteEmbeddedRequirePaths(code, fromFileName, toFileName) {
26623
26880
  });
26624
26881
  }
26625
26882
  function rewriteChunkRequireCallsToExpression(chunk, targetFileName, expression) {
26626
- let didRewrite = false;
26627
- const nextCode = rewriteRequireCallLiterals(chunk.code, (_requireLiteral, importee) => {
26883
+ return replaceOutputChunkCode(chunk, REQUEST_GLOBAL_REQUIRE_CALL_RE, (match) => {
26884
+ const importee = match[2] ?? match[3] ?? match[4];
26885
+ if (!importee) return;
26628
26886
  if (normalizeRelativeChunkImport(chunk.fileName, importee) !== targetFileName) return;
26629
- didRewrite = true;
26630
26887
  return expression;
26631
26888
  });
26632
- if (didRewrite) chunk.code = nextCode;
26633
- return didRewrite;
26634
26889
  }
26635
26890
  function createRequestGlobalsStaticImportReplacement(node, expression) {
26636
26891
  const declarations = [];
@@ -26669,10 +26924,11 @@ function rewriteChunkStaticImportsToExpression(chunk, targetFileName, expression
26669
26924
  });
26670
26925
  } });
26671
26926
  if (replacements.length === 0) return false;
26672
- let nextCode = chunk.code;
26673
- for (const replacement of replacements.sort((left, right) => right.start - left.start)) nextCode = `${nextCode.slice(0, replacement.start)}${replacement.value}${nextCode.slice(replacement.end)}`;
26674
- chunk.code = nextCode;
26675
- return true;
26927
+ return replaceOutputChunkCodeRanges(chunk, replacements.map((replacement) => ({
26928
+ content: replacement.value,
26929
+ end: replacement.end,
26930
+ start: replacement.start
26931
+ })));
26676
26932
  } catch {
26677
26933
  return false;
26678
26934
  }
@@ -26708,7 +26964,7 @@ function collapseRequestGlobalsRuntimeSupportChunk(bundle) {
26708
26964
  const resolvedImport = normalizeRelativeChunkImport(runtimeOutput.fileName, importee);
26709
26965
  const supportChunk = bundle[resolvedImport];
26710
26966
  if (!supportChunk || supportChunk.type !== "chunk") continue;
26711
- if (resolvedImport === "weapp-vendors/request-globals-runtime.js" || !resolvedImport.startsWith("request-globals-") && !resolvedImport.endsWith("web-apis-shared.js")) continue;
26967
+ if (resolvedImport === "weapp-vendors/request-globals-runtime.js" || !isRequestGlobalsSupportChunkFileName(resolvedImport)) continue;
26712
26968
  supportChunkFileName = resolvedImport;
26713
26969
  runtimeRequireMatch = requireMatch;
26714
26970
  break;
@@ -26718,22 +26974,29 @@ function collapseRequestGlobalsRuntimeSupportChunk(bundle) {
26718
26974
  if (!supportChunk || supportChunk.type !== "chunk") return;
26719
26975
  const supportModuleRef = "__wvRGS__";
26720
26976
  const supportRequireIdentifier = runtimeRequireMatch[1];
26721
- runtimeOutput.code = runtimeOutput.code.replace(runtimeRequireMatch[0], `${supportRequireIdentifier} = ${supportModuleRef}`);
26722
- runtimeOutput.code = [
26723
- `const ${supportModuleRef} = (() => {`,
26724
- " const module = { exports: {} }",
26725
- " const exports = module.exports",
26726
- String(supportChunk.code),
26727
- " return module.exports",
26728
- "})();",
26729
- runtimeOutput.code,
26730
- `for (const __wvRGK__ in ${supportModuleRef}) {`,
26731
- " if (__wvRGK__ in exports) {",
26732
- " continue",
26733
- " }",
26734
- ` Object.defineProperty(exports, __wvRGK__, { enumerable: true, get: () => ${supportModuleRef}[__wvRGK__] })`,
26735
- "}"
26736
- ].join("\n");
26977
+ editOutputChunkCode(runtimeOutput, (magicString) => {
26978
+ const runtimeRequireIndex = runtimeRequireMatch.index;
26979
+ if (typeof runtimeRequireIndex !== "number") return;
26980
+ magicString.overwrite(runtimeRequireIndex, runtimeRequireIndex + runtimeRequireMatch[0].length, `${supportRequireIdentifier} = ${supportModuleRef}`);
26981
+ magicString.prepend([
26982
+ `const ${supportModuleRef} = (() => {`,
26983
+ " const module = { exports: {} }",
26984
+ " const exports = module.exports",
26985
+ String(supportChunk.code),
26986
+ " return module.exports",
26987
+ "})();",
26988
+ ""
26989
+ ].join("\n"));
26990
+ magicString.append([
26991
+ "",
26992
+ `for (const __wvRGK__ in ${supportModuleRef}) {`,
26993
+ " if (__wvRGK__ in exports) {",
26994
+ " continue",
26995
+ " }",
26996
+ ` Object.defineProperty(exports, __wvRGK__, { enumerable: true, get: () => ${supportModuleRef}[__wvRGK__] })`,
26997
+ "}"
26998
+ ].join("\n"));
26999
+ });
26737
27000
  delete bundle[supportChunkFileName];
26738
27001
  for (const output of Object.values(bundle)) {
26739
27002
  if (!output || output.type !== "chunk") continue;
@@ -26756,7 +27019,7 @@ function injectRequestGlobalsAppRegistration(bundle, installerChunks) {
26756
27019
  requireStatements.push(`require(${JSON.stringify(requirePath)});`);
26757
27020
  }
26758
27021
  if (requireStatements.length === 0) return;
26759
- appChunk.code = `${requireStatements.join("\n")}\n${appChunk.code}`;
27022
+ prependOutputChunkCode(appChunk, `${requireStatements.join("\n")}\n`);
26760
27023
  }
26761
27024
  function inlineRequestGlobalsAppRegisteredInstallerChunks(bundle, installerChunks, preservedInstallerChunks = /* @__PURE__ */ new Set()) {
26762
27025
  if (installerChunks.size === 0) return;
@@ -26799,7 +27062,7 @@ function inlineRequestGlobalsAppRegisteredInstallerChunks(bundle, installerChunk
26799
27062
  if (!hasPreservedAssetRequire) delete bundle[installerChunkFileName];
26800
27063
  }
26801
27064
  if (inlinedModules.length === 0) return;
26802
- appChunk.code = `${inlinedModules.join("\n")}\n${appChunk.code}`;
27065
+ prependOutputChunkCode(appChunk, `${inlinedModules.join("\n")}\n`);
26803
27066
  }
26804
27067
  function createRequestGlobalsPreludeCode(chunk, installerChunks, targets, mode, networkDefaults) {
26805
27068
  const chunkTargets = resolvePreludeRequestGlobalsTargets(chunk.code, targets, mode);
@@ -26888,7 +27151,7 @@ function injectAxiosFetchAdapterEnv(bundle) {
26888
27151
  const moduleIds = Array.isArray(chunk.moduleIds) ? chunk.moduleIds : [];
26889
27152
  const normalizedFileName = toPosixPath(chunk.fileName);
26890
27153
  if (!(moduleIds.some((id) => AXIOS_MODULE_ID_RE.test(id)) || normalizedFileName === "axios.js" || normalizedFileName.endsWith("/axios.js"))) continue;
26891
- chunk.code = `${chunk.code}\n${axiosEnvPatchCode}`;
27154
+ appendOutputChunkCode(chunk, `\n${axiosEnvPatchCode}`);
26892
27155
  }
26893
27156
  }
26894
27157
  //#endregion
@@ -27644,10 +27907,37 @@ function parseRequest(id) {
27644
27907
  * @returns 返回文件的真实路径。
27645
27908
  */
27646
27909
  function getCssRealPath(res) {
27910
+ if (typeof res.query.nativeStyle === "string" && res.query.nativeStyle) return changeFileExtension(res.filename, res.query.nativeStyle);
27647
27911
  if (res.query.wxss) return changeFileExtension(res.filename, "wxss");
27648
27912
  return res.filename;
27649
27913
  }
27650
27914
  //#endregion
27915
+ //#region src/utils/codeTransform.ts
27916
+ /**
27917
+ * 对 load/transform 结果执行可追踪编辑,并按需组合已有映射。
27918
+ */
27919
+ function editCodeTransformResult(result, sourceId, edit, options) {
27920
+ const magicString = new MagicString(result.code);
27921
+ edit(magicString, result.code);
27922
+ const code = magicString.toString();
27923
+ if (code === result.code) return result;
27924
+ const previousMap = normalizeEncodedSourceMapLike(result.map);
27925
+ if (!options?.sourceMap && !previousMap) return {
27926
+ ...result,
27927
+ code
27928
+ };
27929
+ const rewriteMap = magicString.generateMap({
27930
+ hires: true,
27931
+ includeContent: true,
27932
+ source: sourceId
27933
+ });
27934
+ return {
27935
+ ...result,
27936
+ code,
27937
+ map: previousMap ? composeSourceMaps(rewriteMap, previousMap) : rewriteMap
27938
+ };
27939
+ }
27940
+ //#endregion
27651
27941
  //#region src/plugins/core/lifecycle/load/requestGlobals.ts
27652
27942
  const NORMAL_SFC_SCRIPT_RE = /<script(?![^>]*setup)[^>]*>/u;
27653
27943
  function resolvePassiveRequestGlobalsTargets(code, requestGlobalsTargets) {
@@ -27665,14 +27955,13 @@ function resolveRequestGlobalsTargetsForCode(code, sourceId, options) {
27665
27955
  }
27666
27956
  function injectRequestGlobalsIntoLoadResult(result, sourceId, targets, options) {
27667
27957
  if (!result || typeof result !== "object" || !("code" in result) || typeof result.code !== "string" || targets.length === 0) return result;
27668
- if (sourceId.endsWith(".vue")) return {
27669
- ...result,
27670
- code: injectRequestGlobalsIntoSfc(result.code, targets, options)
27671
- };
27672
- return {
27673
- ...result,
27674
- code: `${createInjectRequestGlobalsCode(targets, options)}${result.code}`
27675
- };
27958
+ if (sourceId.endsWith(".vue")) {
27959
+ const injection = resolveRequestGlobalsSfcInjection(result.code, targets, options);
27960
+ if (!injection) return result;
27961
+ return editCodeTransformResult(result, sourceId, (magicString) => magicString.appendLeft(injection.index, injection.code), { sourceMap: options?.sourceMap });
27962
+ }
27963
+ const injection = createInjectRequestGlobalsCode(targets, options);
27964
+ return editCodeTransformResult(result, sourceId, (magicString) => magicString.prepend(injection), { sourceMap: options?.sourceMap });
27676
27965
  }
27677
27966
  //#endregion
27678
27967
  //#region src/plugins/core/lifecycle/load/weapi.ts
@@ -27995,7 +28284,10 @@ function createLoadHook(state) {
27995
28284
  function injectRequestGlobalsProfiled(result, sourceId, requestGlobalsTargets, options) {
27996
28285
  const startedAt = performance.now();
27997
28286
  try {
27998
- return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, options);
28287
+ return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, {
28288
+ ...options,
28289
+ sourceMap: Boolean(configService.inlineConfig?.build?.sourcemap)
28290
+ });
27999
28291
  } finally {
28000
28292
  recordLoadDuration("requestGlobalsMs", startedAt);
28001
28293
  }
@@ -28024,7 +28316,7 @@ function createLoadHook(state) {
28024
28316
  configService.weappViteConfig?.debug?.load?.(id, subPackageMeta);
28025
28317
  if (isCSSRequest(id)) {
28026
28318
  const parsed = parseRequest(id);
28027
- if (parsed.query.wxss) {
28319
+ if (parsed.query.wxss || parsed.query.nativeStyle) {
28028
28320
  const realPath = getCssRealPath(parsed);
28029
28321
  try {
28030
28322
  return { code: await readFile$1(realPath, { checkMtime: configService.isDev }) };
@@ -28166,8 +28458,8 @@ async function collectLogicalEntryDependencies(state, ownerId) {
28166
28458
  const entry = resolveEntryRecord(state, ownerId);
28167
28459
  const [jsonEntry, templateEntry, styleEntry] = await Promise.all([
28168
28460
  findJsonEntry(ownerId),
28169
- findTemplateEntry(ownerId),
28170
- findCssEntry(ownerId)
28461
+ findTemplateEntry(ownerId, state.ctx.configService.platform),
28462
+ findCssEntry(ownerId, state.ctx.configService.platform)
28171
28463
  ]);
28172
28464
  await addExistingDependency("json", entry?.jsonPath ?? jsonEntry.path);
28173
28465
  await addExistingDependency("json", entry && "sitemapJsonPath" in entry ? entry.sitemapJsonPath : void 0);
@@ -28425,6 +28717,7 @@ const ATOMIC_SAVE_RECHECK_DELAYS_MS = [20, 60];
28425
28717
  const tailwindContentExtensions = /* @__PURE__ */ new Set([
28426
28718
  ".vue",
28427
28719
  ".wxml",
28720
+ ".axml",
28428
28721
  ".js",
28429
28722
  ".jsx",
28430
28723
  ".ts",
@@ -28651,7 +28944,7 @@ async function processChangedFile(state, id, event) {
28651
28944
  if (!shouldRefreshAppStyleForTailwindContent(state)) return false;
28652
28945
  const appEntryId = scanService.appEntry?.path ? normalizeFsResolvedId(scanService.appEntry.path) : void 0;
28653
28946
  if (!appEntryId || appEntryId === normalizedId || !resolvedEntryMap.has(appEntryId)) return false;
28654
- const styleEntry = await findCssEntry(appEntryId);
28947
+ const styleEntry = await findCssEntry(appEntryId, ctx.configService.platform);
28655
28948
  if (!styleEntry.path) return false;
28656
28949
  if (!await isTailwindAppStyleSource(styleEntry.path)) return false;
28657
28950
  if (concreteChangedEntryId !== appEntryId && (loadedEntrySet.has(concreteChangedEntryId) || resolvedEntryMap.has(concreteChangedEntryId))) markEntryDirtyWithCause(concreteChangedEntryId, "direct", "tailwind-content");
@@ -28997,16 +29290,17 @@ function createRequireAnalysisPlugin(state) {
28997
29290
  }
28998
29291
  //#endregion
28999
29292
  //#region src/plugins/core/wxss.ts
29293
+ const nativeStyleExtensionRe = new RegExp(`\\.(${ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS.join("|")})$`);
29000
29294
  function createWxssResolverPlugin(state) {
29001
29295
  return {
29002
- name: "weapp-vite:pre:wxss",
29296
+ name: "weapp-vite:pre:native-style",
29003
29297
  enforce: "pre",
29004
29298
  resolveId: {
29005
- filter: { id: /\.wxss$/ },
29299
+ filter: { id: nativeStyleExtensionRe },
29006
29300
  handler(id) {
29007
29301
  const startedAt = performance.now();
29008
29302
  try {
29009
- return id.replace(/\.wxss$/, ".css?wxss");
29303
+ return id.replace(nativeStyleExtensionRe, (_match, extension) => `.css?nativeStyle=${extension}`);
29010
29304
  } finally {
29011
29305
  const profile = state.ctx.runtimeState?.build?.hmr?.profile;
29012
29306
  recordHmrProfileDuration(profile, "pluginResolveMs", performance.now() - startedAt);
@@ -30804,7 +31098,7 @@ async function resolveNativeLayoutAssetState(options) {
30804
31098
  if (!resolvedOptions) return;
30805
31099
  return {
30806
31100
  resolvedOptions,
30807
- assets: await collectNativeLayoutAssets(options.layoutBasePath)
31101
+ assets: await collectNativeLayoutAssets(options.layoutBasePath, options.configService.platform)
30808
31102
  };
30809
31103
  }
30810
31104
  async function emitResolvedNativeLayoutStaticAssets(options) {
@@ -32051,6 +32345,9 @@ function workers(ctx) {
32051
32345
  const wxsCodeCache = new LRUCache({ max: 512 });
32052
32346
  const WXS_FILE_SUFFIX_RE = /\.(?:wxs|sjs)(\.[jt]s)?$/;
32053
32347
  const WXS_SCAN_RELEVANT_HMR_RE = /\.(?:vue|wxml|axml|swan|ttml|jxml|qml|ksml|xhsml|html|wxs|sjs)(?:\.[jt]s)?$/i;
32348
+ function createWxsCodeCacheKey(rawCode, scriptModuleExtension) {
32349
+ return `${scriptModuleExtension ?? "wxs"}::${rawCode}`;
32350
+ }
32054
32351
  function resolveWxsOutputFileName(ctx, wxsPath, scriptModuleExtension) {
32055
32352
  const suffixMatch = wxsPath.match(WXS_FILE_SUFFIX_RE);
32056
32353
  const isRaw = suffixMatch ? !suffixMatch[1] : true;
@@ -32070,7 +32367,8 @@ async function transformWxsFile(state, wxsPath) {
32070
32367
  filename: wxsPath,
32071
32368
  extension: scriptModuleExtension
32072
32369
  });
32073
- const code = wxsCodeCache.get(rawCode) ?? result?.code;
32370
+ const cacheKey = createWxsCodeCacheKey(rawCode, scriptModuleExtension);
32371
+ const code = wxsCodeCache.get(cacheKey) ?? result?.code;
32074
32372
  const dirname = path.dirname(wxsPath);
32075
32373
  const importeePaths = importees.map(({ source }) => path.resolve(dirname, source));
32076
32374
  await Promise.all(importeePaths.map((importeePath) => transformWxsFile.call(this, state, importeePath)));
@@ -32081,7 +32379,7 @@ async function transformWxsFile(state, wxsPath) {
32081
32379
  source: code
32082
32380
  };
32083
32381
  state.wxsMap.set(wxsPath, { emittedFile });
32084
- wxsCodeCache.set(rawCode, code);
32382
+ wxsCodeCache.set(cacheKey, code);
32085
32383
  }
32086
32384
  async function handleWxsDeps(state, deps, absPath) {
32087
32385
  await Promise.all(deps.filter((dep) => isScriptModuleTagName(dep.tagName)).map(async (dep) => {
@@ -33226,7 +33524,7 @@ async function loadAppEntry(ctx, scanState) {
33226
33524
  const { path: appEntryPath } = appEntry;
33227
33525
  let configFromVue;
33228
33526
  if (!appConfigFile && vueAppPath) {
33229
- const { extractConfigFromVue } = await import("./file-BG-q88IF.mjs");
33527
+ const { extractConfigFromVue } = await import("./file-D0RifY1q.mjs");
33230
33528
  configFromVue = await extractConfigFromVue(vueAppPath);
33231
33529
  if (configFromVue) appConfigFile = vueAppPath;
33232
33530
  }