weapp-vite 6.20.0 → 6.20.2

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-NyBgGJm2.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-DQ5FlYd5.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";
@@ -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);
@@ -5989,6 +5984,7 @@ function createAutoImportScheduling(options) {
5989
5984
  html: void 0,
5990
5985
  vue: void 0
5991
5986
  };
5987
+ let outputWritesSuppressed = 0;
5992
5988
  let outputSettingsSnapshot;
5993
5989
  function getOutputSettingsSnapshot() {
5994
5990
  if (!outputSettingsSnapshot) outputSettingsSnapshot = {
@@ -5999,6 +5995,7 @@ function createAutoImportScheduling(options) {
5999
5995
  return outputSettingsSnapshot;
6000
5996
  }
6001
5997
  function deferOrSchedule(kind, shouldWrite) {
5998
+ if (outputWritesSuppressed > 0) return;
6002
5999
  if (batchedWrites.depth > 0) {
6003
6000
  const previous = batchedWrites[kind];
6004
6001
  batchedWrites[kind] = previous === void 0 ? shouldWrite : previous || shouldWrite;
@@ -6041,10 +6038,19 @@ function createAutoImportScheduling(options) {
6041
6038
  if (batchedWrites.depth === 0) flushBatchedWrites();
6042
6039
  }
6043
6040
  }
6041
+ async function runWithoutOutputWrites(task) {
6042
+ outputWritesSuppressed += 1;
6043
+ try {
6044
+ return await task();
6045
+ } finally {
6046
+ outputWritesSuppressed -= 1;
6047
+ }
6048
+ }
6044
6049
  return {
6045
6050
  getOutputSettingsSnapshot,
6046
6051
  deferOrSchedule,
6047
- runInBatch
6052
+ runInBatch,
6053
+ runWithoutOutputWrites
6048
6054
  };
6049
6055
  }
6050
6056
  //#endregion
@@ -6165,6 +6171,9 @@ function createAutoImportService(ctx) {
6165
6171
  },
6166
6172
  async runInBatch(task) {
6167
6173
  return await scheduling.runInBatch(task);
6174
+ },
6175
+ async runWithoutOutputWrites(task) {
6176
+ return await scheduling.runWithoutOutputWrites(task);
6168
6177
  }
6169
6178
  };
6170
6179
  }
@@ -6431,7 +6440,7 @@ const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
6431
6440
  ".turbo"
6432
6441
  ]);
6433
6442
  const SCRIPT_SIDECAR_PATTERN = /\.(?:wxs|sjs)\.[jt]s$/i;
6434
- const TEMPLATE_SIDECAR_PATTERN = /\.wxml\.[jt]s$/i;
6443
+ const TEMPLATE_SIDECAR_PATTERN = new RegExp(`\\.(?:${templateExtensions.join("|")})\\.[jt]s$`, "i");
6435
6444
  function isConfigFile(filePath) {
6436
6445
  return CONFIG_SUFFIXES.some((ext) => filePath.endsWith(ext));
6437
6446
  }
@@ -7298,7 +7307,7 @@ function matchesRouteFile(ctx, candidate) {
7298
7307
  if (isVueFile(resolvedPath.absolutePath) || isScriptFile(resolvedPath.absolutePath) || isTemplateFile(resolvedPath.absolutePath) || isStyleFile(resolvedPath.absolutePath)) return true;
7299
7308
  return false;
7300
7309
  }
7301
- async function rebuildCandidateForBase(base) {
7310
+ async function rebuildCandidateForBase(base, platform) {
7302
7311
  const files = /* @__PURE__ */ new Set();
7303
7312
  let hasScript = false;
7304
7313
  let hasTemplate = false;
@@ -7306,8 +7315,8 @@ async function rebuildCandidateForBase(base) {
7306
7315
  const [vueEntry, jsEntry, templateEntry, styleEntry, jsonEntry] = await Promise.all([
7307
7316
  findVueEntry(base),
7308
7317
  findJsEntry(base),
7309
- findTemplateEntry(base),
7310
- findCssEntry(base),
7318
+ findTemplateEntry(base, platform),
7319
+ findCssEntry(base, platform),
7311
7320
  findJsonEntry(base)
7312
7321
  ]);
7313
7322
  if (vueEntry) {
@@ -7368,7 +7377,7 @@ async function updateCandidateFromFile(ctx, stateCandidates, filePath, event, ma
7368
7377
  matchesInclude,
7369
7378
  hasCandidateEntry: stateCandidates.has(base)
7370
7379
  })) return stateCandidates.delete(base);
7371
- const candidate = await rebuildCandidateForBase(base);
7380
+ const candidate = await rebuildCandidateForBase(base, ctx.configService.platform);
7372
7381
  if (!candidate) return stateCandidates.delete(base);
7373
7382
  if (isAutoRoutesCandidateUnchanged(stateCandidates.get(base), candidate)) return false;
7374
7383
  stateCandidates.set(base, candidate);
@@ -10625,6 +10634,7 @@ class WeappViteDevRuntime extends BaseDevRuntime {
10625
10634
  createModuleHotContext(moduleId) {
10626
10635
  const previous = this.contexts.get(moduleId);
10627
10636
  const context = new WeappViteHotContext(moduleId);
10637
+ this.registrationModuleId = moduleId;
10628
10638
  if (previous) {
10629
10639
  context.callbacks = previous.callbacks;
10630
10640
  context.data = previous.data;
@@ -10720,6 +10730,10 @@ function rememberInstanceState(instance, moduleId) {
10720
10730
  function trackInstance(instance, moduleId) {
10721
10731
  getInstances(moduleId).add(instance);
10722
10732
  if (instanceSnapshots.has(instance)) return;
10733
+ if ((wevuRefreshGenerations.get(moduleId) || 0) > 0) {
10734
+ rememberInstanceState(instance, moduleId);
10735
+ return;
10736
+ }
10723
10737
  const snapshot = moduleSnapshots.get(moduleId);
10724
10738
  if (snapshot) {
10725
10739
  instanceSnapshots.set(instance, snapshot);
@@ -10747,7 +10761,11 @@ function rememberTrackedInstances() {
10747
10761
  }
10748
10762
  function restoreTrackedInstances() {
10749
10763
  for (const [moduleId, values] of instances) {
10750
- for (const instance of values) restoreInstanceState(instance, moduleId);
10764
+ for (const instance of values) {
10765
+ const generation = wevuRefreshGenerations.get(moduleId) || 0;
10766
+ if (generation > 0 && wevuInstanceGenerations.get(instance)?.get(moduleId) === generation) continue;
10767
+ restoreInstanceState(instance, moduleId);
10768
+ }
10751
10769
  }
10752
10770
  }
10753
10771
  function refreshWevuInstance(instance, moduleId) {
@@ -10822,63 +10840,81 @@ function decorateObject(value, moduleId, prefix = '', trackLifecycle = false) {
10822
10840
  }
10823
10841
  function decorateWevuComponent(definition, moduleId) {
10824
10842
  const result = { ...definition };
10843
+ const resolveWevuDefinition = () => definitions.get(moduleId) || definition;
10844
+ const callLatestWevuFunction = (instance, path, fallback, args) => {
10845
+ const segments = path.split('.');
10846
+ let value = resolveWevuDefinition();
10847
+ for (const segment of segments) value = value && value[segment];
10848
+ return (typeof value === 'function' ? value : fallback)?.apply(instance, args);
10849
+ };
10825
10850
  const methods = { ...(definition.methods || {}) };
10826
- for (const [name, method] of Object.entries(methods)) {
10827
- if (typeof method !== 'function') continue;
10851
+ for (const name of Object.keys(methods)) {
10852
+ const fallback = methods[name];
10853
+ if (typeof fallback !== 'function') continue;
10828
10854
  methods[name] = function (...args) {
10829
10855
  trackInstance(this, moduleId);
10830
10856
  refreshWevuInstance(this, moduleId);
10831
10857
  try {
10832
- return method.apply(this, args);
10858
+ return callLatestWevuFunction(this, 'methods.' + name, fallback, args);
10833
10859
  } finally {
10834
10860
  rememberInstanceState(this, moduleId);
10835
10861
  }
10836
10862
  };
10837
10863
  }
10838
10864
  result.methods = methods;
10839
- const onLoad = definition.onLoad;
10840
- const onUnload = definition.onUnload;
10841
- if (typeof onLoad === 'function') {
10842
- result.onLoad = function (...args) {
10865
+ const pageHookNames = ['onLoad', 'onShow', 'onReady', 'onHide', 'onResize', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites'];
10866
+ for (const name of pageHookNames) {
10867
+ const fallback = result[name];
10868
+ if (typeof fallback !== 'function') continue;
10869
+ result[name] = function (...args) {
10843
10870
  trackInstance(this, moduleId);
10844
10871
  refreshWevuInstance(this, moduleId);
10845
- if (suppressLifecycles) return;
10846
- return onLoad.apply(this, args);
10872
+ if (suppressLifecycles && /^(?:onLoad|onShow|onHide|onUnload)$/.test(name)) return;
10873
+ try {
10874
+ return callLatestWevuFunction(this, name, fallback, args);
10875
+ } finally {
10876
+ rememberInstanceState(this, moduleId);
10877
+ if (name === 'onUnload') forgetInstance(this, moduleId);
10878
+ }
10847
10879
  };
10848
10880
  }
10849
- if (typeof onUnload === 'function') {
10850
- result.onUnload = function (...args) {
10881
+ const lifetimes = { ...(definition.lifetimes || {}) };
10882
+ for (const name of Object.keys(lifetimes)) {
10883
+ const fallback = lifetimes[name];
10884
+ if (typeof fallback !== 'function') continue;
10885
+ lifetimes[name] = function (...args) {
10851
10886
  if (suppressLifecycles) return;
10887
+ if (name === 'created' || name === 'attached') {
10888
+ trackInstance(this, moduleId);
10889
+ refreshWevuInstance(this, moduleId);
10890
+ }
10852
10891
  try {
10853
- return onUnload.apply(this, args);
10892
+ return callLatestWevuFunction(this, 'lifetimes.' + name, fallback, args);
10854
10893
  } finally {
10855
- forgetInstance(this, moduleId);
10894
+ if (name === 'detached') forgetInstance(this, moduleId);
10856
10895
  }
10857
10896
  };
10858
10897
  }
10859
- const lifetimes = { ...(definition.lifetimes || {}) };
10860
- const attached = lifetimes.attached;
10861
- const detached = lifetimes.detached;
10862
- lifetimes.attached = function (...args) {
10863
- trackInstance(this, moduleId);
10864
- refreshWevuInstance(this, moduleId);
10865
- if (suppressLifecycles) return;
10866
- return attached?.apply(this, args);
10867
- };
10868
- lifetimes.detached = function (...args) {
10869
- if (suppressLifecycles) return;
10870
- try {
10871
- return detached?.apply(this, args);
10872
- } finally {
10873
- forgetInstance(this, moduleId);
10874
- }
10875
- };
10876
- return { ...result, lifetimes };
10898
+ const pageLifetimes = { ...(definition.pageLifetimes || {}) };
10899
+ for (const name of Object.keys(pageLifetimes)) {
10900
+ const fallback = pageLifetimes[name];
10901
+ if (typeof fallback !== 'function') continue;
10902
+ pageLifetimes[name] = function (...args) {
10903
+ trackInstance(this, moduleId);
10904
+ refreshWevuInstance(this, moduleId);
10905
+ try {
10906
+ return callLatestWevuFunction(this, 'pageLifetimes.' + name, fallback, args);
10907
+ } finally {
10908
+ rememberInstanceState(this, moduleId);
10909
+ }
10910
+ };
10911
+ }
10912
+ return { ...result, lifetimes, pageLifetimes };
10877
10913
  }
10878
10914
  function registerDefinition(name, definition, nativeRegistration) {
10879
10915
  const moduleId = runtime.currentModuleId || runtime.registrationModuleId || name;
10880
10916
  if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) return;
10881
- definitions.set(moduleId, definition);
10917
+ if (!wevuRefreshes.has(moduleId)) definitions.set(moduleId, definition);
10882
10918
  if (registered.has(moduleId)) {
10883
10919
  return;
10884
10920
  }
@@ -10907,8 +10943,17 @@ globalThis[bridgeKey] = {
10907
10943
  return pending;
10908
10944
  },
10909
10945
  isApplying() { return runtime.applyingPatch; },
10946
+ getDebugSnapshot() {
10947
+ return {
10948
+ definitions: [...definitions.keys()],
10949
+ instances: [...instances.entries()].map(([moduleId, values]) => ({ moduleId, count: values.size })),
10950
+ registered: [...registered.values()],
10951
+ refreshes: [...wevuRefreshes.keys()],
10952
+ refreshGenerations: [...wevuRefreshGenerations.entries()],
10953
+ };
10954
+ },
10910
10955
  trackWevuComponent(definition, refresh) {
10911
- const moduleId = runtime.registrationModuleId || runtime.currentModuleId || 'Component';
10956
+ const moduleId = runtime.currentModuleId || runtime.registrationModuleId || 'Component';
10912
10957
  if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) {
10913
10958
  return decorateWevuComponent(definition, moduleId);
10914
10959
  }
@@ -10933,6 +10978,8 @@ globalThis[bridgeKey] = {
10933
10978
  setTimeout(() => { suppressLifecycles = false; });
10934
10979
  }
10935
10980
  };
10981
+ const runtimeGlobal = globalThis.wx || globalThis.my || globalThis.swan || globalThis.tt || globalThis.ali || globalThis.hd || globalThis.qq || globalThis.ks || globalThis.zfb || globalThis.jd || globalThis.xhs;
10982
+ if (runtimeGlobal && !runtimeGlobal[bridgeKey]) runtimeGlobal[bridgeKey] = globalThis[bridgeKey];
10936
10983
  `;
10937
10984
  function createStatefulHmrControlSource(control) {
10938
10985
  return `
@@ -12255,6 +12302,7 @@ function createStatefulHmrBanner(chunk) {
12255
12302
  return [
12256
12303
  `require(${JSON.stringify(`${prefix}rolldown-runtime.js`)});`,
12257
12304
  `globalThis[${JSON.stringify(WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY)}].installNative('Page', definition => Page(definition));`,
12305
+ `globalThis[${JSON.stringify(WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY)}].installNative('Component', definition => Component(definition));`,
12258
12306
  `require(${JSON.stringify(`${prefix}${WEAPP_VITE_STATEFUL_HMR_PRELOAD_FILE}`)});`,
12259
12307
  `require(${JSON.stringify(`${prefix}${WEAPP_VITE_STATEFUL_HMR_UPDATE_FILE}`)});`
12260
12308
  ].join("");
@@ -12311,7 +12359,11 @@ async function runStatefulHmrDev(ctx, buildOptions, restart, snapshots) {
12311
12359
  server: {
12312
12360
  ...buildOptions.server ?? {},
12313
12361
  host: "127.0.0.1",
12314
- port: 0
12362
+ port: 0,
12363
+ watch: {
12364
+ ...buildOptions.server?.watch ?? {},
12365
+ ignored: createStatefulHmrWatchIgnored(buildOptions.root ?? configService.cwd, configService.outDir, buildOptions.server?.watch?.ignored)
12366
+ }
12315
12367
  },
12316
12368
  build: {
12317
12369
  ...buildOptions.build ?? {},
@@ -12330,6 +12382,14 @@ async function runStatefulHmrDev(ctx, buildOptions, restart, snapshots) {
12330
12382
  throw error;
12331
12383
  }
12332
12384
  }
12385
+ function createStatefulHmrWatchIgnored(root, outDir, ignored) {
12386
+ const normalizedRoot = normalizeFsResolvedId(root);
12387
+ const normalizedOutDir = normalizeFsResolvedId(path.isAbsolute(outDir) ? outDir : path.resolve(root, outDir));
12388
+ return [...ignored === void 0 ? [] : Array.isArray(ignored) ? ignored : [ignored], (id) => {
12389
+ const normalizedId = normalizeFsResolvedId(path.isAbsolute(id) ? id : path.resolve(normalizedRoot, id));
12390
+ return isPathInside(normalizedOutDir, normalizedId);
12391
+ }];
12392
+ }
12333
12393
  var StatefulHmrSession = class {
12334
12394
  ctx;
12335
12395
  server;
@@ -13079,8 +13139,8 @@ async function collectMiniappConfigFile(pluginCtx, id, configService, jsonServic
13079
13139
  type: "page"
13080
13140
  });
13081
13141
  }
13082
- async function ensureTemplateScanned(pluginCtx, id, scanTemplateEntry, existsCache, ttlMs) {
13083
- const { path: templateEntry, predictions } = await findTemplateEntry(id);
13142
+ async function ensureTemplateScanned(pluginCtx, id, scanTemplateEntry, existsCache, ttlMs, platform) {
13143
+ const { path: templateEntry, predictions } = await findTemplateEntry(id, platform);
13084
13144
  await addPredictedWatchTargets(pluginCtx, predictions, existsCache, ttlMs, templateEntry);
13085
13145
  if (!templateEntry) return "";
13086
13146
  await scanTemplateEntry(templateEntry);
@@ -13134,8 +13194,8 @@ function collectVueTemplateAutoImportTags(template, filename) {
13134
13194
  function collectScriptSetupImports(scriptSetup, templateComponentNames, options) {
13135
13195
  return collectScriptSetupImportsFromCode(scriptSetup, templateComponentNames, options);
13136
13196
  }
13137
- async function scanTemplateEntry(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs) {
13138
- return ensureTemplateScanned(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs);
13197
+ async function scanTemplateEntry(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs, platform) {
13198
+ return ensureTemplateScanned(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs, platform);
13139
13199
  }
13140
13200
  async function applyScriptSetupUsingComponents(options) {
13141
13201
  const { pluginCtx, vueEntryPath, source, templatePath, json, configService, wxmlService, reExportResolutionCache, externalComponentEntryMap } = options;
@@ -13353,6 +13413,7 @@ function normalizeWxsFilename(value, extension = "wxs") {
13353
13413
  function transformWxsCode(code, options) {
13354
13414
  const filename = options?.filename ?? "script.ts";
13355
13415
  const extension = options?.extension ?? "wxs";
13416
+ const preserveEsmExports = extension.replace(/^\./, "") === "sjs";
13356
13417
  const importees = [];
13357
13418
  const maybePushImportee = (value) => {
13358
13419
  if (typeof value !== "string" || !value) return;
@@ -13379,7 +13440,7 @@ function transformWxsCode(code, options) {
13379
13440
  babelrc: false,
13380
13441
  configFile: false,
13381
13442
  presets: [[babelPresetEnv, {
13382
- modules: "commonjs",
13443
+ modules: preserveEsmExports ? false : "commonjs",
13383
13444
  targets: { ie: "11" }
13384
13445
  }], babelPresetTypescript],
13385
13446
  filename,
@@ -13411,6 +13472,7 @@ function transformWxsCode(code, options) {
13411
13472
  p.replaceWith(t.callExpression(t.identifier("getRegExp"), args));
13412
13473
  } },
13413
13474
  MemberExpression: { enter(p) {
13475
+ if (preserveEsmExports) return;
13414
13476
  const node = p.node;
13415
13477
  if (!t.isIdentifier(node.object, { name: "exports" })) return;
13416
13478
  const moduleExports = t.memberExpression(t.identifier("module"), t.identifier("exports"));
@@ -13532,7 +13594,7 @@ function createCacheKey$1(options) {
13532
13594
  const importMetaExtension = options.importMetaExtension ?? "";
13533
13595
  const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(options);
13534
13596
  const defineKeys = resolvedDefineImportMetaEnv ? Object.keys(resolvedDefineImportMetaEnv).sort().map((key) => `${key}:${String(resolvedDefineImportMetaEnv[key])}`).join(",") : "";
13535
- return `${options.removeComment ? 1 : 0}|${options.transformEvent ? 1 : 0}|${extension}|${tag}|${templateExt}|${importMetaExtension}|${importMetaRelativePath}|${defineKeys}`;
13597
+ return `${options.removeComment ? 1 : 0}|${options.transformEvent ? 1 : 0}|${options.transformPlatformSyntax ? 1 : 0}|${extension}|${tag}|${templateExt}|${importMetaExtension}|${importMetaRelativePath}|${defineKeys}`;
13536
13598
  }
13537
13599
  function getCachedResult(data, cacheKey) {
13538
13600
  return handleCache.get(data)?.get(cacheKey);
@@ -13570,6 +13632,7 @@ function handleWxml(data, options) {
13570
13632
  importMetaExtension: void 0,
13571
13633
  removeComment: true,
13572
13634
  transformEvent: true,
13635
+ transformPlatformSyntax: true,
13573
13636
  scriptModuleExtension: void 0,
13574
13637
  scriptModuleTag: void 0,
13575
13638
  templateExtension: void 0
@@ -13584,14 +13647,15 @@ function handleWxml(data, options) {
13584
13647
  scriptModuleExtension: normalizedScriptExtension,
13585
13648
  scriptModuleTag: opts.scriptModuleTag
13586
13649
  });
13587
- const shouldNormalizeImports = wxsImportNormalizeTokens.length > 0;
13588
- const shouldNormalizeTemplateImports = templateImportNormalizeTokens.length > 0 && normalizedTemplateExtension;
13589
- const shouldRemoveLang = removeWxsLangAttrTokens.length > 0;
13590
- const shouldTransformInlineWxs = inlineWxsTokens.length > 0;
13591
- const shouldTransformEvents = opts.transformEvent && eventTokens.length > 0;
13592
- const shouldTransformDirectives = directiveTokens.length > 0;
13593
- const shouldTransformTagNames = tagNameTokens.length > 0;
13594
- const shouldTransformScriptModuleTags = resolvedScriptTag !== "wxs" && scriptModuleTagTokens.length > 0;
13650
+ const shouldTransformPlatformSyntax = opts.transformPlatformSyntax;
13651
+ const shouldNormalizeImports = shouldTransformPlatformSyntax && wxsImportNormalizeTokens.length > 0;
13652
+ const shouldNormalizeTemplateImports = shouldTransformPlatformSyntax && templateImportNormalizeTokens.length > 0 && normalizedTemplateExtension;
13653
+ const shouldRemoveLang = shouldTransformPlatformSyntax && removeWxsLangAttrTokens.length > 0;
13654
+ const shouldTransformInlineWxs = shouldTransformPlatformSyntax && inlineWxsTokens.length > 0;
13655
+ const shouldTransformEvents = shouldTransformPlatformSyntax && opts.transformEvent && eventTokens.length > 0;
13656
+ const shouldTransformDirectives = shouldTransformPlatformSyntax && directiveTokens.length > 0;
13657
+ const shouldTransformTagNames = shouldTransformPlatformSyntax && tagNameTokens.length > 0;
13658
+ const shouldTransformScriptModuleTags = shouldTransformPlatformSyntax && resolvedScriptTag !== "wxs" && scriptModuleTagTokens.length > 0;
13595
13659
  const shouldRemoveConditionals = removalRanges.length > 0;
13596
13660
  const shouldRemoveComments = opts.removeComment && commentTokens.length > 0;
13597
13661
  const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(opts);
@@ -13630,7 +13694,7 @@ function handleWxml(data, options) {
13630
13694
  }
13631
13695
  if (shouldRemoveComments) for (const { end, start } of commentTokens) ms.remove(start, end);
13632
13696
  return setCachedResult(data, cacheKey, {
13633
- code: replaceDefineImportMetaEnv(shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(), resolvedDefineImportMetaEnv),
13697
+ code: replaceDefineImportMetaEnv(shouldTransformPlatformSyntax && shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(), resolvedDefineImportMetaEnv),
13634
13698
  components,
13635
13699
  deps
13636
13700
  });
@@ -14423,7 +14487,7 @@ async function collectAutoImportTemplateTags(ctx) {
14423
14487
  const files = await new fdir({
14424
14488
  includeDirs: false,
14425
14489
  pathSeparator: "/"
14426
- }).withFullPaths().filter((filePath) => filePath.endsWith(".vue") || filePath.endsWith(".wxml")).crawl(srcRoot).withPromise();
14490
+ }).withFullPaths().filter((filePath) => filePath.endsWith(".vue") || filePath.endsWith(".wxml") || filePath.endsWith(".axml")).crawl(srcRoot).withPromise();
14427
14491
  const tags = /* @__PURE__ */ new Map();
14428
14492
  const platform = resolveMiniPlatformWithDefault(ctx.configService?.platform);
14429
14493
  await Promise.all(files.map(async (filePath) => {
@@ -14694,14 +14758,38 @@ function createIndependentBuilder(configService, buildState) {
14694
14758
  const task = (async () => {
14695
14759
  try {
14696
14760
  const chunkRoot = meta.subPackage.root ?? root;
14697
- const inlineConfig = configService.merge(meta, meta.subPackage.inlineConfig, { build: {
14761
+ const isolatedCtx = createCompilerContextInstance();
14762
+ await isolatedCtx.configService.load({
14763
+ cwd: configService.cwd,
14764
+ isDev: configService.isDev,
14765
+ mode: configService.mode,
14766
+ configFile: configService.configFilePath,
14767
+ cliPlatform: configService.platform,
14768
+ projectConfigPath: configService.projectConfigPath
14769
+ });
14770
+ const isolatedConfigService = isolatedCtx.configService;
14771
+ isolatedConfigService.options = {
14772
+ ...isolatedConfigService.options,
14773
+ currentSubPackageRoot: chunkRoot
14774
+ };
14775
+ const inlineConfig = isolatedConfigService.merge(meta, meta.subPackage.inlineConfig, { build: {
14698
14776
  write: false,
14699
14777
  watch: null,
14700
14778
  rolldownOptions: { output: { chunkFileNames() {
14701
14779
  return `${chunkRoot}/[name].js`;
14702
14780
  } } }
14703
14781
  } });
14704
- const restoreDefineEnv = syncImportMetaEnvDefineOverride(configService, inlineConfig.define);
14782
+ const autoImportGlobs = getAutoImportConfig(isolatedConfigService)?.globs;
14783
+ if (autoImportGlobs?.length) {
14784
+ const candidates = await findAutoImportCandidates({
14785
+ ctx: isolatedCtx,
14786
+ resolvedConfig: { build: { outDir: isolatedConfigService.outDir } }
14787
+ }, autoImportGlobs);
14788
+ await isolatedCtx.autoImportService.runWithoutOutputWrites(async () => {
14789
+ await Promise.all(candidates.map((candidate) => isolatedCtx.autoImportService.registerPotentialComponent(candidate)));
14790
+ });
14791
+ }
14792
+ const restoreDefineEnv = syncImportMetaEnvDefineOverride(isolatedConfigService, inlineConfig.define);
14705
14793
  let result;
14706
14794
  try {
14707
14795
  result = await build(inlineConfig);
@@ -21100,11 +21188,11 @@ function isLayoutFile(filename, configService) {
21100
21188
  const layoutsRoot = `${normalizeWatchPath(path.join(configService.absoluteSrcRoot, "layouts"))}/`;
21101
21189
  return normalizeWatchPath(filename).startsWith(layoutsRoot);
21102
21190
  }
21103
- async function collectNativeLayoutAssets(basePath) {
21191
+ async function collectNativeLayoutAssets(basePath, platform) {
21104
21192
  const [jsonEntry, templateEntry, styleEntry, scriptEntry] = await Promise.all([
21105
21193
  findJsonEntry(basePath),
21106
- findTemplateEntry(basePath),
21107
- findCssEntry(basePath),
21194
+ findTemplateEntry(basePath, platform),
21195
+ findCssEntry(basePath, platform),
21108
21196
  findJsEntry(basePath)
21109
21197
  ]);
21110
21198
  return {
@@ -21134,10 +21222,10 @@ function assertTemplateHasDefaultSlot(options) {
21134
21222
  //#endregion
21135
21223
  //#region src/plugins/utils/layoutEntries.ts
21136
21224
  async function registerResolvedPageLayoutEntries(options) {
21137
- const { layouts, entries, explicitEntryTypes, nativeScriptEntries, normalizeEntry, jsonPath } = options;
21225
+ const { layouts, entries, explicitEntryTypes, nativeScriptEntries, normalizeEntry, jsonPath, platform } = options;
21138
21226
  for (const layout of layouts) {
21139
21227
  if (layout.kind === "native") {
21140
- if (!(await collectNativeLayoutAssets(layout.file)).script) continue;
21228
+ if (!(await collectNativeLayoutAssets(layout.file, platform)).script) continue;
21141
21229
  }
21142
21230
  entries.push(layout.importPath);
21143
21231
  const normalizedEntry = normalizeEntry(layout.importPath, jsonPath);
@@ -21153,20 +21241,20 @@ function markComponentEntries(entriesMap, entries) {
21153
21241
  }
21154
21242
  //#endregion
21155
21243
  //#region src/plugins/utils/pageLayout.ts
21156
- async function expandResolvedPageLayoutFiles(layouts) {
21244
+ async function expandResolvedPageLayoutFiles(layouts, platform) {
21157
21245
  const files = [];
21158
21246
  for (const layout of layouts) {
21159
21247
  if (layout.kind !== "native") {
21160
21248
  files.push(layout.file);
21161
21249
  continue;
21162
21250
  }
21163
- const nativeAssets = await collectNativeLayoutAssets(layout.file);
21251
+ const nativeAssets = await collectNativeLayoutAssets(layout.file, platform);
21164
21252
  for (const asset of Object.values(nativeAssets)) if (asset) files.push(asset);
21165
21253
  }
21166
21254
  return files;
21167
21255
  }
21168
21256
  async function registerResolvedPageLayoutDependencies(ctx, ownerId, layouts) {
21169
- const dependencies = await expandResolvedPageLayoutFiles(layouts);
21257
+ const dependencies = await expandResolvedPageLayoutFiles(layouts, ctx.configService.platform);
21170
21258
  const transitiveDependencies = new Set(dependencies);
21171
21259
  for (const file of dependencies) {
21172
21260
  if (!isTemplate(file)) continue;
@@ -21814,7 +21902,7 @@ function resolveWxmlEmitTargets(options) {
21814
21902
  return Array.from(wxmlService.tokenMap.entries()).map(([id, token]) => resolveTarget(id, token)).filter((target) => Boolean(target));
21815
21903
  }
21816
21904
  function emitWxmlAssetFile(options) {
21817
- const { runtime, id, fileName, token, deps, emittedCodeCache, importMetaDefineRegistry, scriptModuleExtension, scriptModuleTag, templateExtension } = options;
21905
+ const { runtime, id, fileName, token, deps, emittedCodeCache, importMetaDefineRegistry, scriptModuleExtension, scriptModuleTag, templateExtension, platform } = options;
21818
21906
  runtime.addWatchFile?.(normalizeWatchPath(id));
21819
21907
  if (deps) for (const dep of deps) runtime.addWatchFile?.(normalizeWatchPath(dep));
21820
21908
  const result = handleWxml(token, {
@@ -21823,7 +21911,8 @@ function emitWxmlAssetFile(options) {
21823
21911
  importMetaRelativePath: fileName,
21824
21912
  scriptModuleExtension,
21825
21913
  scriptModuleTag,
21826
- templateExtension
21914
+ templateExtension,
21915
+ transformPlatformSyntax: !isNativeTemplateSource(id, platform)
21827
21916
  });
21828
21917
  if (emittedCodeCache.get(fileName) === result.code) return false;
21829
21918
  emittedCodeCache.set(fileName, result.code);
@@ -21856,7 +21945,8 @@ function emitWxmlAssetsWithCache(options) {
21856
21945
  importMetaDefineRegistry: configService.importMetaDefineRegistry,
21857
21946
  scriptModuleExtension,
21858
21947
  scriptModuleTag,
21859
- templateExtension
21948
+ templateExtension,
21949
+ platform: configService.platform
21860
21950
  });
21861
21951
  }
21862
21952
  return emittedFiles;
@@ -21959,7 +22049,7 @@ async function emitEntryOutput(options) {
21959
22049
  outputExtensions: configService.outputExtensions
21960
22050
  });
21961
22051
  if (!resolvedOptions) return;
21962
- const assets = await collectNativeLayoutAssets(layoutBasePath);
22052
+ const assets = await collectNativeLayoutAssets(layoutBasePath, configService.platform);
21963
22053
  const emittedLayoutAssets = pluginCtx.__weappViteNativeLayoutAssets ?? (pluginCtx.__weappViteNativeLayoutAssets = /* @__PURE__ */ new Set());
21964
22054
  if (assets.json) registerJsonAsset({
21965
22055
  jsonPath: assets.json,
@@ -22085,7 +22175,7 @@ async function emitEntryOutput(options) {
22085
22175
  });
22086
22176
  if (layoutPlan) {
22087
22177
  const layoutDependencies = /* @__PURE__ */ new Set();
22088
- for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts)) layoutDependencies.add(normalizeFsResolvedId(file));
22178
+ for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts, configService.platform)) layoutDependencies.add(normalizeFsResolvedId(file));
22089
22179
  replaceLayoutDependencies(id, layoutDependencies);
22090
22180
  const nativeTemplate = await readFile$1(templatePath, { checkMtime: configService.isDev });
22091
22181
  const transformed = applyPageLayoutPlanToNativePage({
@@ -22389,7 +22479,7 @@ function createEntryLoader(options) {
22389
22479
  const registerPageLayoutComponentEntries = async (layoutPlan, options) => {
22390
22480
  if (options?.trackLayoutDependencies) {
22391
22481
  const layoutDependencies = /* @__PURE__ */ new Set();
22392
- for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts)) layoutDependencies.add(normalizeFsResolvedId(file));
22482
+ for (const file of await expandResolvedPageLayoutFiles(layoutPlan.layouts, configService.platform)) layoutDependencies.add(normalizeFsResolvedId(file));
22393
22483
  replaceLayoutDependencies(normalizedId, layoutDependencies);
22394
22484
  }
22395
22485
  await registerResolvedPageLayoutDependencies(ctx, normalizedId, layoutPlan.layouts);
@@ -22399,7 +22489,8 @@ function createEntryLoader(options) {
22399
22489
  explicitEntryTypes,
22400
22490
  nativeScriptEntries: nativeLayoutScriptEntries,
22401
22491
  normalizeEntry,
22402
- jsonPath
22492
+ jsonPath,
22493
+ platform: configService.platform
22403
22494
  });
22404
22495
  for (const layout of layoutPlan.layouts) {
22405
22496
  if (layout.kind === "native") continue;
@@ -22473,7 +22564,7 @@ function createEntryLoader(options) {
22473
22564
  } else {
22474
22565
  const templateScanStartedAt = performance$1.now();
22475
22566
  try {
22476
- templatePath = (isJsonStableHmr ? templateEntryPathCache.get(normalizedId) : void 0) ?? await scanTemplateEntry(this, id, scanTemplateEntryFn, existsCache, pathExistsTtlMs);
22567
+ templatePath = (isJsonStableHmr ? templateEntryPathCache.get(normalizedId) : void 0) ?? await scanTemplateEntry(this, id, scanTemplateEntryFn, existsCache, pathExistsTtlMs, configService.platform);
22477
22568
  templateEntryPathCache.set(normalizedId, templatePath);
22478
22569
  } finally {
22479
22570
  recordEntryDuration("entryTemplateScanMs", templateScanStartedAt);
@@ -22481,7 +22572,7 @@ function createEntryLoader(options) {
22481
22572
  if (libEntry && libConfig) {
22482
22573
  const componentJson = libConfig.componentJson ?? "auto";
22483
22574
  const hasTemplate = Boolean(templatePath) || id.endsWith(".vue");
22484
- const styleEntry = await findCssEntry(baseName);
22575
+ const styleEntry = await findCssEntry(baseName, configService.platform);
22485
22576
  const hasStyle = Boolean(styleEntry.path);
22486
22577
  const shouldTreatAsComponent = hasTemplate || hasStyle || Boolean(json?.component);
22487
22578
  if (!hasJsonEntry && shouldTreatAsComponent) {
@@ -25084,13 +25175,13 @@ function injectSharedStyleImports(css, modulePath, fileName, sharedStyles, confi
25084
25175
  //#region src/plugins/css.ts
25085
25176
  const LEADING_BLANK_LINES_RE = /^(?:[ \t]*\r?\n)+/;
25086
25177
  const TAILWIND_CONTENT_HMR_NONCE_RE = /\n\/\* weapp-vite tailwind-content [^*\n]+ \*\/$/;
25087
- const SOURCE_STYLE_ASSET_RE = /\.(?:wxss|css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
25088
- const VITE_PREPROCESS_STYLE_RE = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
25178
+ const VITE_PREPROCESS_STYLE_RE = /\.(?:acss|css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
25089
25179
  function stripLeadingBlankLines(code) {
25090
25180
  return code.replace(LEADING_BLANK_LINES_RE, "");
25091
25181
  }
25092
25182
  function isSourceStyleAsset(fileName) {
25093
- return SOURCE_STYLE_ASSET_RE.test(fileName);
25183
+ const extension = path.extname(fileName);
25184
+ return isSourceStyleExtension(extension) || /\.(?:stylus|pcss|postcss|sss)$/.test(fileName);
25094
25185
  }
25095
25186
  function hasStyleDirtyReason(dirtyReasonSummary) {
25096
25187
  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:"));
@@ -25107,8 +25198,7 @@ function stripTailwindContentHmrNonce(source) {
25107
25198
  }
25108
25199
  function isStyleBundleAsset(output, bundleKey) {
25109
25200
  if (output.type !== "asset") return false;
25110
- const fileName = output.fileName || bundleKey;
25111
- return fileName.endsWith(".css") || fileName.endsWith(".wxss") || isSourceStyleAsset(fileName);
25201
+ return isSourceStyleAsset(output.fileName || bundleKey);
25112
25202
  }
25113
25203
  function hasStyleBundleAsset(bundle) {
25114
25204
  for (const [bundleKey, output] of Object.entries(bundle)) if (isStyleBundleAsset(output, bundleKey)) return true;
@@ -25615,6 +25705,10 @@ function normalizeTemplateAssetEntries(ctx, entries) {
25615
25705
  if (!mayNeedTemplateNormalization(code, configService?.platform)) continue;
25616
25706
  const result = handleWxml(scanWxml(code, { platform: configService?.platform }), {
25617
25707
  scriptModuleExtension: configService?.outputExtensions?.wxs,
25708
+ scriptModuleTag: resolveScriptModuleTagName({
25709
+ platform: configService?.platform,
25710
+ scriptModuleExtension: configService?.outputExtensions?.wxs
25711
+ }),
25618
25712
  templateExtension: configService?.outputExtensions?.wxml
25619
25713
  });
25620
25714
  if (result.code !== code) output.source = result.code;
@@ -26537,6 +26631,10 @@ function toRequireRequestPath(fromFileName, toFileName) {
26537
26631
  const relativePath = toPosixPath(path.relative(path.dirname(fromFileName), toFileName));
26538
26632
  return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
26539
26633
  }
26634
+ function isRequestGlobalsSupportChunkFileName(fileName) {
26635
+ const baseName = path.basename(toPosixPath(fileName));
26636
+ return baseName.startsWith("request-globals-") || baseName === "web-apis-shared.js";
26637
+ }
26540
26638
  function rewriteChunkRequireLiteral(chunk, fromFileName, toFileName) {
26541
26639
  let didRewrite = false;
26542
26640
  const nextCode = chunk.code.replaceAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE, (...args) => {
@@ -26658,7 +26756,7 @@ function collapseRequestGlobalsRuntimeSupportChunk(bundle) {
26658
26756
  const resolvedImport = normalizeRelativeChunkImport(runtimeOutput.fileName, importee);
26659
26757
  const supportChunk = bundle[resolvedImport];
26660
26758
  if (!supportChunk || supportChunk.type !== "chunk") continue;
26661
- if (resolvedImport === "weapp-vendors/request-globals-runtime.js" || !resolvedImport.startsWith("request-globals-") && !resolvedImport.endsWith("web-apis-shared.js")) continue;
26759
+ if (resolvedImport === "weapp-vendors/request-globals-runtime.js" || !isRequestGlobalsSupportChunkFileName(resolvedImport)) continue;
26662
26760
  supportChunkFileName = resolvedImport;
26663
26761
  runtimeRequireMatch = requireMatch;
26664
26762
  break;
@@ -27594,6 +27692,7 @@ function parseRequest(id) {
27594
27692
  * @returns 返回文件的真实路径。
27595
27693
  */
27596
27694
  function getCssRealPath(res) {
27695
+ if (typeof res.query.nativeStyle === "string" && res.query.nativeStyle) return changeFileExtension(res.filename, res.query.nativeStyle);
27597
27696
  if (res.query.wxss) return changeFileExtension(res.filename, "wxss");
27598
27697
  return res.filename;
27599
27698
  }
@@ -27855,8 +27954,7 @@ function createOptionsHook(state) {
27855
27954
  scanService.loadSubPackages();
27856
27955
  const dirtyIndependentRoots = scanService.drainIndependentDirtyRoots();
27857
27956
  const pendingIndependentBuilds = [];
27858
- const shouldSerializeIndependentBuilds = !configService.isDev && dirtyIndependentRoots.length > 0;
27859
- const previousSubPackageRoot = shouldSerializeIndependentBuilds ? configService.currentSubPackageRoot : void 0;
27957
+ const previousSubPackageRoot = configService.currentSubPackageRoot;
27860
27958
  for (const root of dirtyIndependentRoots) {
27861
27959
  const meta = scanService.independentSubPackageMap.get(root);
27862
27960
  if (!meta) continue;
@@ -27868,11 +27966,11 @@ function createOptionsHook(state) {
27868
27966
  });
27869
27967
  buildTask.catch(() => {});
27870
27968
  pendingIndependentBuilds.push(buildTask);
27871
- if (shouldSerializeIndependentBuilds) try {
27969
+ try {
27872
27970
  await buildTask;
27873
27971
  } catch {}
27874
27972
  }
27875
- if (shouldSerializeIndependentBuilds && configService.currentSubPackageRoot !== previousSubPackageRoot) configService.options = {
27973
+ if (configService.currentSubPackageRoot !== previousSubPackageRoot) configService.options = {
27876
27974
  ...configService.options,
27877
27975
  currentSubPackageRoot: previousSubPackageRoot
27878
27976
  };
@@ -27975,7 +28073,7 @@ function createLoadHook(state) {
27975
28073
  configService.weappViteConfig?.debug?.load?.(id, subPackageMeta);
27976
28074
  if (isCSSRequest(id)) {
27977
28075
  const parsed = parseRequest(id);
27978
- if (parsed.query.wxss) {
28076
+ if (parsed.query.wxss || parsed.query.nativeStyle) {
27979
28077
  const realPath = getCssRealPath(parsed);
27980
28078
  try {
27981
28079
  return { code: await readFile$1(realPath, { checkMtime: configService.isDev }) };
@@ -28117,8 +28215,8 @@ async function collectLogicalEntryDependencies(state, ownerId) {
28117
28215
  const entry = resolveEntryRecord(state, ownerId);
28118
28216
  const [jsonEntry, templateEntry, styleEntry] = await Promise.all([
28119
28217
  findJsonEntry(ownerId),
28120
- findTemplateEntry(ownerId),
28121
- findCssEntry(ownerId)
28218
+ findTemplateEntry(ownerId, state.ctx.configService.platform),
28219
+ findCssEntry(ownerId, state.ctx.configService.platform)
28122
28220
  ]);
28123
28221
  await addExistingDependency("json", entry?.jsonPath ?? jsonEntry.path);
28124
28222
  await addExistingDependency("json", entry && "sitemapJsonPath" in entry ? entry.sitemapJsonPath : void 0);
@@ -28376,6 +28474,7 @@ const ATOMIC_SAVE_RECHECK_DELAYS_MS = [20, 60];
28376
28474
  const tailwindContentExtensions = /* @__PURE__ */ new Set([
28377
28475
  ".vue",
28378
28476
  ".wxml",
28477
+ ".axml",
28379
28478
  ".js",
28380
28479
  ".jsx",
28381
28480
  ".ts",
@@ -28602,7 +28701,7 @@ async function processChangedFile(state, id, event) {
28602
28701
  if (!shouldRefreshAppStyleForTailwindContent(state)) return false;
28603
28702
  const appEntryId = scanService.appEntry?.path ? normalizeFsResolvedId(scanService.appEntry.path) : void 0;
28604
28703
  if (!appEntryId || appEntryId === normalizedId || !resolvedEntryMap.has(appEntryId)) return false;
28605
- const styleEntry = await findCssEntry(appEntryId);
28704
+ const styleEntry = await findCssEntry(appEntryId, ctx.configService.platform);
28606
28705
  if (!styleEntry.path) return false;
28607
28706
  if (!await isTailwindAppStyleSource(styleEntry.path)) return false;
28608
28707
  if (concreteChangedEntryId !== appEntryId && (loadedEntrySet.has(concreteChangedEntryId) || resolvedEntryMap.has(concreteChangedEntryId))) markEntryDirtyWithCause(concreteChangedEntryId, "direct", "tailwind-content");
@@ -28948,16 +29047,17 @@ function createRequireAnalysisPlugin(state) {
28948
29047
  }
28949
29048
  //#endregion
28950
29049
  //#region src/plugins/core/wxss.ts
29050
+ const nativeStyleExtensionRe = new RegExp(`\\.(${ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS.join("|")})$`);
28951
29051
  function createWxssResolverPlugin(state) {
28952
29052
  return {
28953
- name: "weapp-vite:pre:wxss",
29053
+ name: "weapp-vite:pre:native-style",
28954
29054
  enforce: "pre",
28955
29055
  resolveId: {
28956
- filter: { id: /\.wxss$/ },
29056
+ filter: { id: nativeStyleExtensionRe },
28957
29057
  handler(id) {
28958
29058
  const startedAt = performance.now();
28959
29059
  try {
28960
- return id.replace(/\.wxss$/, ".css?wxss");
29060
+ return id.replace(nativeStyleExtensionRe, (_match, extension) => `.css?nativeStyle=${extension}`);
28961
29061
  } finally {
28962
29062
  const profile = state.ctx.runtimeState?.build?.hmr?.profile;
28963
29063
  recordHmrProfileDuration(profile, "pluginResolveMs", performance.now() - startedAt);
@@ -30755,7 +30855,7 @@ async function resolveNativeLayoutAssetState(options) {
30755
30855
  if (!resolvedOptions) return;
30756
30856
  return {
30757
30857
  resolvedOptions,
30758
- assets: await collectNativeLayoutAssets(options.layoutBasePath)
30858
+ assets: await collectNativeLayoutAssets(options.layoutBasePath, options.configService.platform)
30759
30859
  };
30760
30860
  }
30761
30861
  async function emitResolvedNativeLayoutStaticAssets(options) {
@@ -32002,6 +32102,9 @@ function workers(ctx) {
32002
32102
  const wxsCodeCache = new LRUCache({ max: 512 });
32003
32103
  const WXS_FILE_SUFFIX_RE = /\.(?:wxs|sjs)(\.[jt]s)?$/;
32004
32104
  const WXS_SCAN_RELEVANT_HMR_RE = /\.(?:vue|wxml|axml|swan|ttml|jxml|qml|ksml|xhsml|html|wxs|sjs)(?:\.[jt]s)?$/i;
32105
+ function createWxsCodeCacheKey(rawCode, scriptModuleExtension) {
32106
+ return `${scriptModuleExtension ?? "wxs"}::${rawCode}`;
32107
+ }
32005
32108
  function resolveWxsOutputFileName(ctx, wxsPath, scriptModuleExtension) {
32006
32109
  const suffixMatch = wxsPath.match(WXS_FILE_SUFFIX_RE);
32007
32110
  const isRaw = suffixMatch ? !suffixMatch[1] : true;
@@ -32021,7 +32124,8 @@ async function transformWxsFile(state, wxsPath) {
32021
32124
  filename: wxsPath,
32022
32125
  extension: scriptModuleExtension
32023
32126
  });
32024
- const code = wxsCodeCache.get(rawCode) ?? result?.code;
32127
+ const cacheKey = createWxsCodeCacheKey(rawCode, scriptModuleExtension);
32128
+ const code = wxsCodeCache.get(cacheKey) ?? result?.code;
32025
32129
  const dirname = path.dirname(wxsPath);
32026
32130
  const importeePaths = importees.map(({ source }) => path.resolve(dirname, source));
32027
32131
  await Promise.all(importeePaths.map((importeePath) => transformWxsFile.call(this, state, importeePath)));
@@ -32032,7 +32136,7 @@ async function transformWxsFile(state, wxsPath) {
32032
32136
  source: code
32033
32137
  };
32034
32138
  state.wxsMap.set(wxsPath, { emittedFile });
32035
- wxsCodeCache.set(rawCode, code);
32139
+ wxsCodeCache.set(cacheKey, code);
32036
32140
  }
32037
32141
  async function handleWxsDeps(state, deps, absPath) {
32038
32142
  await Promise.all(deps.filter((dep) => isScriptModuleTagName(dep.tagName)).map(async (dep) => {
@@ -33177,7 +33281,7 @@ async function loadAppEntry(ctx, scanState) {
33177
33281
  const { path: appEntryPath } = appEntry;
33178
33282
  let configFromVue;
33179
33283
  if (!appConfigFile && vueAppPath) {
33180
- const { extractConfigFromVue } = await import("./file-CQTcjEWz.mjs");
33284
+ const { extractConfigFromVue } = await import("./file-_4iQaFyw.mjs");
33181
33285
  configFromVue = await extractConfigFromVue(vueAppPath);
33182
33286
  if (configFromVue) appConfigFile = vueAppPath;
33183
33287
  }