weapp-vite 6.20.1 → 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.
- package/README.md +6 -0
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +203 -33
- package/dist/{config-Dd_PqIy2.d.mts → config-C810aRQQ.d.mts} +1 -0
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-DutRdQ_I.mjs → createContext-DiBG4uOB.mjs} +158 -103
- package/dist/docs/README.md +6 -0
- package/dist/docs/ai-workflows.md +1 -0
- package/dist/docs/troubleshooting.md +2 -0
- package/dist/{file-Bwxu2veP.mjs → file-DQ5FlYd5.mjs} +60 -16
- package/dist/file-_4iQaFyw.mjs +2 -0
- package/dist/getInstance-COmUPo24.mjs +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/test.mjs +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +16 -16
- package/dist/file-BG-q88IF.mjs +0 -2
- package/dist/getInstance-D8SEyLSD.mjs +0 -2
|
@@ -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-
|
|
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,
|
|
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(
|
|
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
|
-
|
|
4863
|
-
|
|
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 =
|
|
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);
|
|
@@ -10639,6 +10634,7 @@ class WeappViteDevRuntime extends BaseDevRuntime {
|
|
|
10639
10634
|
createModuleHotContext(moduleId) {
|
|
10640
10635
|
const previous = this.contexts.get(moduleId);
|
|
10641
10636
|
const context = new WeappViteHotContext(moduleId);
|
|
10637
|
+
this.registrationModuleId = moduleId;
|
|
10642
10638
|
if (previous) {
|
|
10643
10639
|
context.callbacks = previous.callbacks;
|
|
10644
10640
|
context.data = previous.data;
|
|
@@ -10734,6 +10730,10 @@ function rememberInstanceState(instance, moduleId) {
|
|
|
10734
10730
|
function trackInstance(instance, moduleId) {
|
|
10735
10731
|
getInstances(moduleId).add(instance);
|
|
10736
10732
|
if (instanceSnapshots.has(instance)) return;
|
|
10733
|
+
if ((wevuRefreshGenerations.get(moduleId) || 0) > 0) {
|
|
10734
|
+
rememberInstanceState(instance, moduleId);
|
|
10735
|
+
return;
|
|
10736
|
+
}
|
|
10737
10737
|
const snapshot = moduleSnapshots.get(moduleId);
|
|
10738
10738
|
if (snapshot) {
|
|
10739
10739
|
instanceSnapshots.set(instance, snapshot);
|
|
@@ -10761,7 +10761,11 @@ function rememberTrackedInstances() {
|
|
|
10761
10761
|
}
|
|
10762
10762
|
function restoreTrackedInstances() {
|
|
10763
10763
|
for (const [moduleId, values] of instances) {
|
|
10764
|
-
for (const instance of values)
|
|
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
|
+
}
|
|
10765
10769
|
}
|
|
10766
10770
|
}
|
|
10767
10771
|
function refreshWevuInstance(instance, moduleId) {
|
|
@@ -10836,63 +10840,81 @@ function decorateObject(value, moduleId, prefix = '', trackLifecycle = false) {
|
|
|
10836
10840
|
}
|
|
10837
10841
|
function decorateWevuComponent(definition, moduleId) {
|
|
10838
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
|
+
};
|
|
10839
10850
|
const methods = { ...(definition.methods || {}) };
|
|
10840
|
-
for (const
|
|
10841
|
-
|
|
10851
|
+
for (const name of Object.keys(methods)) {
|
|
10852
|
+
const fallback = methods[name];
|
|
10853
|
+
if (typeof fallback !== 'function') continue;
|
|
10842
10854
|
methods[name] = function (...args) {
|
|
10843
10855
|
trackInstance(this, moduleId);
|
|
10844
10856
|
refreshWevuInstance(this, moduleId);
|
|
10845
10857
|
try {
|
|
10846
|
-
return
|
|
10858
|
+
return callLatestWevuFunction(this, 'methods.' + name, fallback, args);
|
|
10847
10859
|
} finally {
|
|
10848
10860
|
rememberInstanceState(this, moduleId);
|
|
10849
10861
|
}
|
|
10850
10862
|
};
|
|
10851
10863
|
}
|
|
10852
10864
|
result.methods = methods;
|
|
10853
|
-
const
|
|
10854
|
-
const
|
|
10855
|
-
|
|
10856
|
-
|
|
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) {
|
|
10857
10870
|
trackInstance(this, moduleId);
|
|
10858
10871
|
refreshWevuInstance(this, moduleId);
|
|
10859
|
-
if (suppressLifecycles) return;
|
|
10860
|
-
|
|
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
|
+
}
|
|
10861
10879
|
};
|
|
10862
10880
|
}
|
|
10863
|
-
|
|
10864
|
-
|
|
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) {
|
|
10865
10886
|
if (suppressLifecycles) return;
|
|
10887
|
+
if (name === 'created' || name === 'attached') {
|
|
10888
|
+
trackInstance(this, moduleId);
|
|
10889
|
+
refreshWevuInstance(this, moduleId);
|
|
10890
|
+
}
|
|
10866
10891
|
try {
|
|
10867
|
-
return
|
|
10892
|
+
return callLatestWevuFunction(this, 'lifetimes.' + name, fallback, args);
|
|
10868
10893
|
} finally {
|
|
10869
|
-
forgetInstance(this, moduleId);
|
|
10894
|
+
if (name === 'detached') forgetInstance(this, moduleId);
|
|
10870
10895
|
}
|
|
10871
10896
|
};
|
|
10872
10897
|
}
|
|
10873
|
-
const
|
|
10874
|
-
const
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
}
|
|
10889
|
-
};
|
|
10890
|
-
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 };
|
|
10891
10913
|
}
|
|
10892
10914
|
function registerDefinition(name, definition, nativeRegistration) {
|
|
10893
10915
|
const moduleId = runtime.currentModuleId || runtime.registrationModuleId || name;
|
|
10894
10916
|
if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) return;
|
|
10895
|
-
definitions.set(moduleId, definition);
|
|
10917
|
+
if (!wevuRefreshes.has(moduleId)) definitions.set(moduleId, definition);
|
|
10896
10918
|
if (registered.has(moduleId)) {
|
|
10897
10919
|
return;
|
|
10898
10920
|
}
|
|
@@ -10921,8 +10943,17 @@ globalThis[bridgeKey] = {
|
|
|
10921
10943
|
return pending;
|
|
10922
10944
|
},
|
|
10923
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
|
+
},
|
|
10924
10955
|
trackWevuComponent(definition, refresh) {
|
|
10925
|
-
const moduleId = runtime.
|
|
10956
|
+
const moduleId = runtime.currentModuleId || runtime.registrationModuleId || 'Component';
|
|
10926
10957
|
if (!runtime.applyingPatch && runtime.patchedModules.has(moduleId)) {
|
|
10927
10958
|
return decorateWevuComponent(definition, moduleId);
|
|
10928
10959
|
}
|
|
@@ -10947,6 +10978,8 @@ globalThis[bridgeKey] = {
|
|
|
10947
10978
|
setTimeout(() => { suppressLifecycles = false; });
|
|
10948
10979
|
}
|
|
10949
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];
|
|
10950
10983
|
`;
|
|
10951
10984
|
function createStatefulHmrControlSource(control) {
|
|
10952
10985
|
return `
|
|
@@ -12269,6 +12302,7 @@ function createStatefulHmrBanner(chunk) {
|
|
|
12269
12302
|
return [
|
|
12270
12303
|
`require(${JSON.stringify(`${prefix}rolldown-runtime.js`)});`,
|
|
12271
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));`,
|
|
12272
12306
|
`require(${JSON.stringify(`${prefix}${WEAPP_VITE_STATEFUL_HMR_PRELOAD_FILE}`)});`,
|
|
12273
12307
|
`require(${JSON.stringify(`${prefix}${WEAPP_VITE_STATEFUL_HMR_UPDATE_FILE}`)});`
|
|
12274
12308
|
].join("");
|
|
@@ -13105,8 +13139,8 @@ async function collectMiniappConfigFile(pluginCtx, id, configService, jsonServic
|
|
|
13105
13139
|
type: "page"
|
|
13106
13140
|
});
|
|
13107
13141
|
}
|
|
13108
|
-
async function ensureTemplateScanned(pluginCtx, id, scanTemplateEntry, existsCache, ttlMs) {
|
|
13109
|
-
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);
|
|
13110
13144
|
await addPredictedWatchTargets(pluginCtx, predictions, existsCache, ttlMs, templateEntry);
|
|
13111
13145
|
if (!templateEntry) return "";
|
|
13112
13146
|
await scanTemplateEntry(templateEntry);
|
|
@@ -13160,8 +13194,8 @@ function collectVueTemplateAutoImportTags(template, filename) {
|
|
|
13160
13194
|
function collectScriptSetupImports(scriptSetup, templateComponentNames, options) {
|
|
13161
13195
|
return collectScriptSetupImportsFromCode(scriptSetup, templateComponentNames, options);
|
|
13162
13196
|
}
|
|
13163
|
-
async function scanTemplateEntry(pluginCtx, id, scanTemplateEntryFn, existsCache, ttlMs) {
|
|
13164
|
-
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);
|
|
13165
13199
|
}
|
|
13166
13200
|
async function applyScriptSetupUsingComponents(options) {
|
|
13167
13201
|
const { pluginCtx, vueEntryPath, source, templatePath, json, configService, wxmlService, reExportResolutionCache, externalComponentEntryMap } = options;
|
|
@@ -13379,6 +13413,7 @@ function normalizeWxsFilename(value, extension = "wxs") {
|
|
|
13379
13413
|
function transformWxsCode(code, options) {
|
|
13380
13414
|
const filename = options?.filename ?? "script.ts";
|
|
13381
13415
|
const extension = options?.extension ?? "wxs";
|
|
13416
|
+
const preserveEsmExports = extension.replace(/^\./, "") === "sjs";
|
|
13382
13417
|
const importees = [];
|
|
13383
13418
|
const maybePushImportee = (value) => {
|
|
13384
13419
|
if (typeof value !== "string" || !value) return;
|
|
@@ -13405,7 +13440,7 @@ function transformWxsCode(code, options) {
|
|
|
13405
13440
|
babelrc: false,
|
|
13406
13441
|
configFile: false,
|
|
13407
13442
|
presets: [[babelPresetEnv, {
|
|
13408
|
-
modules: "commonjs",
|
|
13443
|
+
modules: preserveEsmExports ? false : "commonjs",
|
|
13409
13444
|
targets: { ie: "11" }
|
|
13410
13445
|
}], babelPresetTypescript],
|
|
13411
13446
|
filename,
|
|
@@ -13437,6 +13472,7 @@ function transformWxsCode(code, options) {
|
|
|
13437
13472
|
p.replaceWith(t.callExpression(t.identifier("getRegExp"), args));
|
|
13438
13473
|
} },
|
|
13439
13474
|
MemberExpression: { enter(p) {
|
|
13475
|
+
if (preserveEsmExports) return;
|
|
13440
13476
|
const node = p.node;
|
|
13441
13477
|
if (!t.isIdentifier(node.object, { name: "exports" })) return;
|
|
13442
13478
|
const moduleExports = t.memberExpression(t.identifier("module"), t.identifier("exports"));
|
|
@@ -13558,7 +13594,7 @@ function createCacheKey$1(options) {
|
|
|
13558
13594
|
const importMetaExtension = options.importMetaExtension ?? "";
|
|
13559
13595
|
const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(options);
|
|
13560
13596
|
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}`;
|
|
13597
|
+
return `${options.removeComment ? 1 : 0}|${options.transformEvent ? 1 : 0}|${options.transformPlatformSyntax ? 1 : 0}|${extension}|${tag}|${templateExt}|${importMetaExtension}|${importMetaRelativePath}|${defineKeys}`;
|
|
13562
13598
|
}
|
|
13563
13599
|
function getCachedResult(data, cacheKey) {
|
|
13564
13600
|
return handleCache.get(data)?.get(cacheKey);
|
|
@@ -13596,6 +13632,7 @@ function handleWxml(data, options) {
|
|
|
13596
13632
|
importMetaExtension: void 0,
|
|
13597
13633
|
removeComment: true,
|
|
13598
13634
|
transformEvent: true,
|
|
13635
|
+
transformPlatformSyntax: true,
|
|
13599
13636
|
scriptModuleExtension: void 0,
|
|
13600
13637
|
scriptModuleTag: void 0,
|
|
13601
13638
|
templateExtension: void 0
|
|
@@ -13610,14 +13647,15 @@ function handleWxml(data, options) {
|
|
|
13610
13647
|
scriptModuleExtension: normalizedScriptExtension,
|
|
13611
13648
|
scriptModuleTag: opts.scriptModuleTag
|
|
13612
13649
|
});
|
|
13613
|
-
const
|
|
13614
|
-
const
|
|
13615
|
-
const
|
|
13616
|
-
const
|
|
13617
|
-
const
|
|
13618
|
-
const
|
|
13619
|
-
const
|
|
13620
|
-
const
|
|
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;
|
|
13621
13659
|
const shouldRemoveConditionals = removalRanges.length > 0;
|
|
13622
13660
|
const shouldRemoveComments = opts.removeComment && commentTokens.length > 0;
|
|
13623
13661
|
const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(opts);
|
|
@@ -13656,7 +13694,7 @@ function handleWxml(data, options) {
|
|
|
13656
13694
|
}
|
|
13657
13695
|
if (shouldRemoveComments) for (const { end, start } of commentTokens) ms.remove(start, end);
|
|
13658
13696
|
return setCachedResult(data, cacheKey, {
|
|
13659
|
-
code: replaceDefineImportMetaEnv(shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(), resolvedDefineImportMetaEnv),
|
|
13697
|
+
code: replaceDefineImportMetaEnv(shouldTransformPlatformSyntax && shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(), resolvedDefineImportMetaEnv),
|
|
13660
13698
|
components,
|
|
13661
13699
|
deps
|
|
13662
13700
|
});
|
|
@@ -14449,7 +14487,7 @@ async function collectAutoImportTemplateTags(ctx) {
|
|
|
14449
14487
|
const files = await new fdir({
|
|
14450
14488
|
includeDirs: false,
|
|
14451
14489
|
pathSeparator: "/"
|
|
14452
|
-
}).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();
|
|
14453
14491
|
const tags = /* @__PURE__ */ new Map();
|
|
14454
14492
|
const platform = resolveMiniPlatformWithDefault(ctx.configService?.platform);
|
|
14455
14493
|
await Promise.all(files.map(async (filePath) => {
|
|
@@ -21150,11 +21188,11 @@ function isLayoutFile(filename, configService) {
|
|
|
21150
21188
|
const layoutsRoot = `${normalizeWatchPath(path.join(configService.absoluteSrcRoot, "layouts"))}/`;
|
|
21151
21189
|
return normalizeWatchPath(filename).startsWith(layoutsRoot);
|
|
21152
21190
|
}
|
|
21153
|
-
async function collectNativeLayoutAssets(basePath) {
|
|
21191
|
+
async function collectNativeLayoutAssets(basePath, platform) {
|
|
21154
21192
|
const [jsonEntry, templateEntry, styleEntry, scriptEntry] = await Promise.all([
|
|
21155
21193
|
findJsonEntry(basePath),
|
|
21156
|
-
findTemplateEntry(basePath),
|
|
21157
|
-
findCssEntry(basePath),
|
|
21194
|
+
findTemplateEntry(basePath, platform),
|
|
21195
|
+
findCssEntry(basePath, platform),
|
|
21158
21196
|
findJsEntry(basePath)
|
|
21159
21197
|
]);
|
|
21160
21198
|
return {
|
|
@@ -21184,10 +21222,10 @@ function assertTemplateHasDefaultSlot(options) {
|
|
|
21184
21222
|
//#endregion
|
|
21185
21223
|
//#region src/plugins/utils/layoutEntries.ts
|
|
21186
21224
|
async function registerResolvedPageLayoutEntries(options) {
|
|
21187
|
-
const { layouts, entries, explicitEntryTypes, nativeScriptEntries, normalizeEntry, jsonPath } = options;
|
|
21225
|
+
const { layouts, entries, explicitEntryTypes, nativeScriptEntries, normalizeEntry, jsonPath, platform } = options;
|
|
21188
21226
|
for (const layout of layouts) {
|
|
21189
21227
|
if (layout.kind === "native") {
|
|
21190
|
-
if (!(await collectNativeLayoutAssets(layout.file)).script) continue;
|
|
21228
|
+
if (!(await collectNativeLayoutAssets(layout.file, platform)).script) continue;
|
|
21191
21229
|
}
|
|
21192
21230
|
entries.push(layout.importPath);
|
|
21193
21231
|
const normalizedEntry = normalizeEntry(layout.importPath, jsonPath);
|
|
@@ -21203,20 +21241,20 @@ function markComponentEntries(entriesMap, entries) {
|
|
|
21203
21241
|
}
|
|
21204
21242
|
//#endregion
|
|
21205
21243
|
//#region src/plugins/utils/pageLayout.ts
|
|
21206
|
-
async function expandResolvedPageLayoutFiles(layouts) {
|
|
21244
|
+
async function expandResolvedPageLayoutFiles(layouts, platform) {
|
|
21207
21245
|
const files = [];
|
|
21208
21246
|
for (const layout of layouts) {
|
|
21209
21247
|
if (layout.kind !== "native") {
|
|
21210
21248
|
files.push(layout.file);
|
|
21211
21249
|
continue;
|
|
21212
21250
|
}
|
|
21213
|
-
const nativeAssets = await collectNativeLayoutAssets(layout.file);
|
|
21251
|
+
const nativeAssets = await collectNativeLayoutAssets(layout.file, platform);
|
|
21214
21252
|
for (const asset of Object.values(nativeAssets)) if (asset) files.push(asset);
|
|
21215
21253
|
}
|
|
21216
21254
|
return files;
|
|
21217
21255
|
}
|
|
21218
21256
|
async function registerResolvedPageLayoutDependencies(ctx, ownerId, layouts) {
|
|
21219
|
-
const dependencies = await expandResolvedPageLayoutFiles(layouts);
|
|
21257
|
+
const dependencies = await expandResolvedPageLayoutFiles(layouts, ctx.configService.platform);
|
|
21220
21258
|
const transitiveDependencies = new Set(dependencies);
|
|
21221
21259
|
for (const file of dependencies) {
|
|
21222
21260
|
if (!isTemplate(file)) continue;
|
|
@@ -21864,7 +21902,7 @@ function resolveWxmlEmitTargets(options) {
|
|
|
21864
21902
|
return Array.from(wxmlService.tokenMap.entries()).map(([id, token]) => resolveTarget(id, token)).filter((target) => Boolean(target));
|
|
21865
21903
|
}
|
|
21866
21904
|
function emitWxmlAssetFile(options) {
|
|
21867
|
-
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;
|
|
21868
21906
|
runtime.addWatchFile?.(normalizeWatchPath(id));
|
|
21869
21907
|
if (deps) for (const dep of deps) runtime.addWatchFile?.(normalizeWatchPath(dep));
|
|
21870
21908
|
const result = handleWxml(token, {
|
|
@@ -21873,7 +21911,8 @@ function emitWxmlAssetFile(options) {
|
|
|
21873
21911
|
importMetaRelativePath: fileName,
|
|
21874
21912
|
scriptModuleExtension,
|
|
21875
21913
|
scriptModuleTag,
|
|
21876
|
-
templateExtension
|
|
21914
|
+
templateExtension,
|
|
21915
|
+
transformPlatformSyntax: !isNativeTemplateSource(id, platform)
|
|
21877
21916
|
});
|
|
21878
21917
|
if (emittedCodeCache.get(fileName) === result.code) return false;
|
|
21879
21918
|
emittedCodeCache.set(fileName, result.code);
|
|
@@ -21906,7 +21945,8 @@ function emitWxmlAssetsWithCache(options) {
|
|
|
21906
21945
|
importMetaDefineRegistry: configService.importMetaDefineRegistry,
|
|
21907
21946
|
scriptModuleExtension,
|
|
21908
21947
|
scriptModuleTag,
|
|
21909
|
-
templateExtension
|
|
21948
|
+
templateExtension,
|
|
21949
|
+
platform: configService.platform
|
|
21910
21950
|
});
|
|
21911
21951
|
}
|
|
21912
21952
|
return emittedFiles;
|
|
@@ -22009,7 +22049,7 @@ async function emitEntryOutput(options) {
|
|
|
22009
22049
|
outputExtensions: configService.outputExtensions
|
|
22010
22050
|
});
|
|
22011
22051
|
if (!resolvedOptions) return;
|
|
22012
|
-
const assets = await collectNativeLayoutAssets(layoutBasePath);
|
|
22052
|
+
const assets = await collectNativeLayoutAssets(layoutBasePath, configService.platform);
|
|
22013
22053
|
const emittedLayoutAssets = pluginCtx.__weappViteNativeLayoutAssets ?? (pluginCtx.__weappViteNativeLayoutAssets = /* @__PURE__ */ new Set());
|
|
22014
22054
|
if (assets.json) registerJsonAsset({
|
|
22015
22055
|
jsonPath: assets.json,
|
|
@@ -22135,7 +22175,7 @@ async function emitEntryOutput(options) {
|
|
|
22135
22175
|
});
|
|
22136
22176
|
if (layoutPlan) {
|
|
22137
22177
|
const layoutDependencies = /* @__PURE__ */ new Set();
|
|
22138
|
-
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));
|
|
22139
22179
|
replaceLayoutDependencies(id, layoutDependencies);
|
|
22140
22180
|
const nativeTemplate = await readFile$1(templatePath, { checkMtime: configService.isDev });
|
|
22141
22181
|
const transformed = applyPageLayoutPlanToNativePage({
|
|
@@ -22439,7 +22479,7 @@ function createEntryLoader(options) {
|
|
|
22439
22479
|
const registerPageLayoutComponentEntries = async (layoutPlan, options) => {
|
|
22440
22480
|
if (options?.trackLayoutDependencies) {
|
|
22441
22481
|
const layoutDependencies = /* @__PURE__ */ new Set();
|
|
22442
|
-
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));
|
|
22443
22483
|
replaceLayoutDependencies(normalizedId, layoutDependencies);
|
|
22444
22484
|
}
|
|
22445
22485
|
await registerResolvedPageLayoutDependencies(ctx, normalizedId, layoutPlan.layouts);
|
|
@@ -22449,7 +22489,8 @@ function createEntryLoader(options) {
|
|
|
22449
22489
|
explicitEntryTypes,
|
|
22450
22490
|
nativeScriptEntries: nativeLayoutScriptEntries,
|
|
22451
22491
|
normalizeEntry,
|
|
22452
|
-
jsonPath
|
|
22492
|
+
jsonPath,
|
|
22493
|
+
platform: configService.platform
|
|
22453
22494
|
});
|
|
22454
22495
|
for (const layout of layoutPlan.layouts) {
|
|
22455
22496
|
if (layout.kind === "native") continue;
|
|
@@ -22523,7 +22564,7 @@ function createEntryLoader(options) {
|
|
|
22523
22564
|
} else {
|
|
22524
22565
|
const templateScanStartedAt = performance$1.now();
|
|
22525
22566
|
try {
|
|
22526
|
-
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);
|
|
22527
22568
|
templateEntryPathCache.set(normalizedId, templatePath);
|
|
22528
22569
|
} finally {
|
|
22529
22570
|
recordEntryDuration("entryTemplateScanMs", templateScanStartedAt);
|
|
@@ -22531,7 +22572,7 @@ function createEntryLoader(options) {
|
|
|
22531
22572
|
if (libEntry && libConfig) {
|
|
22532
22573
|
const componentJson = libConfig.componentJson ?? "auto";
|
|
22533
22574
|
const hasTemplate = Boolean(templatePath) || id.endsWith(".vue");
|
|
22534
|
-
const styleEntry = await findCssEntry(baseName);
|
|
22575
|
+
const styleEntry = await findCssEntry(baseName, configService.platform);
|
|
22535
22576
|
const hasStyle = Boolean(styleEntry.path);
|
|
22536
22577
|
const shouldTreatAsComponent = hasTemplate || hasStyle || Boolean(json?.component);
|
|
22537
22578
|
if (!hasJsonEntry && shouldTreatAsComponent) {
|
|
@@ -25134,13 +25175,13 @@ function injectSharedStyleImports(css, modulePath, fileName, sharedStyles, confi
|
|
|
25134
25175
|
//#region src/plugins/css.ts
|
|
25135
25176
|
const LEADING_BLANK_LINES_RE = /^(?:[ \t]*\r?\n)+/;
|
|
25136
25177
|
const TAILWIND_CONTENT_HMR_NONCE_RE = /\n\/\* weapp-vite tailwind-content [^*\n]+ \*\/$/;
|
|
25137
|
-
const
|
|
25138
|
-
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)$/;
|
|
25139
25179
|
function stripLeadingBlankLines(code) {
|
|
25140
25180
|
return code.replace(LEADING_BLANK_LINES_RE, "");
|
|
25141
25181
|
}
|
|
25142
25182
|
function isSourceStyleAsset(fileName) {
|
|
25143
|
-
|
|
25183
|
+
const extension = path.extname(fileName);
|
|
25184
|
+
return isSourceStyleExtension(extension) || /\.(?:stylus|pcss|postcss|sss)$/.test(fileName);
|
|
25144
25185
|
}
|
|
25145
25186
|
function hasStyleDirtyReason(dirtyReasonSummary) {
|
|
25146
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:"));
|
|
@@ -25157,8 +25198,7 @@ function stripTailwindContentHmrNonce(source) {
|
|
|
25157
25198
|
}
|
|
25158
25199
|
function isStyleBundleAsset(output, bundleKey) {
|
|
25159
25200
|
if (output.type !== "asset") return false;
|
|
25160
|
-
|
|
25161
|
-
return fileName.endsWith(".css") || fileName.endsWith(".wxss") || isSourceStyleAsset(fileName);
|
|
25201
|
+
return isSourceStyleAsset(output.fileName || bundleKey);
|
|
25162
25202
|
}
|
|
25163
25203
|
function hasStyleBundleAsset(bundle) {
|
|
25164
25204
|
for (const [bundleKey, output] of Object.entries(bundle)) if (isStyleBundleAsset(output, bundleKey)) return true;
|
|
@@ -25665,6 +25705,10 @@ function normalizeTemplateAssetEntries(ctx, entries) {
|
|
|
25665
25705
|
if (!mayNeedTemplateNormalization(code, configService?.platform)) continue;
|
|
25666
25706
|
const result = handleWxml(scanWxml(code, { platform: configService?.platform }), {
|
|
25667
25707
|
scriptModuleExtension: configService?.outputExtensions?.wxs,
|
|
25708
|
+
scriptModuleTag: resolveScriptModuleTagName({
|
|
25709
|
+
platform: configService?.platform,
|
|
25710
|
+
scriptModuleExtension: configService?.outputExtensions?.wxs
|
|
25711
|
+
}),
|
|
25668
25712
|
templateExtension: configService?.outputExtensions?.wxml
|
|
25669
25713
|
});
|
|
25670
25714
|
if (result.code !== code) output.source = result.code;
|
|
@@ -26587,6 +26631,10 @@ function toRequireRequestPath(fromFileName, toFileName) {
|
|
|
26587
26631
|
const relativePath = toPosixPath(path.relative(path.dirname(fromFileName), toFileName));
|
|
26588
26632
|
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
26589
26633
|
}
|
|
26634
|
+
function isRequestGlobalsSupportChunkFileName(fileName) {
|
|
26635
|
+
const baseName = path.basename(toPosixPath(fileName));
|
|
26636
|
+
return baseName.startsWith("request-globals-") || baseName === "web-apis-shared.js";
|
|
26637
|
+
}
|
|
26590
26638
|
function rewriteChunkRequireLiteral(chunk, fromFileName, toFileName) {
|
|
26591
26639
|
let didRewrite = false;
|
|
26592
26640
|
const nextCode = chunk.code.replaceAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE, (...args) => {
|
|
@@ -26708,7 +26756,7 @@ function collapseRequestGlobalsRuntimeSupportChunk(bundle) {
|
|
|
26708
26756
|
const resolvedImport = normalizeRelativeChunkImport(runtimeOutput.fileName, importee);
|
|
26709
26757
|
const supportChunk = bundle[resolvedImport];
|
|
26710
26758
|
if (!supportChunk || supportChunk.type !== "chunk") continue;
|
|
26711
|
-
if (resolvedImport === "weapp-vendors/request-globals-runtime.js" || !
|
|
26759
|
+
if (resolvedImport === "weapp-vendors/request-globals-runtime.js" || !isRequestGlobalsSupportChunkFileName(resolvedImport)) continue;
|
|
26712
26760
|
supportChunkFileName = resolvedImport;
|
|
26713
26761
|
runtimeRequireMatch = requireMatch;
|
|
26714
26762
|
break;
|
|
@@ -27644,6 +27692,7 @@ function parseRequest(id) {
|
|
|
27644
27692
|
* @returns 返回文件的真实路径。
|
|
27645
27693
|
*/
|
|
27646
27694
|
function getCssRealPath(res) {
|
|
27695
|
+
if (typeof res.query.nativeStyle === "string" && res.query.nativeStyle) return changeFileExtension(res.filename, res.query.nativeStyle);
|
|
27647
27696
|
if (res.query.wxss) return changeFileExtension(res.filename, "wxss");
|
|
27648
27697
|
return res.filename;
|
|
27649
27698
|
}
|
|
@@ -28024,7 +28073,7 @@ function createLoadHook(state) {
|
|
|
28024
28073
|
configService.weappViteConfig?.debug?.load?.(id, subPackageMeta);
|
|
28025
28074
|
if (isCSSRequest(id)) {
|
|
28026
28075
|
const parsed = parseRequest(id);
|
|
28027
|
-
if (parsed.query.wxss) {
|
|
28076
|
+
if (parsed.query.wxss || parsed.query.nativeStyle) {
|
|
28028
28077
|
const realPath = getCssRealPath(parsed);
|
|
28029
28078
|
try {
|
|
28030
28079
|
return { code: await readFile$1(realPath, { checkMtime: configService.isDev }) };
|
|
@@ -28166,8 +28215,8 @@ async function collectLogicalEntryDependencies(state, ownerId) {
|
|
|
28166
28215
|
const entry = resolveEntryRecord(state, ownerId);
|
|
28167
28216
|
const [jsonEntry, templateEntry, styleEntry] = await Promise.all([
|
|
28168
28217
|
findJsonEntry(ownerId),
|
|
28169
|
-
findTemplateEntry(ownerId),
|
|
28170
|
-
findCssEntry(ownerId)
|
|
28218
|
+
findTemplateEntry(ownerId, state.ctx.configService.platform),
|
|
28219
|
+
findCssEntry(ownerId, state.ctx.configService.platform)
|
|
28171
28220
|
]);
|
|
28172
28221
|
await addExistingDependency("json", entry?.jsonPath ?? jsonEntry.path);
|
|
28173
28222
|
await addExistingDependency("json", entry && "sitemapJsonPath" in entry ? entry.sitemapJsonPath : void 0);
|
|
@@ -28425,6 +28474,7 @@ const ATOMIC_SAVE_RECHECK_DELAYS_MS = [20, 60];
|
|
|
28425
28474
|
const tailwindContentExtensions = /* @__PURE__ */ new Set([
|
|
28426
28475
|
".vue",
|
|
28427
28476
|
".wxml",
|
|
28477
|
+
".axml",
|
|
28428
28478
|
".js",
|
|
28429
28479
|
".jsx",
|
|
28430
28480
|
".ts",
|
|
@@ -28651,7 +28701,7 @@ async function processChangedFile(state, id, event) {
|
|
|
28651
28701
|
if (!shouldRefreshAppStyleForTailwindContent(state)) return false;
|
|
28652
28702
|
const appEntryId = scanService.appEntry?.path ? normalizeFsResolvedId(scanService.appEntry.path) : void 0;
|
|
28653
28703
|
if (!appEntryId || appEntryId === normalizedId || !resolvedEntryMap.has(appEntryId)) return false;
|
|
28654
|
-
const styleEntry = await findCssEntry(appEntryId);
|
|
28704
|
+
const styleEntry = await findCssEntry(appEntryId, ctx.configService.platform);
|
|
28655
28705
|
if (!styleEntry.path) return false;
|
|
28656
28706
|
if (!await isTailwindAppStyleSource(styleEntry.path)) return false;
|
|
28657
28707
|
if (concreteChangedEntryId !== appEntryId && (loadedEntrySet.has(concreteChangedEntryId) || resolvedEntryMap.has(concreteChangedEntryId))) markEntryDirtyWithCause(concreteChangedEntryId, "direct", "tailwind-content");
|
|
@@ -28997,16 +29047,17 @@ function createRequireAnalysisPlugin(state) {
|
|
|
28997
29047
|
}
|
|
28998
29048
|
//#endregion
|
|
28999
29049
|
//#region src/plugins/core/wxss.ts
|
|
29050
|
+
const nativeStyleExtensionRe = new RegExp(`\\.(${ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS.join("|")})$`);
|
|
29000
29051
|
function createWxssResolverPlugin(state) {
|
|
29001
29052
|
return {
|
|
29002
|
-
name: "weapp-vite:pre:
|
|
29053
|
+
name: "weapp-vite:pre:native-style",
|
|
29003
29054
|
enforce: "pre",
|
|
29004
29055
|
resolveId: {
|
|
29005
|
-
filter: { id:
|
|
29056
|
+
filter: { id: nativeStyleExtensionRe },
|
|
29006
29057
|
handler(id) {
|
|
29007
29058
|
const startedAt = performance.now();
|
|
29008
29059
|
try {
|
|
29009
|
-
return id.replace(
|
|
29060
|
+
return id.replace(nativeStyleExtensionRe, (_match, extension) => `.css?nativeStyle=${extension}`);
|
|
29010
29061
|
} finally {
|
|
29011
29062
|
const profile = state.ctx.runtimeState?.build?.hmr?.profile;
|
|
29012
29063
|
recordHmrProfileDuration(profile, "pluginResolveMs", performance.now() - startedAt);
|
|
@@ -30804,7 +30855,7 @@ async function resolveNativeLayoutAssetState(options) {
|
|
|
30804
30855
|
if (!resolvedOptions) return;
|
|
30805
30856
|
return {
|
|
30806
30857
|
resolvedOptions,
|
|
30807
|
-
assets: await collectNativeLayoutAssets(options.layoutBasePath)
|
|
30858
|
+
assets: await collectNativeLayoutAssets(options.layoutBasePath, options.configService.platform)
|
|
30808
30859
|
};
|
|
30809
30860
|
}
|
|
30810
30861
|
async function emitResolvedNativeLayoutStaticAssets(options) {
|
|
@@ -32051,6 +32102,9 @@ function workers(ctx) {
|
|
|
32051
32102
|
const wxsCodeCache = new LRUCache({ max: 512 });
|
|
32052
32103
|
const WXS_FILE_SUFFIX_RE = /\.(?:wxs|sjs)(\.[jt]s)?$/;
|
|
32053
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
|
+
}
|
|
32054
32108
|
function resolveWxsOutputFileName(ctx, wxsPath, scriptModuleExtension) {
|
|
32055
32109
|
const suffixMatch = wxsPath.match(WXS_FILE_SUFFIX_RE);
|
|
32056
32110
|
const isRaw = suffixMatch ? !suffixMatch[1] : true;
|
|
@@ -32070,7 +32124,8 @@ async function transformWxsFile(state, wxsPath) {
|
|
|
32070
32124
|
filename: wxsPath,
|
|
32071
32125
|
extension: scriptModuleExtension
|
|
32072
32126
|
});
|
|
32073
|
-
const
|
|
32127
|
+
const cacheKey = createWxsCodeCacheKey(rawCode, scriptModuleExtension);
|
|
32128
|
+
const code = wxsCodeCache.get(cacheKey) ?? result?.code;
|
|
32074
32129
|
const dirname = path.dirname(wxsPath);
|
|
32075
32130
|
const importeePaths = importees.map(({ source }) => path.resolve(dirname, source));
|
|
32076
32131
|
await Promise.all(importeePaths.map((importeePath) => transformWxsFile.call(this, state, importeePath)));
|
|
@@ -32081,7 +32136,7 @@ async function transformWxsFile(state, wxsPath) {
|
|
|
32081
32136
|
source: code
|
|
32082
32137
|
};
|
|
32083
32138
|
state.wxsMap.set(wxsPath, { emittedFile });
|
|
32084
|
-
wxsCodeCache.set(
|
|
32139
|
+
wxsCodeCache.set(cacheKey, code);
|
|
32085
32140
|
}
|
|
32086
32141
|
async function handleWxsDeps(state, deps, absPath) {
|
|
32087
32142
|
await Promise.all(deps.filter((dep) => isScriptModuleTagName(dep.tagName)).map(async (dep) => {
|
|
@@ -33226,7 +33281,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
33226
33281
|
const { path: appEntryPath } = appEntry;
|
|
33227
33282
|
let configFromVue;
|
|
33228
33283
|
if (!appConfigFile && vueAppPath) {
|
|
33229
|
-
const { extractConfigFromVue } = await import("./file-
|
|
33284
|
+
const { extractConfigFromVue } = await import("./file-_4iQaFyw.mjs");
|
|
33230
33285
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
33231
33286
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
33232
33287
|
}
|