weapp-vite 6.16.26 → 6.16.28
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 +1 -1
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/{config-DJ3SOkf9.d.mts → config-s5bMI_-z.d.mts} +6 -2
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-D64s5KsN.mjs → createContext-e20SKsa-.mjs} +989 -691
- package/dist/docs/README.md +1 -1
- package/dist/docs/vue-sfc.md +6 -4
- package/dist/docs/weapp-config.md +4 -4
- package/dist/{file-B8gSIRd0.mjs → file-6emWhSkC.mjs} +1 -1
- package/dist/file-C85Sj-OD.mjs +2 -0
- package/dist/getInstance-DMap3kp4.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/types.d.mts +1 -1
- package/package.json +11 -11
- package/dist/file-Cjctfg-V.mjs +0 -2
- package/dist/getInstance-CjO8kDWJ.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 vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-
|
|
3
|
+
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-6emWhSkC.mjs";
|
|
4
4
|
import { createRequire, isBuiltin } from "node:module";
|
|
5
5
|
import path, { posix } from "pathe";
|
|
6
6
|
import path$1, { normalize, relative, win32 } from "node:path";
|
|
@@ -34,6 +34,7 @@ import { getPackageInfo, getPackageInfoSync, resolveModule } from "local-pkg";
|
|
|
34
34
|
import { spawn } from "node:child_process";
|
|
35
35
|
import * as t from "@weapp-vite/ast/babelTypes";
|
|
36
36
|
import { objectHash } from "@weapp-core/shared/node";
|
|
37
|
+
import PQueue from "p-queue";
|
|
37
38
|
import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEVU_APP_SHELL_COMPONENT_BASE, WEVU_APP_SHELL_TAG_NAME, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
|
|
38
39
|
import { Buffer } from "node:buffer";
|
|
39
40
|
import { detect } from "package-manager-detector/detect";
|
|
@@ -47,7 +48,6 @@ import postcss from "postcss";
|
|
|
47
48
|
import remapping from "@jridgewell/remapping";
|
|
48
49
|
import { weappWebPlugin } from "@weapp-vite/web";
|
|
49
50
|
import { bundleRequire } from "rolldown-require";
|
|
50
|
-
import PQueue from "p-queue";
|
|
51
51
|
//#region src/runtime/autoImport/config/base.ts
|
|
52
52
|
const DEFAULT_AUTO_IMPORT_MANIFEST_FILENAME = "auto-import-components.json";
|
|
53
53
|
const WEAPP_VITE_INTERNAL_DIRNAME = ".weapp-vite";
|
|
@@ -1683,10 +1683,12 @@ function formatGlobalComponentEntry(name, metadata, sourceImport) {
|
|
|
1683
1683
|
function formatGlobalConstEntry(name, metadata, sourceImport) {
|
|
1684
1684
|
if (!isValidIdentifierName(name)) return;
|
|
1685
1685
|
const propsType = formatPropsType(metadata.types);
|
|
1686
|
-
const baseType = propsType.includes("\n") ?
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1686
|
+
const baseType = propsType.includes("\n") ? (() => {
|
|
1687
|
+
return `WeappComponent<${propsType.split("\n").map((line, index) => {
|
|
1688
|
+
if (index === 0) return line;
|
|
1689
|
+
return ` ${line}`;
|
|
1690
|
+
}).join("\n")}>`;
|
|
1691
|
+
})() : `WeappComponent<${propsType}>`;
|
|
1690
1692
|
return ` const ${name}: ${sourceImport ? formatComponentTypeWithSourceImport(sourceImport, baseType) : baseType}`;
|
|
1691
1693
|
}
|
|
1692
1694
|
function createVueComponentsDefinition(componentNames, getMetadata, options = {}) {
|
|
@@ -4714,13 +4716,27 @@ function jsonFileRemoveJsExtension(fileName) {
|
|
|
4714
4716
|
function stringifyJson(value, replacer) {
|
|
4715
4717
|
return stringify(value, replacer, 2);
|
|
4716
4718
|
}
|
|
4719
|
+
function normalizeAppJson(json) {
|
|
4720
|
+
if (!json || typeof json !== "object" || Array.isArray(json)) return json;
|
|
4721
|
+
const subPackages = Array.isArray(json.subPackages) ? json.subPackages : Array.isArray(json.subpackages) ? json.subpackages : [];
|
|
4722
|
+
const { subpackages: _subpackages, ...rest } = json;
|
|
4723
|
+
return {
|
|
4724
|
+
...rest,
|
|
4725
|
+
subPackages: subPackages.map((subPackage) => ({
|
|
4726
|
+
...subPackage,
|
|
4727
|
+
pages: Array.isArray(subPackage?.pages) ? subPackage.pages : []
|
|
4728
|
+
}))
|
|
4729
|
+
};
|
|
4730
|
+
}
|
|
4717
4731
|
function matches(pattern, importee) {
|
|
4718
4732
|
if (pattern instanceof RegExp) return pattern.test(importee);
|
|
4719
4733
|
if (importee.length < pattern.length) return false;
|
|
4720
4734
|
if (importee === pattern) return true;
|
|
4721
4735
|
return importee.startsWith(pattern + "/");
|
|
4722
4736
|
}
|
|
4723
|
-
function getAliasEntries(
|
|
4737
|
+
function getAliasEntries(options = {}) {
|
|
4738
|
+
if (options === false) return [];
|
|
4739
|
+
const { entries } = options;
|
|
4724
4740
|
if (!entries) return [];
|
|
4725
4741
|
if (Array.isArray(entries)) return entries.map((entry) => {
|
|
4726
4742
|
return {
|
|
@@ -4791,7 +4807,7 @@ function normalizeComponentGenericsByPlatform(componentGenerics, platform) {
|
|
|
4791
4807
|
}
|
|
4792
4808
|
function resolveJson(entry, aliasEntries, platform, options) {
|
|
4793
4809
|
if (entry.json) {
|
|
4794
|
-
const json = structuredClone(entry.json);
|
|
4810
|
+
const json = entry.type === "app" ? normalizeAppJson(structuredClone(entry.json)) : structuredClone(entry.json);
|
|
4795
4811
|
if (entry.jsonPath && Array.isArray(aliasEntries)) {
|
|
4796
4812
|
const usingComponents = get(json, "usingComponents");
|
|
4797
4813
|
if (isObject(usingComponents)) {
|
|
@@ -5869,6 +5885,85 @@ function createAutoRoutesMatcher(include, subPackageRoots = []) {
|
|
|
5869
5885
|
};
|
|
5870
5886
|
}
|
|
5871
5887
|
//#endregion
|
|
5888
|
+
//#region src/autoRoutesConfig.ts
|
|
5889
|
+
function resolveWeappAutoRoutesConfig(config) {
|
|
5890
|
+
if (config == null || config === false) return {
|
|
5891
|
+
enabled: false,
|
|
5892
|
+
typedRouter: false,
|
|
5893
|
+
include: [...DEFAULT_AUTO_ROUTE_INCLUDE],
|
|
5894
|
+
persistentCache: false,
|
|
5895
|
+
watch: false
|
|
5896
|
+
};
|
|
5897
|
+
const record = typeof config === "object" && config ? config : {};
|
|
5898
|
+
return {
|
|
5899
|
+
enabled: config === true || record.enabled !== false,
|
|
5900
|
+
typedRouter: record.typedRouter !== false,
|
|
5901
|
+
include: record.include == null ? [...DEFAULT_AUTO_ROUTE_INCLUDE] : Array.isArray(record.include) ? [...record.include] : [record.include],
|
|
5902
|
+
persistentCache: typeof record.persistentCache === "string" || record.persistentCache === true,
|
|
5903
|
+
persistentCachePath: typeof record.persistentCache === "string" ? record.persistentCache : void 0,
|
|
5904
|
+
watch: record.watch !== false
|
|
5905
|
+
};
|
|
5906
|
+
}
|
|
5907
|
+
//#endregion
|
|
5908
|
+
//#region src/runtime/autoRoutesPlugin/generatedPaths.ts
|
|
5909
|
+
const AUTO_ROUTES_CACHE_FILE$1 = ".weapp-vite/auto-routes.cache.json";
|
|
5910
|
+
const TYPED_ROUTER_OUTPUT_FILE$1 = ".weapp-vite/typed-router.d.ts";
|
|
5911
|
+
const GENERATED_DIRECTORY_NAMES = new Set([
|
|
5912
|
+
".cache",
|
|
5913
|
+
".rolldown-require",
|
|
5914
|
+
".rolldown-require-cache",
|
|
5915
|
+
".tmp",
|
|
5916
|
+
".weapp-vite",
|
|
5917
|
+
".wevu-config",
|
|
5918
|
+
"__temp__",
|
|
5919
|
+
"coverage",
|
|
5920
|
+
"dist",
|
|
5921
|
+
"miniprogram_npm",
|
|
5922
|
+
"node_modules"
|
|
5923
|
+
]);
|
|
5924
|
+
const GENERATED_FILE_NAMES = new Set([path.basename(AUTO_ROUTES_CACHE_FILE$1), path.basename(TYPED_ROUTER_OUTPUT_FILE$1)]);
|
|
5925
|
+
function stripQuery(candidate) {
|
|
5926
|
+
return candidate.split("?")[0];
|
|
5927
|
+
}
|
|
5928
|
+
function resolveGeneratedCandidatePath(candidate, cwd) {
|
|
5929
|
+
const pathWithoutQuery = stripQuery(candidate);
|
|
5930
|
+
if (!pathWithoutQuery) return;
|
|
5931
|
+
return normalizePath$1(path.isAbsolute(pathWithoutQuery) ? pathWithoutQuery : path.resolve(cwd, pathWithoutQuery));
|
|
5932
|
+
}
|
|
5933
|
+
function isAutoRoutesGeneratedDirectoryName(name) {
|
|
5934
|
+
return GENERATED_DIRECTORY_NAMES.has(name);
|
|
5935
|
+
}
|
|
5936
|
+
function isAutoRoutesGeneratedFileName(fileName) {
|
|
5937
|
+
return GENERATED_FILE_NAMES.has(fileName) || fileName.includes(".auto-routes.") || fileName.includes(".auto-routes-");
|
|
5938
|
+
}
|
|
5939
|
+
function isAutoRoutesGeneratedRelativePath(relativePath) {
|
|
5940
|
+
const segments = toPosixPath(relativePath).split("/").filter(Boolean);
|
|
5941
|
+
if (segments.some(isAutoRoutesGeneratedDirectoryName)) return true;
|
|
5942
|
+
const fileName = segments[segments.length - 1];
|
|
5943
|
+
return Boolean(fileName && isAutoRoutesGeneratedFileName(fileName));
|
|
5944
|
+
}
|
|
5945
|
+
function resolveAutoRoutesManagedOutputPaths(ctx) {
|
|
5946
|
+
const configService = ctx.configService;
|
|
5947
|
+
const outputPaths = /* @__PURE__ */ new Set();
|
|
5948
|
+
if (!configService) return outputPaths;
|
|
5949
|
+
const baseDir = typeof configService.configFilePath === "string" ? path.dirname(configService.configFilePath) : configService.cwd;
|
|
5950
|
+
if (!baseDir) return outputPaths;
|
|
5951
|
+
outputPaths.add(normalizePath$1(path.resolve(baseDir, TYPED_ROUTER_OUTPUT_FILE$1)));
|
|
5952
|
+
outputPaths.add(normalizePath$1(path.resolve(baseDir, AUTO_ROUTES_CACHE_FILE$1)));
|
|
5953
|
+
const autoRoutesConfig = resolveWeappAutoRoutesConfig(configService.weappViteConfig?.autoRoutes);
|
|
5954
|
+
if (autoRoutesConfig.persistentCache) outputPaths.add(normalizePath$1(path.resolve(baseDir, autoRoutesConfig.persistentCachePath ?? AUTO_ROUTES_CACHE_FILE$1)));
|
|
5955
|
+
return outputPaths;
|
|
5956
|
+
}
|
|
5957
|
+
function isAutoRoutesGeneratedPath(candidate, options) {
|
|
5958
|
+
const absolutePath = resolveGeneratedCandidatePath(candidate, options.cwd);
|
|
5959
|
+
if (!absolutePath) return false;
|
|
5960
|
+
for (const outputPath of options.managedOutputPaths ?? []) if (absolutePath === normalizePath$1(outputPath)) return true;
|
|
5961
|
+
const normalizedSrcRoot = normalizePath$1(options.absoluteSrcRoot);
|
|
5962
|
+
const relativePath = toPosixPath(path.relative(normalizedSrcRoot, absolutePath));
|
|
5963
|
+
if (!relativePath || relativePath.startsWith("..") || path.isAbsolute(relativePath)) return false;
|
|
5964
|
+
return isAutoRoutesGeneratedRelativePath(relativePath);
|
|
5965
|
+
}
|
|
5966
|
+
//#endregion
|
|
5872
5967
|
//#region src/runtime/autoRoutesPlugin/candidates.ts
|
|
5873
5968
|
const SCRIPT_EXTENSIONS = new Set(jsExtensions.map((ext) => `.${ext}`));
|
|
5874
5969
|
const TEMPLATE_EXTENSIONS = new Set(templateExtensions.map((ext) => `.${ext}`));
|
|
@@ -5876,15 +5971,10 @@ const VUE_EXTENSIONS = new Set(vueExtensions.map((ext) => `.${ext}`));
|
|
|
5876
5971
|
const STYLE_EXTENSIONS = new Set(supportedCssLangs.map((ext) => `.${ext}`));
|
|
5877
5972
|
const CONFIG_SUFFIXES = configExtensions.map((ext) => `.${ext}`);
|
|
5878
5973
|
const SKIPPED_DIRECTORIES = new Set([
|
|
5879
|
-
"node_modules",
|
|
5880
|
-
"miniprogram_npm",
|
|
5881
5974
|
".git",
|
|
5882
|
-
".idea",
|
|
5883
5975
|
".husky",
|
|
5884
|
-
".
|
|
5885
|
-
".
|
|
5886
|
-
".weapp-vite",
|
|
5887
|
-
"dist"
|
|
5976
|
+
".idea",
|
|
5977
|
+
".turbo"
|
|
5888
5978
|
]);
|
|
5889
5979
|
const SCRIPT_SIDECAR_PATTERN = /\.(?:wxs|sjs)\.[jt]s$/i;
|
|
5890
5980
|
const TEMPLATE_SIDECAR_PATTERN = /\.wxml\.[jt]s$/i;
|
|
@@ -5897,7 +5987,7 @@ function hasNestedPagesRoot(root, discoveredPagesRoots) {
|
|
|
5897
5987
|
}
|
|
5898
5988
|
function classifyPagesRootEntry(current, entry) {
|
|
5899
5989
|
if (!entry.isDirectory()) return;
|
|
5900
|
-
if (SKIPPED_DIRECTORIES.has(entry.name)) return;
|
|
5990
|
+
if (SKIPPED_DIRECTORIES.has(entry.name) || isAutoRoutesGeneratedDirectoryName(entry.name)) return;
|
|
5901
5991
|
const nextPath = path.join(current, entry.name);
|
|
5902
5992
|
return entry.name === "pages" ? { pageRoot: nextPath } : { nextPath };
|
|
5903
5993
|
}
|
|
@@ -5995,6 +6085,7 @@ async function safeCrawlCandidateFiles(crawler, targetRoot) {
|
|
|
5995
6085
|
function resolveCandidateEntryPath(absoluteSrcRoot, entryPath) {
|
|
5996
6086
|
const normalizedRelative = toPosixPath(path.relative(absoluteSrcRoot, entryPath));
|
|
5997
6087
|
if (!normalizedRelative || normalizedRelative.startsWith("..")) return;
|
|
6088
|
+
if (isAutoRoutesGeneratedRelativePath(normalizedRelative)) return;
|
|
5998
6089
|
return {
|
|
5999
6090
|
normalizedRelative,
|
|
6000
6091
|
relativeBase: removeExtensionDeep(normalizedRelative),
|
|
@@ -6028,7 +6119,7 @@ async function collectCandidates(absoluteSrcRoot, include, subPackageRoots, sear
|
|
|
6028
6119
|
excludeSymlinks: true,
|
|
6029
6120
|
suppressErrors: true,
|
|
6030
6121
|
exclude(dirName) {
|
|
6031
|
-
return SKIPPED_DIRECTORIES.has(dirName);
|
|
6122
|
+
return SKIPPED_DIRECTORIES.has(dirName) || isAutoRoutesGeneratedDirectoryName(dirName);
|
|
6032
6123
|
}
|
|
6033
6124
|
}).withFullPaths();
|
|
6034
6125
|
for (const root of roots) {
|
|
@@ -6059,26 +6150,6 @@ function areSetsEqual(a, b) {
|
|
|
6059
6150
|
return true;
|
|
6060
6151
|
}
|
|
6061
6152
|
//#endregion
|
|
6062
|
-
//#region src/autoRoutesConfig.ts
|
|
6063
|
-
function resolveWeappAutoRoutesConfig(config) {
|
|
6064
|
-
if (config == null || config === false) return {
|
|
6065
|
-
enabled: false,
|
|
6066
|
-
typedRouter: false,
|
|
6067
|
-
include: [...DEFAULT_AUTO_ROUTE_INCLUDE],
|
|
6068
|
-
persistentCache: false,
|
|
6069
|
-
watch: false
|
|
6070
|
-
};
|
|
6071
|
-
const record = typeof config === "object" && config ? config : {};
|
|
6072
|
-
return {
|
|
6073
|
-
enabled: config === true || record.enabled !== false,
|
|
6074
|
-
typedRouter: record.typedRouter !== false,
|
|
6075
|
-
include: record.include == null ? [...DEFAULT_AUTO_ROUTE_INCLUDE] : Array.isArray(record.include) ? [...record.include] : [record.include],
|
|
6076
|
-
persistentCache: typeof record.persistentCache === "string" || record.persistentCache === true,
|
|
6077
|
-
persistentCachePath: typeof record.persistentCache === "string" ? record.persistentCache : void 0,
|
|
6078
|
-
watch: record.watch !== false
|
|
6079
|
-
};
|
|
6080
|
-
}
|
|
6081
|
-
//#endregion
|
|
6082
6153
|
//#region src/runtime/autoRoutesPlugin/routes/format.ts
|
|
6083
6154
|
const INDENT = " ";
|
|
6084
6155
|
const TS_STRING_PLACEHOLDER = "${string}";
|
|
@@ -6518,6 +6589,7 @@ function resolveAutoRoutesAliasTargets(packageRoot) {
|
|
|
6518
6589
|
* 判断文件是否属于 auto-routes 的 pages 关注范围,包括显式 include 和 watch root。
|
|
6519
6590
|
*/
|
|
6520
6591
|
function isAutoRoutesPagesRelatedPath(candidate, options) {
|
|
6592
|
+
if (isAutoRoutesGeneratedPath(candidate, options)) return false;
|
|
6521
6593
|
const resolvedPath = resolveAutoRoutesPath(candidate, options);
|
|
6522
6594
|
if (!resolvedPath) return false;
|
|
6523
6595
|
const matcher = createAutoRoutesMatcher(options.include, options.subPackageRoots);
|
|
@@ -6694,6 +6766,22 @@ function resolveDefaultPersistentCachePath(ctx) {
|
|
|
6694
6766
|
if (!baseDir) return;
|
|
6695
6767
|
return path.resolve(baseDir, AUTO_ROUTES_CACHE_FILE);
|
|
6696
6768
|
}
|
|
6769
|
+
async function hasSameTextContent(filePath, content) {
|
|
6770
|
+
try {
|
|
6771
|
+
return await fs.pathExists(filePath) && await fs.readFile(filePath, "utf8") === content;
|
|
6772
|
+
} catch {
|
|
6773
|
+
return false;
|
|
6774
|
+
}
|
|
6775
|
+
}
|
|
6776
|
+
async function hasSamePersistentCachePayload(filePath, payload) {
|
|
6777
|
+
try {
|
|
6778
|
+
if (!await fs.pathExists(filePath)) return false;
|
|
6779
|
+
const current = await fs.readJson(filePath);
|
|
6780
|
+
return JSON.stringify(current) === JSON.stringify(payload);
|
|
6781
|
+
} catch {
|
|
6782
|
+
return false;
|
|
6783
|
+
}
|
|
6784
|
+
}
|
|
6697
6785
|
async function restorePersistentCache(ctx, state) {
|
|
6698
6786
|
if (!getResolvedConfig(ctx).persistentCache) return false;
|
|
6699
6787
|
const cachePath = resolvePersistentCachePath(ctx);
|
|
@@ -6728,7 +6816,9 @@ async function writePersistentCache(ctx, state) {
|
|
|
6728
6816
|
return;
|
|
6729
6817
|
}
|
|
6730
6818
|
try {
|
|
6731
|
-
|
|
6819
|
+
const payload = createPersistentCachePayload(state, fileMtims);
|
|
6820
|
+
if (await hasSamePersistentCachePayload(cachePath, payload)) return;
|
|
6821
|
+
await fs.outputJson(cachePath, payload, { spaces: 2 });
|
|
6732
6822
|
} catch (error) {
|
|
6733
6823
|
const message = error instanceof Error ? error.message : String(error);
|
|
6734
6824
|
logger_default.warn(`写入 auto-routes 缓存失败: ${message}`);
|
|
@@ -6765,6 +6855,7 @@ async function writeTypedRouterDefinition(ctx, typedDefinition, lastWrittenTyped
|
|
|
6765
6855
|
const outputPath = resolveTypedRouterOutputPath(configService);
|
|
6766
6856
|
if (!typedDefinition || typedDefinition === lastWrittenTypedDefinition) return lastWrittenTypedDefinition;
|
|
6767
6857
|
try {
|
|
6858
|
+
if (await hasSameTextContent(outputPath, typedDefinition)) return typedDefinition;
|
|
6768
6859
|
await fs.outputFile(outputPath, typedDefinition, "utf8");
|
|
6769
6860
|
return typedDefinition;
|
|
6770
6861
|
} catch (error) {
|
|
@@ -6778,6 +6869,11 @@ async function writeTypedRouterDefinition(ctx, typedDefinition, lastWrittenTyped
|
|
|
6778
6869
|
function matchesRouteFile(ctx, candidate) {
|
|
6779
6870
|
const configService = ctx.configService;
|
|
6780
6871
|
if (!configService) return false;
|
|
6872
|
+
if (isAutoRoutesGeneratedPath(candidate, {
|
|
6873
|
+
cwd: configService.cwd,
|
|
6874
|
+
absoluteSrcRoot: configService.absoluteSrcRoot,
|
|
6875
|
+
managedOutputPaths: resolveAutoRoutesManagedOutputPaths(ctx)
|
|
6876
|
+
})) return false;
|
|
6781
6877
|
const [pathWithoutQuery] = candidate.split("?");
|
|
6782
6878
|
if (!pathWithoutQuery) return false;
|
|
6783
6879
|
const resolvedPath = resolveAutoRoutesPath(candidate, {
|
|
@@ -6829,6 +6925,11 @@ async function rebuildCandidateForBase(base) {
|
|
|
6829
6925
|
}
|
|
6830
6926
|
async function updateCandidateFromFile(ctx, stateCandidates, filePath, event, markNeedsFullRescan) {
|
|
6831
6927
|
if (!ctx.configService) return false;
|
|
6928
|
+
if (isAutoRoutesGeneratedPath(filePath, {
|
|
6929
|
+
cwd: ctx.configService.cwd,
|
|
6930
|
+
absoluteSrcRoot: ctx.configService.absoluteSrcRoot,
|
|
6931
|
+
managedOutputPaths: resolveAutoRoutesManagedOutputPaths(ctx)
|
|
6932
|
+
})) return false;
|
|
6832
6933
|
if (shouldAutoRoutesFullRescan(event)) {
|
|
6833
6934
|
markNeedsFullRescan?.();
|
|
6834
6935
|
return true;
|
|
@@ -8858,135 +8959,561 @@ function createNpmService(ctx) {
|
|
|
8858
8959
|
};
|
|
8859
8960
|
}
|
|
8860
8961
|
//#endregion
|
|
8861
|
-
//#region src/
|
|
8862
|
-
const
|
|
8863
|
-
const
|
|
8864
|
-
const
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
const DYNAMIC_GLOBAL_RESOLUTION_RE = /Function\(\s*(?:`return this`|'return this'|"return this")\s*\)\(\)/g;
|
|
8869
|
-
const BROWSER_GLOBAL_HOST_TERNARY_RE = /typeof self<[`'"]u[`'"]\?self:typeof window<[`'"]u[`'"]\?window:globalThis/g;
|
|
8870
|
-
const AXIOS_MODULE_ID_RE = /[/\\](?:\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?axios[/\\]/u;
|
|
8871
|
-
const APP_PRELUDE_REQUIRE_FILE_BASENAME = "app.prelude.js";
|
|
8872
|
-
const DIRECTIVE_PROLOGUE_RE = /^(?:(['"])(?:\\.|(?!\1)[^\\])*\1;?\s*)+/u;
|
|
8873
|
-
const USE_STRICT_PREFIX_RE = /^(?:['"]use strict['"];\s*)+/u;
|
|
8874
|
-
//#endregion
|
|
8875
|
-
//#region src/runtime/chunkStrategy/state.ts
|
|
8876
|
-
const sharedChunkDiagnostics = /* @__PURE__ */ new Map();
|
|
8877
|
-
const takeImportersMap = /* @__PURE__ */ new Map();
|
|
8878
|
-
const forceDuplicateSharedChunks = /* @__PURE__ */ new Set();
|
|
8879
|
-
const sharedChunkNameCache = /* @__PURE__ */ new Map();
|
|
8880
|
-
function resetTakeImportRegistry(options = {}) {
|
|
8881
|
-
takeImportersMap.clear();
|
|
8882
|
-
forceDuplicateSharedChunks.clear();
|
|
8883
|
-
sharedChunkDiagnostics.clear();
|
|
8884
|
-
if (!options.preserveSharedChunkNameCache) sharedChunkNameCache.clear();
|
|
8885
|
-
}
|
|
8886
|
-
function getTakeImporters(moduleId) {
|
|
8887
|
-
return takeImportersMap.get(moduleId);
|
|
8888
|
-
}
|
|
8889
|
-
function markForceDuplicateSharedChunk(sharedName) {
|
|
8890
|
-
if (!sharedName) return;
|
|
8891
|
-
forceDuplicateSharedChunks.add(sharedName);
|
|
8892
|
-
forceDuplicateSharedChunks.add(`${sharedName}.js`);
|
|
8893
|
-
}
|
|
8894
|
-
function isForceDuplicateSharedChunk(fileName) {
|
|
8895
|
-
return forceDuplicateSharedChunks.has(fileName);
|
|
8896
|
-
}
|
|
8897
|
-
function hasForceDuplicateSharedChunks() {
|
|
8898
|
-
return forceDuplicateSharedChunks.size > 0;
|
|
8962
|
+
//#region src/cache/file.ts
|
|
8963
|
+
const FNV_OFFSET_BASIS = 14695981039346656037n;
|
|
8964
|
+
const FNV_PRIME = 1099511628211n;
|
|
8965
|
+
const FNV_MASK = 18446744073709551615n;
|
|
8966
|
+
function fnv1aStep(hash, byte) {
|
|
8967
|
+
hash ^= BigInt(byte & 255);
|
|
8968
|
+
return hash * FNV_PRIME & FNV_MASK;
|
|
8899
8969
|
}
|
|
8900
|
-
function
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8970
|
+
function createSignature(content) {
|
|
8971
|
+
let hash = FNV_OFFSET_BASIS;
|
|
8972
|
+
if (typeof content === "string") for (let i = 0; i < content.length; i++) {
|
|
8973
|
+
const code = content.charCodeAt(i);
|
|
8974
|
+
hash = fnv1aStep(hash, code & 255);
|
|
8975
|
+
const high = code >>> 8;
|
|
8976
|
+
if (high > 0) hash = fnv1aStep(hash, high);
|
|
8977
|
+
}
|
|
8978
|
+
else for (const byte of content) hash = fnv1aStep(hash, byte);
|
|
8979
|
+
return hash.toString(36);
|
|
8905
8980
|
}
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8981
|
+
var FileCache = class {
|
|
8982
|
+
cache;
|
|
8983
|
+
mtimeMap;
|
|
8984
|
+
signatureMap;
|
|
8985
|
+
constructor(max = 1024) {
|
|
8986
|
+
this.mtimeMap = /* @__PURE__ */ new Map();
|
|
8987
|
+
this.signatureMap = /* @__PURE__ */ new Map();
|
|
8988
|
+
this.cache = new LRUCache({
|
|
8989
|
+
max,
|
|
8990
|
+
dispose: (_value, key) => {
|
|
8991
|
+
this.mtimeMap.delete(key);
|
|
8992
|
+
this.signatureMap.delete(key);
|
|
8993
|
+
}
|
|
8994
|
+
});
|
|
8911
8995
|
}
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
if (fallback) {
|
|
8915
|
-
sharedChunkDiagnostics.delete(withoutExt);
|
|
8916
|
-
return fallback;
|
|
8996
|
+
get(id) {
|
|
8997
|
+
return this.cache.get(id);
|
|
8917
8998
|
}
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
if (!sharedChunkNameCache.has(moduleId)) return;
|
|
8921
|
-
return sharedChunkNameCache.get(moduleId) ?? null;
|
|
8922
|
-
}
|
|
8923
|
-
function setCachedSharedChunkName(moduleId, value) {
|
|
8924
|
-
if (!moduleId) return;
|
|
8925
|
-
sharedChunkNameCache.set(moduleId, value ?? null);
|
|
8926
|
-
}
|
|
8927
|
-
//#endregion
|
|
8928
|
-
//#region src/runtime/chunkStrategy/utils.ts
|
|
8929
|
-
function replaceAll(source, searchValue, replaceValue) {
|
|
8930
|
-
if (!searchValue) return source;
|
|
8931
|
-
if (source.includes(searchValue)) return source.split(searchValue).join(replaceValue);
|
|
8932
|
-
if (searchValue.startsWith("./") && replaceValue.startsWith("./")) {
|
|
8933
|
-
const trimmedSearch = searchValue.slice(2);
|
|
8934
|
-
const trimmedReplace = replaceValue.slice(2);
|
|
8935
|
-
if (trimmedSearch && source.includes(trimmedSearch)) return source.split(trimmedSearch).join(trimmedReplace);
|
|
8999
|
+
set(id, content) {
|
|
9000
|
+
return this.cache.set(id, content);
|
|
8936
9001
|
}
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
if (source.includes(specifier)) return true;
|
|
8942
|
-
if (specifier.startsWith("./")) {
|
|
8943
|
-
const trimmed = specifier.slice(2);
|
|
8944
|
-
if (trimmed && source.includes(trimmed)) return true;
|
|
9002
|
+
delete(id) {
|
|
9003
|
+
this.mtimeMap.delete(id);
|
|
9004
|
+
this.signatureMap.delete(id);
|
|
9005
|
+
return this.cache.delete(id);
|
|
8945
9006
|
}
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
}
|
|
8955
|
-
function createRelativeImport(fromFile, toFile) {
|
|
8956
|
-
const relative = posix.relative(posix.dirname(fromFile), toFile);
|
|
8957
|
-
if (!relative || relative.startsWith(".")) return relative || "./";
|
|
8958
|
-
return `./${relative}`;
|
|
8959
|
-
}
|
|
8960
|
-
//#endregion
|
|
8961
|
-
//#region src/runtime/chunkStrategy/bundle.ts
|
|
8962
|
-
function findChunkImporters(bundle, target) {
|
|
8963
|
-
const importers = /* @__PURE__ */ new Set();
|
|
8964
|
-
for (const [fileName, output] of Object.entries(bundle)) {
|
|
8965
|
-
if (fileName === target) continue;
|
|
8966
|
-
if (output?.type !== "chunk") continue;
|
|
8967
|
-
const chunk = output;
|
|
8968
|
-
if (chunk.imports.includes(target) || chunk.dynamicImports.includes(target)) {
|
|
8969
|
-
importers.add(fileName);
|
|
8970
|
-
continue;
|
|
8971
|
-
}
|
|
8972
|
-
const metadata = chunk.viteMetadata;
|
|
8973
|
-
if (metadata) {
|
|
8974
|
-
const importedChunks = metadata.importedChunks;
|
|
8975
|
-
if (hasInCollection$1(importedChunks, target)) {
|
|
8976
|
-
importers.add(fileName);
|
|
8977
|
-
continue;
|
|
8978
|
-
}
|
|
8979
|
-
if (hasInCollection$1(metadata.importedScripts ?? metadata.importedScriptsByUrl, target)) {
|
|
8980
|
-
importers.add(fileName);
|
|
8981
|
-
continue;
|
|
9007
|
+
async isInvalidate(id, options) {
|
|
9008
|
+
const checkMtime = options?.checkMtime ?? true;
|
|
9009
|
+
const nextSignature = options?.signature ?? (options?.content !== void 0 ? createSignature(options.content) : void 0);
|
|
9010
|
+
if (!checkMtime) {
|
|
9011
|
+
if (nextSignature === void 0) return true;
|
|
9012
|
+
if (this.signatureMap.get(id) !== nextSignature) {
|
|
9013
|
+
this.signatureMap.set(id, nextSignature);
|
|
9014
|
+
return true;
|
|
8982
9015
|
}
|
|
9016
|
+
return false;
|
|
8983
9017
|
}
|
|
8984
|
-
|
|
8985
|
-
if (
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
}
|
|
8989
|
-
|
|
9018
|
+
let mtimeMs;
|
|
9019
|
+
if (typeof options?.mtimeMs === "number" && Number.isFinite(options.mtimeMs)) mtimeMs = options.mtimeMs;
|
|
9020
|
+
else try {
|
|
9021
|
+
mtimeMs = (await fs.stat(id)).mtimeMs;
|
|
9022
|
+
} catch (error) {
|
|
9023
|
+
if (error && error.code === "ENOENT") {
|
|
9024
|
+
this.cache.delete(id);
|
|
9025
|
+
this.mtimeMap.delete(id);
|
|
9026
|
+
this.signatureMap.delete(id);
|
|
9027
|
+
return true;
|
|
9028
|
+
}
|
|
9029
|
+
throw error;
|
|
9030
|
+
}
|
|
9031
|
+
if (mtimeMs === void 0) return true;
|
|
9032
|
+
const cachedMtime = this.mtimeMap.get(id);
|
|
9033
|
+
const updateSignature = () => {
|
|
9034
|
+
if (nextSignature !== void 0) this.signatureMap.set(id, nextSignature);
|
|
9035
|
+
};
|
|
9036
|
+
if (cachedMtime === void 0) {
|
|
9037
|
+
this.mtimeMap.set(id, mtimeMs);
|
|
9038
|
+
updateSignature();
|
|
9039
|
+
return true;
|
|
9040
|
+
} else if (cachedMtime > mtimeMs) {
|
|
9041
|
+
this.mtimeMap.set(id, mtimeMs);
|
|
9042
|
+
updateSignature();
|
|
9043
|
+
return true;
|
|
9044
|
+
} else if (cachedMtime === mtimeMs) {
|
|
9045
|
+
if (nextSignature !== void 0) {
|
|
9046
|
+
if (this.signatureMap.get(id) !== nextSignature) {
|
|
9047
|
+
updateSignature();
|
|
9048
|
+
return true;
|
|
9049
|
+
}
|
|
9050
|
+
}
|
|
9051
|
+
return false;
|
|
9052
|
+
} else {
|
|
9053
|
+
this.mtimeMap.set(id, mtimeMs);
|
|
9054
|
+
updateSignature();
|
|
9055
|
+
return true;
|
|
9056
|
+
}
|
|
9057
|
+
}
|
|
9058
|
+
};
|
|
9059
|
+
//#endregion
|
|
9060
|
+
//#region src/defaults.ts
|
|
9061
|
+
const defaultExcluded = [
|
|
9062
|
+
"**/node_modules/**",
|
|
9063
|
+
"**/miniprogram_npm/**",
|
|
9064
|
+
"**/.weapp-vite",
|
|
9065
|
+
"**/.weapp-vite/**"
|
|
9066
|
+
];
|
|
9067
|
+
/**
|
|
9068
|
+
* 样式扩展名说明:
|
|
9069
|
+
* - wxss:微信小程序
|
|
9070
|
+
* - acss:支付宝小程序
|
|
9071
|
+
* - jxss:京东小程序
|
|
9072
|
+
* - ttss:头条小程序
|
|
9073
|
+
* - qss:QQ 小程序
|
|
9074
|
+
* - css:通用样式文件
|
|
9075
|
+
* - tyss:涂鸦小程序
|
|
9076
|
+
*/
|
|
9077
|
+
/**
|
|
9078
|
+
* 模板扩展名说明:
|
|
9079
|
+
* - wxml:微信小程序
|
|
9080
|
+
* - axml:支付宝小程序
|
|
9081
|
+
* - jxml:京东小程序
|
|
9082
|
+
* - ksml:快手小程序
|
|
9083
|
+
* - ttml:头条小程序
|
|
9084
|
+
* - qml:QQ 小程序
|
|
9085
|
+
* - tyml:涂鸦小程序
|
|
9086
|
+
* - xhsml:小红书小程序
|
|
9087
|
+
* - swan:百度小程序
|
|
9088
|
+
*/
|
|
9089
|
+
function getOutputExtensions(platform) {
|
|
9090
|
+
return getPlatformOutputExtensions(platform ?? DEFAULT_MP_PLATFORM);
|
|
9091
|
+
}
|
|
9092
|
+
function getWeappViteConfig() {
|
|
9093
|
+
return {
|
|
9094
|
+
autoRoutes: false,
|
|
9095
|
+
wxml: true,
|
|
9096
|
+
wxs: true,
|
|
9097
|
+
enhance: {
|
|
9098
|
+
wxml: true,
|
|
9099
|
+
wxs: true
|
|
9100
|
+
},
|
|
9101
|
+
platform: DEFAULT_MP_PLATFORM,
|
|
9102
|
+
multiPlatform: false,
|
|
9103
|
+
es5: false,
|
|
9104
|
+
packageSizeWarningBytes: 2 * 1024 * 1024,
|
|
9105
|
+
analyze: {
|
|
9106
|
+
budgets: {
|
|
9107
|
+
totalBytes: 20 * 1024 * 1024,
|
|
9108
|
+
mainBytes: 2 * 1024 * 1024,
|
|
9109
|
+
subPackageBytes: 2 * 1024 * 1024,
|
|
9110
|
+
independentBytes: 2 * 1024 * 1024,
|
|
9111
|
+
warningRatio: .85
|
|
9112
|
+
},
|
|
9113
|
+
history: {
|
|
9114
|
+
enabled: true,
|
|
9115
|
+
dir: ".weapp-vite/analyze-history",
|
|
9116
|
+
limit: 20
|
|
9117
|
+
}
|
|
9118
|
+
},
|
|
9119
|
+
jsFormat: "cjs",
|
|
9120
|
+
isAdditionalWxml: () => {
|
|
9121
|
+
return false;
|
|
9122
|
+
},
|
|
9123
|
+
npm: {
|
|
9124
|
+
enable: true,
|
|
9125
|
+
cache: true,
|
|
9126
|
+
alipayNpmMode: "node_modules"
|
|
9127
|
+
},
|
|
9128
|
+
hmr: {
|
|
9129
|
+
sharedChunks: "auto",
|
|
9130
|
+
touchAppWxss: "auto",
|
|
9131
|
+
logLevel: "default",
|
|
9132
|
+
profileJson: false
|
|
9133
|
+
},
|
|
9134
|
+
mcp: {
|
|
9135
|
+
enabled: true,
|
|
9136
|
+
autoStart: false,
|
|
9137
|
+
host: "127.0.0.1",
|
|
9138
|
+
port: 3088,
|
|
9139
|
+
endpoint: "/mcp",
|
|
9140
|
+
restEndpoint: "/api/weapp/devtools"
|
|
9141
|
+
},
|
|
9142
|
+
forwardConsole: {
|
|
9143
|
+
enabled: "auto",
|
|
9144
|
+
logLevels: [
|
|
9145
|
+
"log",
|
|
9146
|
+
"info",
|
|
9147
|
+
"warn",
|
|
9148
|
+
"error"
|
|
9149
|
+
],
|
|
9150
|
+
unhandledErrors: true
|
|
9151
|
+
},
|
|
9152
|
+
appPrelude: { mode: "require" },
|
|
9153
|
+
wevu: { defaults: { component: { allowNullPropInput: true } } },
|
|
9154
|
+
chunks: {
|
|
9155
|
+
sharedStrategy: "duplicate",
|
|
9156
|
+
sharedMode: "common",
|
|
9157
|
+
sharedOverrides: [],
|
|
9158
|
+
sharedPathRoot: void 0,
|
|
9159
|
+
dynamicImports: "preserve",
|
|
9160
|
+
logOptimization: true,
|
|
9161
|
+
forceDuplicatePatterns: [],
|
|
9162
|
+
duplicateWarningBytes: 512 * 1024
|
|
9163
|
+
}
|
|
9164
|
+
};
|
|
9165
|
+
}
|
|
9166
|
+
const defaultAssetExtensions = [
|
|
9167
|
+
"png",
|
|
9168
|
+
"jpg",
|
|
9169
|
+
"jpeg",
|
|
9170
|
+
"gif",
|
|
9171
|
+
"svg",
|
|
9172
|
+
"cer",
|
|
9173
|
+
"mp3",
|
|
9174
|
+
"aac",
|
|
9175
|
+
"m4a",
|
|
9176
|
+
"mp4",
|
|
9177
|
+
"wav",
|
|
9178
|
+
"ogg",
|
|
9179
|
+
"silk",
|
|
9180
|
+
"wasm",
|
|
9181
|
+
"br",
|
|
9182
|
+
"cert"
|
|
9183
|
+
];
|
|
9184
|
+
//#endregion
|
|
9185
|
+
//#region src/multiPlatform.ts
|
|
9186
|
+
const DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT = "config";
|
|
9187
|
+
function normalizeMultiPlatformProjectConfigRoot(input) {
|
|
9188
|
+
if (typeof input !== "string") return DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT;
|
|
9189
|
+
return input.trim() || "config";
|
|
9190
|
+
}
|
|
9191
|
+
function resolveMultiPlatformTargets(value) {
|
|
9192
|
+
const supportedPlatforms = getSupportedMiniProgramPlatforms$1();
|
|
9193
|
+
if (value == null || value === "all") return supportedPlatforms;
|
|
9194
|
+
if (!Array.isArray(value)) throw new TypeError("`weapp.multiPlatform.targets` 必须是平台数组或 \"all\"。");
|
|
9195
|
+
const resolvedTargets = [];
|
|
9196
|
+
const invalidTargets = [];
|
|
9197
|
+
for (const rawTarget of value) {
|
|
9198
|
+
const resolvedTarget = typeof rawTarget === "string" ? resolveMiniPlatform(rawTarget) : void 0;
|
|
9199
|
+
if (!resolvedTarget) {
|
|
9200
|
+
invalidTargets.push(String(rawTarget));
|
|
9201
|
+
continue;
|
|
9202
|
+
}
|
|
9203
|
+
if (!resolvedTargets.includes(resolvedTarget)) resolvedTargets.push(resolvedTarget);
|
|
9204
|
+
}
|
|
9205
|
+
if (invalidTargets.length > 0) throw new Error(`\`weapp.multiPlatform.targets\` 包含不支持的平台:${invalidTargets.join(", ")}`);
|
|
9206
|
+
if (resolvedTargets.length === 0) throw new Error("`weapp.multiPlatform.targets` 至少需要包含一个目标平台。");
|
|
9207
|
+
return resolvedTargets;
|
|
9208
|
+
}
|
|
9209
|
+
function resolveMultiPlatformConfig(value) {
|
|
9210
|
+
if (!value) return {
|
|
9211
|
+
enabled: false,
|
|
9212
|
+
projectConfigRoot: DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT,
|
|
9213
|
+
targets: getSupportedMiniProgramPlatforms$1()
|
|
9214
|
+
};
|
|
9215
|
+
if (value === true) return {
|
|
9216
|
+
enabled: true,
|
|
9217
|
+
projectConfigRoot: DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT,
|
|
9218
|
+
targets: getSupportedMiniProgramPlatforms$1()
|
|
9219
|
+
};
|
|
9220
|
+
if (typeof value === "object" && value !== null) {
|
|
9221
|
+
const record = value;
|
|
9222
|
+
const targets = resolveMultiPlatformTargets(record.targets);
|
|
9223
|
+
return {
|
|
9224
|
+
enabled: record.enabled !== false,
|
|
9225
|
+
projectConfigRoot: normalizeMultiPlatformProjectConfigRoot(record.projectConfigRoot),
|
|
9226
|
+
targets
|
|
9227
|
+
};
|
|
9228
|
+
}
|
|
9229
|
+
return {
|
|
9230
|
+
enabled: false,
|
|
9231
|
+
projectConfigRoot: DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT,
|
|
9232
|
+
targets: getSupportedMiniProgramPlatforms$1()
|
|
9233
|
+
};
|
|
9234
|
+
}
|
|
9235
|
+
function supportsMultiPlatformTarget(multiPlatform, platform) {
|
|
9236
|
+
return multiPlatform.targets.includes(platform);
|
|
9237
|
+
}
|
|
9238
|
+
function resolveMultiPlatformProjectConfigDir(multiPlatform, platform) {
|
|
9239
|
+
return path.join(multiPlatform.projectConfigRoot || "config", platform);
|
|
9240
|
+
}
|
|
9241
|
+
//#endregion
|
|
9242
|
+
//#region src/runtime/runtimeState.ts
|
|
9243
|
+
function createDefaultLoadConfigResult() {
|
|
9244
|
+
return {
|
|
9245
|
+
config: {},
|
|
9246
|
+
loadOptions: {
|
|
9247
|
+
cwd: process.cwd(),
|
|
9248
|
+
isDev: false,
|
|
9249
|
+
mode: "development",
|
|
9250
|
+
emitDefaultAutoImportOutputs: true
|
|
9251
|
+
},
|
|
9252
|
+
aliasEntries: [],
|
|
9253
|
+
outputExtensions: getOutputExtensions(DEFAULT_MP_PLATFORM),
|
|
9254
|
+
packageJson: {},
|
|
9255
|
+
relativeSrcRoot: (p) => p,
|
|
9256
|
+
cwd: process.cwd(),
|
|
9257
|
+
isDev: false,
|
|
9258
|
+
mode: "development",
|
|
9259
|
+
emitDefaultAutoImportOutputs: true,
|
|
9260
|
+
projectConfig: {},
|
|
9261
|
+
projectConfigPath: void 0,
|
|
9262
|
+
projectPrivateConfigPath: void 0,
|
|
9263
|
+
mpDistRoot: "",
|
|
9264
|
+
multiPlatform: resolveMultiPlatformConfig(false),
|
|
9265
|
+
weappLib: void 0,
|
|
9266
|
+
weappLibOutputMap: void 0,
|
|
9267
|
+
packageJsonPath: "",
|
|
9268
|
+
platform: DEFAULT_MP_PLATFORM,
|
|
9269
|
+
srcRoot: "",
|
|
9270
|
+
configFilePath: void 0,
|
|
9271
|
+
configFileDependencies: [],
|
|
9272
|
+
weappWeb: void 0,
|
|
9273
|
+
configMergeInfo: void 0
|
|
9274
|
+
};
|
|
9275
|
+
}
|
|
9276
|
+
function createDefaultPackageInfo() {
|
|
9277
|
+
return {
|
|
9278
|
+
name: "",
|
|
9279
|
+
version: void 0,
|
|
9280
|
+
rootPath: "",
|
|
9281
|
+
packageJsonPath: "",
|
|
9282
|
+
packageJson: {}
|
|
9283
|
+
};
|
|
9284
|
+
}
|
|
9285
|
+
function createDefaultPackageManager() {
|
|
9286
|
+
return {
|
|
9287
|
+
agent: "npm",
|
|
9288
|
+
name: "npm"
|
|
9289
|
+
};
|
|
9290
|
+
}
|
|
9291
|
+
function createRuntimeState() {
|
|
9292
|
+
const emptyAutoRoutesSnapshot = createEmptyAutoRoutesSnapshot();
|
|
9293
|
+
const emptyAutoRoutesArtifacts = createAutoRoutesArtifacts(emptyAutoRoutesSnapshot);
|
|
9294
|
+
return {
|
|
9295
|
+
autoRoutes: {
|
|
9296
|
+
routes: emptyAutoRoutesSnapshot,
|
|
9297
|
+
serialized: emptyAutoRoutesArtifacts.serialized,
|
|
9298
|
+
moduleCode: emptyAutoRoutesArtifacts.moduleCode,
|
|
9299
|
+
typedDefinition: "",
|
|
9300
|
+
watchFiles: /* @__PURE__ */ new Set(),
|
|
9301
|
+
watchDirs: /* @__PURE__ */ new Set(),
|
|
9302
|
+
dirty: true,
|
|
9303
|
+
initialized: false,
|
|
9304
|
+
candidates: /* @__PURE__ */ new Map(),
|
|
9305
|
+
needsFullRescan: true,
|
|
9306
|
+
loadingAppConfig: false
|
|
9307
|
+
},
|
|
9308
|
+
autoImport: {
|
|
9309
|
+
registry: /* @__PURE__ */ new Map(),
|
|
9310
|
+
resolvedResolverComponents: /* @__PURE__ */ new Map(),
|
|
9311
|
+
matcherKey: "",
|
|
9312
|
+
version: 0,
|
|
9313
|
+
pendingEntriesByImporter: /* @__PURE__ */ new Map()
|
|
9314
|
+
},
|
|
9315
|
+
build: {
|
|
9316
|
+
queue: new PQueue({ autoStart: false }),
|
|
9317
|
+
npmBuilt: false,
|
|
9318
|
+
independent: { outputs: /* @__PURE__ */ new Map() },
|
|
9319
|
+
hmr: {
|
|
9320
|
+
loadedEntrySet: /* @__PURE__ */ new Set(),
|
|
9321
|
+
dirtyEntrySet: /* @__PURE__ */ new Set(),
|
|
9322
|
+
dirtyEntryReasons: /* @__PURE__ */ new Map(),
|
|
9323
|
+
resolvedEntryMap: /* @__PURE__ */ new Map(),
|
|
9324
|
+
externalComponentEntryMap: /* @__PURE__ */ new Map(),
|
|
9325
|
+
entriesMap: /* @__PURE__ */ new Map(),
|
|
9326
|
+
layoutEntryDependents: /* @__PURE__ */ new Map(),
|
|
9327
|
+
entryLayoutDependencies: /* @__PURE__ */ new Map(),
|
|
9328
|
+
vueEntryHasTemplate: /* @__PURE__ */ new Map(),
|
|
9329
|
+
vueEntryNonJsonSignatures: /* @__PURE__ */ new Map(),
|
|
9330
|
+
vueEntryScriptSignatures: /* @__PURE__ */ new Map(),
|
|
9331
|
+
dirtyVueEntryIds: /* @__PURE__ */ new Set(),
|
|
9332
|
+
didEmitAllEntries: false,
|
|
9333
|
+
lastHmrEntryIds: /* @__PURE__ */ new Set(),
|
|
9334
|
+
lastEmittedEntryIds: /* @__PURE__ */ new Set(),
|
|
9335
|
+
recentProfiles: [],
|
|
9336
|
+
profile: {}
|
|
9337
|
+
}
|
|
9338
|
+
},
|
|
9339
|
+
json: {
|
|
9340
|
+
cache: new FileCache(),
|
|
9341
|
+
emittedSource: /* @__PURE__ */ new Map()
|
|
9342
|
+
},
|
|
9343
|
+
asset: {
|
|
9344
|
+
emittedBuffer: /* @__PURE__ */ new Map(),
|
|
9345
|
+
scopedSlotGenerics: /* @__PURE__ */ new Map()
|
|
9346
|
+
},
|
|
9347
|
+
css: {
|
|
9348
|
+
importerToDependencies: /* @__PURE__ */ new Map(),
|
|
9349
|
+
dependencyToImporters: /* @__PURE__ */ new Map(),
|
|
9350
|
+
emittedSource: /* @__PURE__ */ new Map()
|
|
9351
|
+
},
|
|
9352
|
+
watcher: {
|
|
9353
|
+
rollupWatcherMap: /* @__PURE__ */ new Map(),
|
|
9354
|
+
sidecarWatcherMap: /* @__PURE__ */ new Map()
|
|
9355
|
+
},
|
|
9356
|
+
wxml: {
|
|
9357
|
+
depsMap: /* @__PURE__ */ new Map(),
|
|
9358
|
+
importerMap: /* @__PURE__ */ new Map(),
|
|
9359
|
+
tokenMap: /* @__PURE__ */ new Map(),
|
|
9360
|
+
componentsMap: /* @__PURE__ */ new Map(),
|
|
9361
|
+
aggregatedComponentsMap: /* @__PURE__ */ new Map(),
|
|
9362
|
+
templatePathMap: /* @__PURE__ */ new Map(),
|
|
9363
|
+
cache: new FileCache(),
|
|
9364
|
+
emittedCode: /* @__PURE__ */ new Map()
|
|
9365
|
+
},
|
|
9366
|
+
scan: {
|
|
9367
|
+
subPackageMap: /* @__PURE__ */ new Map(),
|
|
9368
|
+
independentSubPackageMap: /* @__PURE__ */ new Map(),
|
|
9369
|
+
warnedMessages: /* @__PURE__ */ new Set(),
|
|
9370
|
+
isDirty: true,
|
|
9371
|
+
independentDirtyRoots: /* @__PURE__ */ new Set(),
|
|
9372
|
+
pluginJsonPath: void 0
|
|
9373
|
+
},
|
|
9374
|
+
lib: {
|
|
9375
|
+
enabled: false,
|
|
9376
|
+
entries: /* @__PURE__ */ new Map()
|
|
9377
|
+
},
|
|
9378
|
+
config: {
|
|
9379
|
+
packageInfo: createDefaultPackageInfo(),
|
|
9380
|
+
defineEnv: {},
|
|
9381
|
+
importMetaEnvDefineOverride: void 0,
|
|
9382
|
+
packageManager: createDefaultPackageManager(),
|
|
9383
|
+
options: createDefaultLoadConfigResult()
|
|
9384
|
+
}
|
|
9385
|
+
};
|
|
9386
|
+
}
|
|
9387
|
+
//#endregion
|
|
9388
|
+
//#region src/plugins/core/lifecycle/emit/constants.ts
|
|
9389
|
+
const PRETTY_NODE_MODULES_RE = /node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(.+)/;
|
|
9390
|
+
const REQUEST_GLOBAL_EXPORT_RE = /Object\.defineProperty\(exports,\s*(?:`([^`]+)`|'([^']+)'|"([^"]+)"),\s*\{[\s\S]*?get:function\(\)\{return ([A-Za-z_$][\w$]*)\}\}\)/g;
|
|
9391
|
+
const REQUEST_GLOBAL_INSTALLER_RE = /function\s+([A-Za-z_$][\w$]*)\([^)]*=\{\}\)\{[\s\S]{0,220}?targets\?\?\[[\s\S]{0,80}?fetch[\s\S]{0,80}?Headers[\s\S]{0,80}?Request[\s\S]{0,80}?Response[\s\S]{0,80}?AbortController[\s\S]{0,80}?AbortSignal[\s\S]{0,80}?XMLHttpRequest[\s\S]{0,80}?WebSocket[\s\S]{0,260}?return [^}]+\}/;
|
|
9392
|
+
const REQUEST_GLOBAL_ENTRY_NAME_RE = /\.[^/.]+$/;
|
|
9393
|
+
const REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE = /([A-Za-z_$][\w$]*)\s*=\s*require\((`([^`]+)`|'([^']+)'|"([^"]+)")\)/g;
|
|
9394
|
+
const REQUEST_GLOBAL_RUNTIME_CHUNK_FILE_BASENAME = "weapp-vendors/request-globals-runtime.js";
|
|
9395
|
+
const DYNAMIC_GLOBAL_RESOLUTION_RE = /Function\(\s*(?:`return this`|'return this'|"return this")\s*\)\(\)/g;
|
|
9396
|
+
const BROWSER_GLOBAL_HOST_TERNARY_RE = /typeof self<[`'"]u[`'"]\?self:typeof window<[`'"]u[`'"]\?window:globalThis/g;
|
|
9397
|
+
const AXIOS_MODULE_ID_RE = /[/\\](?:\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?axios[/\\]/u;
|
|
9398
|
+
const APP_PRELUDE_REQUIRE_FILE_BASENAME = "app.prelude.js";
|
|
9399
|
+
const DIRECTIVE_PROLOGUE_RE = /^(?:(['"])(?:\\.|(?!\1)[^\\])*\1;?\s*)+/u;
|
|
9400
|
+
const USE_STRICT_PREFIX_RE = /^(?:['"]use strict['"];\s*)+/u;
|
|
9401
|
+
//#endregion
|
|
9402
|
+
//#region src/runtime/chunkStrategy/state.ts
|
|
9403
|
+
const sharedChunkDiagnostics = /* @__PURE__ */ new Map();
|
|
9404
|
+
const takeImportersMap = /* @__PURE__ */ new Map();
|
|
9405
|
+
const forceDuplicateSharedChunks = /* @__PURE__ */ new Set();
|
|
9406
|
+
const sharedChunkNameCache = /* @__PURE__ */ new Map();
|
|
9407
|
+
function resetTakeImportRegistry(options = {}) {
|
|
9408
|
+
takeImportersMap.clear();
|
|
9409
|
+
forceDuplicateSharedChunks.clear();
|
|
9410
|
+
sharedChunkDiagnostics.clear();
|
|
9411
|
+
if (!options.preserveSharedChunkNameCache) sharedChunkNameCache.clear();
|
|
9412
|
+
}
|
|
9413
|
+
function getTakeImporters(moduleId) {
|
|
9414
|
+
return takeImportersMap.get(moduleId);
|
|
9415
|
+
}
|
|
9416
|
+
function markForceDuplicateSharedChunk(sharedName) {
|
|
9417
|
+
if (!sharedName) return;
|
|
9418
|
+
forceDuplicateSharedChunks.add(sharedName);
|
|
9419
|
+
forceDuplicateSharedChunks.add(`${sharedName}.js`);
|
|
9420
|
+
}
|
|
9421
|
+
function isForceDuplicateSharedChunk(fileName) {
|
|
9422
|
+
return forceDuplicateSharedChunks.has(fileName);
|
|
9423
|
+
}
|
|
9424
|
+
function hasForceDuplicateSharedChunks() {
|
|
9425
|
+
return forceDuplicateSharedChunks.size > 0;
|
|
9426
|
+
}
|
|
9427
|
+
function recordSharedChunkDiagnostics(sharedName, ignoredMainImporters) {
|
|
9428
|
+
if (!sharedName || ignoredMainImporters.length === 0) return;
|
|
9429
|
+
const uniqueImporters = Array.from(new Set(ignoredMainImporters));
|
|
9430
|
+
sharedChunkDiagnostics.set(sharedName, { ignoredMainImporters: uniqueImporters });
|
|
9431
|
+
sharedChunkDiagnostics.set(`${sharedName}.js`, { ignoredMainImporters: uniqueImporters });
|
|
9432
|
+
}
|
|
9433
|
+
function consumeSharedChunkDiagnostics(fileName) {
|
|
9434
|
+
const direct = sharedChunkDiagnostics.get(fileName);
|
|
9435
|
+
if (direct) {
|
|
9436
|
+
sharedChunkDiagnostics.delete(fileName);
|
|
9437
|
+
return direct;
|
|
9438
|
+
}
|
|
9439
|
+
const withoutExt = fileName.replace(/\.[^./\\]+$/, "");
|
|
9440
|
+
const fallback = sharedChunkDiagnostics.get(withoutExt);
|
|
9441
|
+
if (fallback) {
|
|
9442
|
+
sharedChunkDiagnostics.delete(withoutExt);
|
|
9443
|
+
return fallback;
|
|
9444
|
+
}
|
|
9445
|
+
}
|
|
9446
|
+
function getCachedSharedChunkName(moduleId) {
|
|
9447
|
+
if (!sharedChunkNameCache.has(moduleId)) return;
|
|
9448
|
+
return sharedChunkNameCache.get(moduleId) ?? null;
|
|
9449
|
+
}
|
|
9450
|
+
function setCachedSharedChunkName(moduleId, value) {
|
|
9451
|
+
if (!moduleId) return;
|
|
9452
|
+
sharedChunkNameCache.set(moduleId, value ?? null);
|
|
9453
|
+
}
|
|
9454
|
+
//#endregion
|
|
9455
|
+
//#region src/runtime/chunkStrategy/utils.ts
|
|
9456
|
+
function replaceAll(source, searchValue, replaceValue) {
|
|
9457
|
+
if (!searchValue) return source;
|
|
9458
|
+
if (source.includes(searchValue)) return source.split(searchValue).join(replaceValue);
|
|
9459
|
+
if (searchValue.startsWith("./") && replaceValue.startsWith("./")) {
|
|
9460
|
+
const trimmedSearch = searchValue.slice(2);
|
|
9461
|
+
const trimmedReplace = replaceValue.slice(2);
|
|
9462
|
+
if (trimmedSearch && source.includes(trimmedSearch)) return source.split(trimmedSearch).join(trimmedReplace);
|
|
9463
|
+
}
|
|
9464
|
+
return source;
|
|
9465
|
+
}
|
|
9466
|
+
function containsImportSpecifier(source, specifier) {
|
|
9467
|
+
if (!specifier) return false;
|
|
9468
|
+
if (source.includes(specifier)) return true;
|
|
9469
|
+
if (specifier.startsWith("./")) {
|
|
9470
|
+
const trimmed = specifier.slice(2);
|
|
9471
|
+
if (trimmed && source.includes(trimmed)) return true;
|
|
9472
|
+
}
|
|
9473
|
+
return false;
|
|
9474
|
+
}
|
|
9475
|
+
function hasInCollection$1(collection, value) {
|
|
9476
|
+
if (!collection || !value) return false;
|
|
9477
|
+
if (collection instanceof Set) return collection.has(value);
|
|
9478
|
+
if (Array.isArray(collection)) return collection.includes(value);
|
|
9479
|
+
if (collection instanceof Map) return collection.has(value);
|
|
9480
|
+
return false;
|
|
9481
|
+
}
|
|
9482
|
+
function createRelativeImport(fromFile, toFile) {
|
|
9483
|
+
const relative = posix.relative(posix.dirname(fromFile), toFile);
|
|
9484
|
+
if (!relative || relative.startsWith(".")) return relative || "./";
|
|
9485
|
+
return `./${relative}`;
|
|
9486
|
+
}
|
|
9487
|
+
//#endregion
|
|
9488
|
+
//#region src/runtime/chunkStrategy/bundle.ts
|
|
9489
|
+
function findChunkImporters(bundle, target) {
|
|
9490
|
+
const importers = /* @__PURE__ */ new Set();
|
|
9491
|
+
for (const [fileName, output] of Object.entries(bundle)) {
|
|
9492
|
+
if (fileName === target) continue;
|
|
9493
|
+
if (output?.type !== "chunk") continue;
|
|
9494
|
+
const chunk = output;
|
|
9495
|
+
if (chunk.imports.includes(target) || chunk.dynamicImports.includes(target)) {
|
|
9496
|
+
importers.add(fileName);
|
|
9497
|
+
continue;
|
|
9498
|
+
}
|
|
9499
|
+
const metadata = chunk.viteMetadata;
|
|
9500
|
+
if (metadata) {
|
|
9501
|
+
const importedChunks = metadata.importedChunks;
|
|
9502
|
+
if (hasInCollection$1(importedChunks, target)) {
|
|
9503
|
+
importers.add(fileName);
|
|
9504
|
+
continue;
|
|
9505
|
+
}
|
|
9506
|
+
if (hasInCollection$1(metadata.importedScripts ?? metadata.importedScriptsByUrl, target)) {
|
|
9507
|
+
importers.add(fileName);
|
|
9508
|
+
continue;
|
|
9509
|
+
}
|
|
9510
|
+
}
|
|
9511
|
+
const potentialImport = createRelativeImport(fileName, target);
|
|
9512
|
+
if (potentialImport && potentialImport !== "./" && containsImportSpecifier(chunk.code ?? "", potentialImport)) importers.add(fileName);
|
|
9513
|
+
}
|
|
9514
|
+
return Array.from(importers);
|
|
9515
|
+
}
|
|
9516
|
+
function ensureUniqueFileName(bundle, fileName) {
|
|
8990
9517
|
if (!bundle[fileName]) return fileName;
|
|
8991
9518
|
const { dir, name, ext } = posix.parse(fileName);
|
|
8992
9519
|
let index = 1;
|
|
@@ -10530,16 +11057,42 @@ function watchWorkers(configService, watcherService, workersDir) {
|
|
|
10530
11057
|
}
|
|
10531
11058
|
//#endregion
|
|
10532
11059
|
//#region src/runtime/buildPlugin/service.ts
|
|
10533
|
-
function shouldHandleSnapshotSidecarFile(filePath) {
|
|
10534
|
-
|
|
11060
|
+
function shouldHandleSnapshotSidecarFile(filePath, configService) {
|
|
11061
|
+
if (isSidecarFile(filePath)) return true;
|
|
11062
|
+
const normalizedFile = normalizeFsResolvedId(filePath);
|
|
11063
|
+
const normalizedSrcRoot = normalizeFsResolvedId(configService.absoluteSrcRoot);
|
|
11064
|
+
if (normalizedFile === normalizedSrcRoot || normalizedFile.startsWith(`${normalizedSrcRoot}/`)) return false;
|
|
11065
|
+
return path.extname(filePath) !== "";
|
|
11066
|
+
}
|
|
11067
|
+
function isGeneratedMiniprogramWatchInclude(pattern, configService) {
|
|
11068
|
+
if (pattern === "**") return true;
|
|
11069
|
+
const normalizedPattern = normalizeFsResolvedId(path.isAbsolute(pattern) ? pattern : path.resolve(configService.cwd, pattern));
|
|
11070
|
+
const normalizedSrcRoot = normalizeFsResolvedId(configService.absoluteSrcRoot);
|
|
11071
|
+
if (normalizedPattern === normalizedSrcRoot || normalizedPattern.startsWith(`${normalizedSrcRoot}/`)) return true;
|
|
11072
|
+
if (configService.absolutePluginRoot) {
|
|
11073
|
+
const normalizedPluginRoot = normalizeFsResolvedId(configService.absolutePluginRoot);
|
|
11074
|
+
if (normalizedPattern === normalizedPluginRoot || normalizedPattern.startsWith(`${normalizedPluginRoot}/`)) return true;
|
|
11075
|
+
}
|
|
11076
|
+
return (configService.configFileDependencies ?? []).some((dependency) => {
|
|
11077
|
+
return normalizedPattern === normalizeFsResolvedId(dependency);
|
|
11078
|
+
});
|
|
10535
11079
|
}
|
|
10536
|
-
function
|
|
10537
|
-
|
|
11080
|
+
function resolveUserBuildWatchInclude(configService, inlineConfig) {
|
|
11081
|
+
const buildWatch = inlineConfig?.build?.watch ?? configService?.inlineConfig?.build?.watch;
|
|
11082
|
+
if (!buildWatch || typeof buildWatch !== "object") return [];
|
|
11083
|
+
const include = buildWatch.include;
|
|
11084
|
+
return (Array.isArray(include) ? include : include ? [include] : []).filter((pattern) => typeof pattern === "string").filter((pattern) => !isGeneratedMiniprogramWatchInclude(pattern, configService)).map((pattern) => path.normalize(path.isAbsolute(pattern) ? pattern : path.resolve(configService.cwd, pattern)));
|
|
11085
|
+
}
|
|
11086
|
+
function createSnapshotSidecarWatchPatterns(configService, inlineConfig) {
|
|
11087
|
+
const root = configService.absoluteSrcRoot;
|
|
11088
|
+
const patterns = [
|
|
10538
11089
|
...configSuffixes$1.map((suffix) => path.join(root, `**/*${suffix}`)),
|
|
10539
11090
|
...Array.from(watchedCssExts).map((ext) => path.join(root, `**/*${ext}`)),
|
|
10540
11091
|
...Array.from(watchedTemplateExts).map((ext) => path.join(root, `**/*${ext}`)),
|
|
10541
11092
|
...Array.from(watchedScriptModuleExts).map((ext) => path.join(root, `**/*${ext}`))
|
|
10542
11093
|
];
|
|
11094
|
+
for (const include of resolveUserBuildWatchInclude(configService, inlineConfig)) patterns.push(include);
|
|
11095
|
+
return patterns;
|
|
10543
11096
|
}
|
|
10544
11097
|
function createSnapshotSidecarIgnoredMatcher(ctx) {
|
|
10545
11098
|
const configService = ctx.configService;
|
|
@@ -10776,6 +11329,7 @@ function createBuildService(ctx) {
|
|
|
10776
11329
|
}
|
|
10777
11330
|
const buildState = ctx.runtimeState.build;
|
|
10778
11331
|
const { queue } = buildState;
|
|
11332
|
+
const requestedConfigRestartBuilds = /* @__PURE__ */ new Set();
|
|
10779
11333
|
let autoTouchResolved = false;
|
|
10780
11334
|
let autoTouchChecked = false;
|
|
10781
11335
|
const { buildIndependentBundle, getIndependentOutput, invalidateIndependentOutput } = createIndependentBuilder(configService, buildState);
|
|
@@ -10799,6 +11353,22 @@ function createBuildService(ctx) {
|
|
|
10799
11353
|
const normalizedFile = normalizeFsResolvedId(filePath);
|
|
10800
11354
|
return normalizedFile === normalizedOutDir || normalizedFile.startsWith(`${normalizedOutDir}/`);
|
|
10801
11355
|
}
|
|
11356
|
+
function shouldRestartDevBuild(target) {
|
|
11357
|
+
if (!configService.isDev) return false;
|
|
11358
|
+
return requestedConfigRestartBuilds.delete(target);
|
|
11359
|
+
}
|
|
11360
|
+
function resetRuntimeStateForConfigRestart() {
|
|
11361
|
+
const fresh = createRuntimeState();
|
|
11362
|
+
ctx.runtimeState.autoRoutes = fresh.autoRoutes;
|
|
11363
|
+
ctx.runtimeState.autoImport = fresh.autoImport;
|
|
11364
|
+
ctx.runtimeState.build.hmr = fresh.build.hmr;
|
|
11365
|
+
ctx.runtimeState.json = fresh.json;
|
|
11366
|
+
ctx.runtimeState.asset = fresh.asset;
|
|
11367
|
+
ctx.runtimeState.css = fresh.css;
|
|
11368
|
+
ctx.runtimeState.wxml = fresh.wxml;
|
|
11369
|
+
ctx.runtimeState.scan = fresh.scan;
|
|
11370
|
+
ctx.runtimeState.lib = fresh.lib;
|
|
11371
|
+
}
|
|
10802
11372
|
async function runDev(target) {
|
|
10803
11373
|
if (process.env.NODE_ENV === void 0) process.env.NODE_ENV = "development";
|
|
10804
11374
|
debug$2?.(`[${target}] dev build watcher start`);
|
|
@@ -10856,13 +11426,16 @@ function createBuildService(ctx) {
|
|
|
10856
11426
|
const startedAt = reason ? performance.now() : 0;
|
|
10857
11427
|
snapshotBuildChain = snapshotBuildChain.then(async () => {
|
|
10858
11428
|
if (devWatcherClosed) return;
|
|
10859
|
-
if (reason?.event || reason?.file)
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
11429
|
+
if (reason?.event || reason?.file) {
|
|
11430
|
+
if (reason.file) invalidateFileCache(reason.file);
|
|
11431
|
+
ctx.runtimeState.build.hmr.profile = {
|
|
11432
|
+
...ctx.runtimeState.build.hmr.profile,
|
|
11433
|
+
eventId: createHmrProfileEventId(),
|
|
11434
|
+
event: reason.event,
|
|
11435
|
+
file: reason.file,
|
|
11436
|
+
watchToDirtyMs: performance.now() - startedAt
|
|
11437
|
+
};
|
|
11438
|
+
}
|
|
10866
11439
|
const sidecarEntryId = await resolveSnapshotSidecarEntryId(reason);
|
|
10867
11440
|
if (sidecarEntryId) {
|
|
10868
11441
|
markSnapshotEntryDirty(sidecarEntryId);
|
|
@@ -10920,6 +11493,15 @@ function createBuildService(ctx) {
|
|
|
10920
11493
|
resetHmrProfile();
|
|
10921
11494
|
if (appWxssPath && shouldTouchAppWxss()) touch(appWxssPath).catch(() => {});
|
|
10922
11495
|
resolveWatcher(e);
|
|
11496
|
+
if (shouldRestartDevBuild(target)) {
|
|
11497
|
+
await watcher.close();
|
|
11498
|
+
logger_default.info("检测到 Vite 配置变更,正在重启小程序开发构建...");
|
|
11499
|
+
resetRuntimeStateForConfigRestart();
|
|
11500
|
+
await configService.load(configService.loadOptions);
|
|
11501
|
+
await scanService.loadAppEntry().catch(() => {});
|
|
11502
|
+
logger_default.success("Vite 配置已重新加载,小程序开发构建已重启。");
|
|
11503
|
+
await runDev(target);
|
|
11504
|
+
}
|
|
10923
11505
|
})().catch((error) => {
|
|
10924
11506
|
resetHmrProfile();
|
|
10925
11507
|
rejectWatcher(error);
|
|
@@ -10932,7 +11514,7 @@ function createBuildService(ctx) {
|
|
|
10932
11514
|
await promise;
|
|
10933
11515
|
const watcherRoot = target === "plugin" ? configService.absolutePluginRoot ?? configService.absoluteSrcRoot : "/";
|
|
10934
11516
|
if (target === "app" && !watcherService.sidecarWatcherMap.has(snapshotWatcherRoot)) {
|
|
10935
|
-
const snapshotWatcher = chokidar.watch(createSnapshotSidecarWatchPatterns(configService
|
|
11517
|
+
const snapshotWatcher = chokidar.watch(createSnapshotSidecarWatchPatterns(configService, buildOptions), createSidecarWatchOptions(configService, {
|
|
10936
11518
|
persistent: true,
|
|
10937
11519
|
ignoreInitial: true,
|
|
10938
11520
|
ignored: createSnapshotSidecarIgnoredMatcher(ctx)
|
|
@@ -10940,7 +11522,7 @@ function createBuildService(ctx) {
|
|
|
10940
11522
|
snapshotWatcher.on("all", (event, id) => {
|
|
10941
11523
|
if (!id) return;
|
|
10942
11524
|
if (isDevOutputFile(id)) return;
|
|
10943
|
-
if (!shouldHandleSnapshotSidecarFile(id)) return;
|
|
11525
|
+
if (!shouldHandleSnapshotSidecarFile(id, configService)) return;
|
|
10944
11526
|
const sidecarStartedAt = performance.now();
|
|
10945
11527
|
runSnapshotBuild({
|
|
10946
11528
|
event: event.startsWith("unlink") ? "delete" : event.startsWith("add") ? "create" : "update",
|
|
@@ -11041,7 +11623,10 @@ function createBuildService(ctx) {
|
|
|
11041
11623
|
}
|
|
11042
11624
|
async function runBuildTarget(target) {
|
|
11043
11625
|
ctx.currentBuildTarget = target;
|
|
11044
|
-
if (configService.isDev)
|
|
11626
|
+
if (configService.isDev) {
|
|
11627
|
+
requestedConfigRestartBuilds.delete(target);
|
|
11628
|
+
return await runDev(target);
|
|
11629
|
+
}
|
|
11045
11630
|
return await runProd(target);
|
|
11046
11631
|
}
|
|
11047
11632
|
async function buildEntry(options) {
|
|
@@ -11061,87 +11646,33 @@ function createBuildService(ctx) {
|
|
|
11061
11646
|
});
|
|
11062
11647
|
if (!configService.isDev && !isLibMode && !pluginOnly && (options?.skipNpm !== true && hasLocalSubPackageNpmConfig(ctx) || configService.weappViteConfig.worker?.entry !== void 0)) {
|
|
11063
11648
|
await scanService.loadAppEntry();
|
|
11064
|
-
scanService.loadSubPackages();
|
|
11065
|
-
}
|
|
11066
|
-
debug$2?.("build start");
|
|
11067
|
-
const npmBuildTask = isLibMode ? Promise.resolve() : scheduleNpmBuild(options);
|
|
11068
|
-
const result = await runBuildTarget(pluginOnly ? "plugin" : "app");
|
|
11069
|
-
if (shouldEmitLibDts) await generateLibDts(configService);
|
|
11070
|
-
await npmBuildTask;
|
|
11071
|
-
if (!pluginOnly && !isLibMode && configService.absolutePluginRoot) await runIsolatedPluginBuild(options);
|
|
11072
|
-
debug$2?.("build end");
|
|
11073
|
-
return result;
|
|
11074
|
-
}
|
|
11075
|
-
return {
|
|
11076
|
-
queue,
|
|
11077
|
-
build: buildEntry,
|
|
11078
|
-
buildIndependentBundle,
|
|
11079
|
-
getIndependentOutput,
|
|
11080
|
-
invalidateIndependentOutput
|
|
11081
|
-
};
|
|
11082
|
-
}
|
|
11083
|
-
//#endregion
|
|
11084
|
-
//#region src/runtime/buildPlugin/index.ts
|
|
11085
|
-
function createBuildServicePlugin(ctx) {
|
|
11086
|
-
ctx.buildService = createBuildService(ctx);
|
|
11087
|
-
return { name: "weapp-runtime:build-service" };
|
|
11088
|
-
}
|
|
11089
|
-
//#endregion
|
|
11090
|
-
//#region src/multiPlatform.ts
|
|
11091
|
-
const DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT = "config";
|
|
11092
|
-
function normalizeMultiPlatformProjectConfigRoot(input) {
|
|
11093
|
-
if (typeof input !== "string") return DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT;
|
|
11094
|
-
return input.trim() || "config";
|
|
11095
|
-
}
|
|
11096
|
-
function resolveMultiPlatformTargets(value) {
|
|
11097
|
-
const supportedPlatforms = getSupportedMiniProgramPlatforms$1();
|
|
11098
|
-
if (value == null || value === "all") return supportedPlatforms;
|
|
11099
|
-
if (!Array.isArray(value)) throw new TypeError("`weapp.multiPlatform.targets` 必须是平台数组或 \"all\"。");
|
|
11100
|
-
const resolvedTargets = [];
|
|
11101
|
-
const invalidTargets = [];
|
|
11102
|
-
for (const rawTarget of value) {
|
|
11103
|
-
const resolvedTarget = typeof rawTarget === "string" ? resolveMiniPlatform(rawTarget) : void 0;
|
|
11104
|
-
if (!resolvedTarget) {
|
|
11105
|
-
invalidTargets.push(String(rawTarget));
|
|
11106
|
-
continue;
|
|
11649
|
+
scanService.loadSubPackages();
|
|
11107
11650
|
}
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
|
|
11113
|
-
|
|
11114
|
-
|
|
11115
|
-
|
|
11116
|
-
enabled: false,
|
|
11117
|
-
projectConfigRoot: DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT,
|
|
11118
|
-
targets: getSupportedMiniProgramPlatforms$1()
|
|
11119
|
-
};
|
|
11120
|
-
if (value === true) return {
|
|
11121
|
-
enabled: true,
|
|
11122
|
-
projectConfigRoot: DEFAULT_MULTI_PLATFORM_PROJECT_CONFIG_ROOT,
|
|
11123
|
-
targets: getSupportedMiniProgramPlatforms$1()
|
|
11124
|
-
};
|
|
11125
|
-
if (typeof value === "object" && value !== null) {
|
|
11126
|
-
const record = value;
|
|
11127
|
-
const targets = resolveMultiPlatformTargets(record.targets);
|
|
11128
|
-
return {
|
|
11129
|
-
enabled: record.enabled !== false,
|
|
11130
|
-
projectConfigRoot: normalizeMultiPlatformProjectConfigRoot(record.projectConfigRoot),
|
|
11131
|
-
targets
|
|
11132
|
-
};
|
|
11651
|
+
debug$2?.("build start");
|
|
11652
|
+
const npmBuildTask = isLibMode ? Promise.resolve() : scheduleNpmBuild(options);
|
|
11653
|
+
const result = await runBuildTarget(pluginOnly ? "plugin" : "app");
|
|
11654
|
+
if (shouldEmitLibDts) await generateLibDts(configService);
|
|
11655
|
+
await npmBuildTask;
|
|
11656
|
+
if (!pluginOnly && !isLibMode && configService.absolutePluginRoot) await runIsolatedPluginBuild(options);
|
|
11657
|
+
debug$2?.("build end");
|
|
11658
|
+
return result;
|
|
11133
11659
|
}
|
|
11134
11660
|
return {
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
|
|
11661
|
+
queue,
|
|
11662
|
+
build: buildEntry,
|
|
11663
|
+
requestConfigRestart(target = "app") {
|
|
11664
|
+
requestedConfigRestartBuilds.add(target);
|
|
11665
|
+
},
|
|
11666
|
+
buildIndependentBundle,
|
|
11667
|
+
getIndependentOutput,
|
|
11668
|
+
invalidateIndependentOutput
|
|
11138
11669
|
};
|
|
11139
11670
|
}
|
|
11140
|
-
|
|
11141
|
-
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
return
|
|
11671
|
+
//#endregion
|
|
11672
|
+
//#region src/runtime/buildPlugin/index.ts
|
|
11673
|
+
function createBuildServicePlugin(ctx) {
|
|
11674
|
+
ctx.buildService = createBuildService(ctx);
|
|
11675
|
+
return { name: "weapp-runtime:build-service" };
|
|
11145
11676
|
}
|
|
11146
11677
|
//#endregion
|
|
11147
11678
|
//#region src/runtime/packageAliases.ts
|
|
@@ -11285,131 +11816,6 @@ function createAliasManager(oxcAlias, defaultBuiltinAliases) {
|
|
|
11285
11816
|
return { injectBuiltinAliases };
|
|
11286
11817
|
}
|
|
11287
11818
|
//#endregion
|
|
11288
|
-
//#region src/defaults.ts
|
|
11289
|
-
const defaultExcluded = [
|
|
11290
|
-
"**/node_modules/**",
|
|
11291
|
-
"**/miniprogram_npm/**",
|
|
11292
|
-
"**/.weapp-vite",
|
|
11293
|
-
"**/.weapp-vite/**"
|
|
11294
|
-
];
|
|
11295
|
-
/**
|
|
11296
|
-
* 样式扩展名说明:
|
|
11297
|
-
* - wxss:微信小程序
|
|
11298
|
-
* - acss:支付宝小程序
|
|
11299
|
-
* - jxss:京东小程序
|
|
11300
|
-
* - ttss:头条小程序
|
|
11301
|
-
* - qss:QQ 小程序
|
|
11302
|
-
* - css:通用样式文件
|
|
11303
|
-
* - tyss:涂鸦小程序
|
|
11304
|
-
*/
|
|
11305
|
-
/**
|
|
11306
|
-
* 模板扩展名说明:
|
|
11307
|
-
* - wxml:微信小程序
|
|
11308
|
-
* - axml:支付宝小程序
|
|
11309
|
-
* - jxml:京东小程序
|
|
11310
|
-
* - ksml:快手小程序
|
|
11311
|
-
* - ttml:头条小程序
|
|
11312
|
-
* - qml:QQ 小程序
|
|
11313
|
-
* - tyml:涂鸦小程序
|
|
11314
|
-
* - xhsml:小红书小程序
|
|
11315
|
-
* - swan:百度小程序
|
|
11316
|
-
*/
|
|
11317
|
-
function getOutputExtensions(platform) {
|
|
11318
|
-
return getPlatformOutputExtensions(platform ?? DEFAULT_MP_PLATFORM);
|
|
11319
|
-
}
|
|
11320
|
-
function getWeappViteConfig() {
|
|
11321
|
-
return {
|
|
11322
|
-
autoRoutes: false,
|
|
11323
|
-
wxml: true,
|
|
11324
|
-
wxs: true,
|
|
11325
|
-
enhance: {
|
|
11326
|
-
wxml: true,
|
|
11327
|
-
wxs: true
|
|
11328
|
-
},
|
|
11329
|
-
platform: DEFAULT_MP_PLATFORM,
|
|
11330
|
-
multiPlatform: false,
|
|
11331
|
-
es5: false,
|
|
11332
|
-
packageSizeWarningBytes: 2 * 1024 * 1024,
|
|
11333
|
-
analyze: {
|
|
11334
|
-
budgets: {
|
|
11335
|
-
totalBytes: 20 * 1024 * 1024,
|
|
11336
|
-
mainBytes: 2 * 1024 * 1024,
|
|
11337
|
-
subPackageBytes: 2 * 1024 * 1024,
|
|
11338
|
-
independentBytes: 2 * 1024 * 1024,
|
|
11339
|
-
warningRatio: .85
|
|
11340
|
-
},
|
|
11341
|
-
history: {
|
|
11342
|
-
enabled: true,
|
|
11343
|
-
dir: ".weapp-vite/analyze-history",
|
|
11344
|
-
limit: 20
|
|
11345
|
-
}
|
|
11346
|
-
},
|
|
11347
|
-
jsFormat: "cjs",
|
|
11348
|
-
isAdditionalWxml: () => {
|
|
11349
|
-
return false;
|
|
11350
|
-
},
|
|
11351
|
-
npm: {
|
|
11352
|
-
enable: true,
|
|
11353
|
-
cache: true,
|
|
11354
|
-
alipayNpmMode: "node_modules"
|
|
11355
|
-
},
|
|
11356
|
-
hmr: {
|
|
11357
|
-
sharedChunks: "auto",
|
|
11358
|
-
touchAppWxss: "auto",
|
|
11359
|
-
logLevel: "default",
|
|
11360
|
-
profileJson: false
|
|
11361
|
-
},
|
|
11362
|
-
mcp: {
|
|
11363
|
-
enabled: true,
|
|
11364
|
-
autoStart: false,
|
|
11365
|
-
host: "127.0.0.1",
|
|
11366
|
-
port: 3088,
|
|
11367
|
-
endpoint: "/mcp",
|
|
11368
|
-
restEndpoint: "/api/weapp/devtools"
|
|
11369
|
-
},
|
|
11370
|
-
forwardConsole: {
|
|
11371
|
-
enabled: "auto",
|
|
11372
|
-
logLevels: [
|
|
11373
|
-
"log",
|
|
11374
|
-
"info",
|
|
11375
|
-
"warn",
|
|
11376
|
-
"error"
|
|
11377
|
-
],
|
|
11378
|
-
unhandledErrors: true
|
|
11379
|
-
},
|
|
11380
|
-
appPrelude: { mode: "require" },
|
|
11381
|
-
wevu: { defaults: { component: { allowNullPropInput: true } } },
|
|
11382
|
-
chunks: {
|
|
11383
|
-
sharedStrategy: "duplicate",
|
|
11384
|
-
sharedMode: "common",
|
|
11385
|
-
sharedOverrides: [],
|
|
11386
|
-
sharedPathRoot: void 0,
|
|
11387
|
-
dynamicImports: "preserve",
|
|
11388
|
-
logOptimization: true,
|
|
11389
|
-
forceDuplicatePatterns: [],
|
|
11390
|
-
duplicateWarningBytes: 512 * 1024
|
|
11391
|
-
}
|
|
11392
|
-
};
|
|
11393
|
-
}
|
|
11394
|
-
const defaultAssetExtensions = [
|
|
11395
|
-
"png",
|
|
11396
|
-
"jpg",
|
|
11397
|
-
"jpeg",
|
|
11398
|
-
"gif",
|
|
11399
|
-
"svg",
|
|
11400
|
-
"cer",
|
|
11401
|
-
"mp3",
|
|
11402
|
-
"aac",
|
|
11403
|
-
"m4a",
|
|
11404
|
-
"mp4",
|
|
11405
|
-
"wav",
|
|
11406
|
-
"ogg",
|
|
11407
|
-
"silk",
|
|
11408
|
-
"wasm",
|
|
11409
|
-
"br",
|
|
11410
|
-
"cert"
|
|
11411
|
-
];
|
|
11412
|
-
//#endregion
|
|
11413
11819
|
//#region src/runtime/config/enhance.ts
|
|
11414
11820
|
const enhanceKeys = [
|
|
11415
11821
|
"wxml",
|
|
@@ -11834,18 +12240,24 @@ function normalizePathAliasKey(key) {
|
|
|
11834
12240
|
return key.endsWith("/*") ? key.slice(0, -2) : key;
|
|
11835
12241
|
}
|
|
11836
12242
|
function normalizePathAliasTarget(target) {
|
|
11837
|
-
if (!target || target.includes("*") && !target.endsWith("/*")) return;
|
|
12243
|
+
if (!target || target.includes("*") && !(target === "*" || target.endsWith("/*"))) return;
|
|
12244
|
+
if (target === "*") return "";
|
|
11838
12245
|
return target.endsWith("/*") ? target.slice(0, -2) : target;
|
|
11839
12246
|
}
|
|
11840
|
-
function
|
|
12247
|
+
function resolvePathAliasBaseDir(configDir, compilerOptions) {
|
|
12248
|
+
const baseUrl = compilerOptions?.baseUrl;
|
|
12249
|
+
return typeof baseUrl === "string" && baseUrl ? path.resolve(configDir, baseUrl) : configDir;
|
|
12250
|
+
}
|
|
12251
|
+
function extractPathAliases(configDir, compilerOptions) {
|
|
11841
12252
|
const aliases = [];
|
|
11842
12253
|
const paths = compilerOptions?.paths;
|
|
11843
12254
|
if (!paths || typeof paths !== "object") return aliases;
|
|
12255
|
+
const baseDir = resolvePathAliasBaseDir(configDir, compilerOptions);
|
|
11844
12256
|
for (const [key, value] of Object.entries(paths)) {
|
|
11845
12257
|
const find = normalizePathAliasKey(key);
|
|
11846
12258
|
const target = Array.isArray(value) ? value.find((item) => typeof item === "string") : void 0;
|
|
11847
12259
|
const normalizedTarget = typeof target === "string" ? normalizePathAliasTarget(target) : void 0;
|
|
11848
|
-
if (!find ||
|
|
12260
|
+
if (!find || normalizedTarget === void 0) continue;
|
|
11849
12261
|
aliases.push({
|
|
11850
12262
|
find,
|
|
11851
12263
|
replacement: path.resolve(baseDir, normalizedTarget)
|
|
@@ -11936,6 +12348,7 @@ async function inspectTsconfigPathsUsage(cwd) {
|
|
|
11936
12348
|
enabled: root || references,
|
|
11937
12349
|
root,
|
|
11938
12350
|
references,
|
|
12351
|
+
aliases: referenceAliases,
|
|
11939
12352
|
referenceAliases
|
|
11940
12353
|
};
|
|
11941
12354
|
}
|
|
@@ -12004,6 +12417,10 @@ function injectResolvedAliases(config, aliases) {
|
|
|
12004
12417
|
}
|
|
12005
12418
|
resolve.alias = aliasArray;
|
|
12006
12419
|
}
|
|
12420
|
+
function mergeJsonAliasEntries(userAlias) {
|
|
12421
|
+
if (userAlias === false) return [];
|
|
12422
|
+
return getAliasEntries(userAlias);
|
|
12423
|
+
}
|
|
12007
12424
|
function normalizeManagedPathAliasKey(key) {
|
|
12008
12425
|
if (!key || key.includes("*") && !key.endsWith("/*")) return;
|
|
12009
12426
|
return key.endsWith("/*") ? key.slice(0, -2) : key;
|
|
@@ -12138,9 +12555,12 @@ function createLoadConfig(options) {
|
|
|
12138
12555
|
const srcRoot = config.weapp?.srcRoot ?? "";
|
|
12139
12556
|
injectResolvedAliases(config, collectManagedTsconfigAliases(config, cwd));
|
|
12140
12557
|
const tsconfigPathsUsage = await inspectTsconfigPathsUsage(cwd);
|
|
12558
|
+
const tsconfigUsageAliases = tsconfigPathsUsage.aliases ?? [];
|
|
12559
|
+
const tsconfigReferenceAliases = tsconfigPathsUsage.referenceAliases ?? [];
|
|
12560
|
+
const tsconfigAliases = tsconfigUsageAliases.length > 0 ? tsconfigUsageAliases : tsconfigReferenceAliases;
|
|
12141
12561
|
if (!tsconfigPathsUsage.enabled) injectDefaultSrcAlias(config, cwd, srcRoot);
|
|
12142
12562
|
else if (tsconfigPathsUsage.references && !tsconfigPathsUsage.root) {
|
|
12143
|
-
injectResolvedAliases(config,
|
|
12563
|
+
injectResolvedAliases(config, tsconfigAliases);
|
|
12144
12564
|
injectDefaultSrcAlias(config, cwd, srcRoot);
|
|
12145
12565
|
}
|
|
12146
12566
|
const resolvedLibConfig = libEntryConfigured ? resolveWeappLibConfig({
|
|
@@ -12199,7 +12619,7 @@ function createLoadConfig(options) {
|
|
|
12199
12619
|
mpDistRoot = libOutDir;
|
|
12200
12620
|
}
|
|
12201
12621
|
if (pluginOnly && buildConfig.outDir) mpDistRoot = buildConfig.outDir;
|
|
12202
|
-
const aliasEntries =
|
|
12622
|
+
const aliasEntries = mergeJsonAliasEntries(config.weapp?.jsonAlias);
|
|
12203
12623
|
config.plugins ??= [];
|
|
12204
12624
|
const tsconfigPathsOptions = config.weapp?.tsconfigPaths;
|
|
12205
12625
|
if (tsconfigPathsOptions !== false) {
|
|
@@ -12227,6 +12647,7 @@ function createLoadConfig(options) {
|
|
|
12227
12647
|
};
|
|
12228
12648
|
return {
|
|
12229
12649
|
config,
|
|
12650
|
+
loadOptions: opts,
|
|
12230
12651
|
aliasEntries,
|
|
12231
12652
|
outputExtensions,
|
|
12232
12653
|
packageJson,
|
|
@@ -12918,7 +13339,7 @@ function hasOwn$4(source, key) {
|
|
|
12918
13339
|
function resolveSfcAssetFileName(relativeBase, extension) {
|
|
12919
13340
|
return `${relativeBase}.${extension}`;
|
|
12920
13341
|
}
|
|
12921
|
-
function parseJsonSafely$
|
|
13342
|
+
function parseJsonSafely$2(source) {
|
|
12922
13343
|
if (!source) return;
|
|
12923
13344
|
try {
|
|
12924
13345
|
return JSON.parse(source);
|
|
@@ -12973,7 +13394,7 @@ function emitSfcJsonAsset(ctx, bundle, relativeBase, result, options) {
|
|
|
12973
13394
|
kind: options.kind ?? "unknown"
|
|
12974
13395
|
});
|
|
12975
13396
|
const defaultConfig = options.defaultConfig;
|
|
12976
|
-
let nextConfig = parseJsonSafely$
|
|
13397
|
+
let nextConfig = parseJsonSafely$2(result.config);
|
|
12977
13398
|
if (!nextConfig && options.defaults) nextConfig = mergeJson({}, options.defaults, "defaults");
|
|
12978
13399
|
if (defaultConfig) nextConfig = mergeJson(defaultConfig, nextConfig ?? {}, "emit");
|
|
12979
13400
|
if (defaultConfig && nextConfig) {
|
|
@@ -13132,8 +13553,12 @@ function normalizeVueConfigForPlatform(config, options) {
|
|
|
13132
13553
|
if (!config) return config;
|
|
13133
13554
|
try {
|
|
13134
13555
|
const parsed = JSON.parse(config);
|
|
13135
|
-
|
|
13136
|
-
|
|
13556
|
+
const normalized = options.kind === "app" ? normalizeAppJson(parsed) : parsed;
|
|
13557
|
+
if (!(jsonPlatformOptions.normalizeUsingComponents || options.kind === "app" || options.platform === "weapp" && shouldNormalizeWeappScopedSlotGenericPlaceholder(parsed))) return config;
|
|
13558
|
+
return resolveJson({
|
|
13559
|
+
json: normalized,
|
|
13560
|
+
type: options.kind
|
|
13561
|
+
}, void 0, options.platform, {
|
|
13137
13562
|
dependencies: jsonPlatformOptions.dependencies,
|
|
13138
13563
|
alipayNpmMode: jsonPlatformOptions.alipayNpmMode
|
|
13139
13564
|
}) ?? config;
|
|
@@ -13255,6 +13680,7 @@ function emitAlipayGenericPlaceholderAssets(ctx, bundle, relativeBase, configSou
|
|
|
13255
13680
|
function prepareNormalizedVueConfigForPlatform(options) {
|
|
13256
13681
|
return normalizeVueConfigForPlatform(options.config, {
|
|
13257
13682
|
platform: options.platform,
|
|
13683
|
+
kind: options.kind,
|
|
13258
13684
|
dependencies: options.dependencies,
|
|
13259
13685
|
alipayNpmMode: options.alipayNpmMode
|
|
13260
13686
|
});
|
|
@@ -13263,6 +13689,7 @@ function resolvePlatformConfigAssetState(options) {
|
|
|
13263
13689
|
const normalizedConfig = prepareNormalizedVueConfigForPlatform({
|
|
13264
13690
|
config: options.config,
|
|
13265
13691
|
platform: options.platform,
|
|
13692
|
+
kind: options.kind,
|
|
13266
13693
|
dependencies: options.dependencies,
|
|
13267
13694
|
alipayNpmMode: options.alipayNpmMode
|
|
13268
13695
|
});
|
|
@@ -13288,6 +13715,7 @@ function preparePlatformConfigAsset(bundle, options) {
|
|
|
13288
13715
|
const { normalizedConfig, genericPlaceholderBase } = resolvePlatformConfigAssetState({
|
|
13289
13716
|
relativeBase: options.relativeBase,
|
|
13290
13717
|
config: options.config,
|
|
13718
|
+
kind: options.kind,
|
|
13291
13719
|
platform: options.platform,
|
|
13292
13720
|
dependencies: options.dependencies,
|
|
13293
13721
|
alipayNpmMode: options.alipayNpmMode
|
|
@@ -13811,7 +14239,7 @@ function collectAutoRoutesWatchDirs(watchDirectories, matcherWatchRoots) {
|
|
|
13811
14239
|
* 过滤出真正需要交给 auto-routes watcher 处理的路由 Vue 文件。
|
|
13812
14240
|
*/
|
|
13813
14241
|
function isAutoRoutesWatchFile(filePath, allowedExtensions, isPagesRelatedPath) {
|
|
13814
|
-
return allowedExtensions.has(path.extname(filePath)) && isPagesRelatedPath(filePath);
|
|
14242
|
+
return !isAutoRoutesGeneratedFileName(path.basename(filePath)) && allowedExtensions.has(path.extname(filePath)) && isPagesRelatedPath(filePath);
|
|
13815
14243
|
}
|
|
13816
14244
|
/**
|
|
13817
14245
|
* 判断是否满足 auto-routes sidecar watcher 的启动前置条件。
|
|
@@ -13895,6 +14323,7 @@ function createAutoRoutesPlugin(ctx) {
|
|
|
13895
14323
|
cwd: configService.cwd,
|
|
13896
14324
|
absoluteSrcRoot: configService.absoluteSrcRoot,
|
|
13897
14325
|
include: autoRoutesConfig.include,
|
|
14326
|
+
managedOutputPaths: resolveAutoRoutesManagedOutputPaths(ctx),
|
|
13898
14327
|
subPackageRoots
|
|
13899
14328
|
});
|
|
13900
14329
|
}
|
|
@@ -14005,32 +14434,42 @@ function autoRoutes(ctx) {
|
|
|
14005
14434
|
}
|
|
14006
14435
|
//#endregion
|
|
14007
14436
|
//#region src/plugins/hooks/useLoadEntry/autoImport.ts
|
|
14008
|
-
function createAutoImportAugmenter(autoImportService, wxmlService) {
|
|
14437
|
+
function createAutoImportAugmenter(autoImportService, wxmlService, externalComponentEntryMap) {
|
|
14009
14438
|
const cache = /* @__PURE__ */ new Map();
|
|
14010
14439
|
return function applyAutoImports(baseName, json) {
|
|
14011
14440
|
const hit = wxmlService.getAggregatedAutoImportComponents?.(baseName) ?? wxmlService.getAggregatedComponents(baseName);
|
|
14012
|
-
if (!hit) return;
|
|
14441
|
+
if (!hit) return [];
|
|
14013
14442
|
const version = autoImportService.getVersion();
|
|
14014
14443
|
const cached = cache.get(baseName);
|
|
14015
|
-
const
|
|
14016
|
-
const
|
|
14444
|
+
const resolvedComponents = cached && cached.hit === hit && cached.version === version ? cached.resolvedComponents : (() => {
|
|
14445
|
+
const resolvedComponents = {};
|
|
14017
14446
|
for (const depComponentName of Object.keys(hit)) {
|
|
14018
14447
|
const match = autoImportService.resolve(depComponentName, baseName);
|
|
14019
14448
|
if (!match) continue;
|
|
14020
|
-
|
|
14449
|
+
resolvedComponents[match.value.name] = {
|
|
14450
|
+
from: match.value.from,
|
|
14451
|
+
resolvedId: match.value.resolvedId
|
|
14452
|
+
};
|
|
14021
14453
|
}
|
|
14022
14454
|
cache.set(baseName, {
|
|
14023
14455
|
hit,
|
|
14024
14456
|
version,
|
|
14025
|
-
|
|
14457
|
+
resolvedComponents
|
|
14026
14458
|
});
|
|
14027
|
-
return
|
|
14459
|
+
return resolvedComponents;
|
|
14028
14460
|
})();
|
|
14029
|
-
|
|
14461
|
+
const injectedEntries = [];
|
|
14462
|
+
for (const [name, resolved] of Object.entries(resolvedComponents)) {
|
|
14030
14463
|
const usingComponents = get(json, "usingComponents");
|
|
14031
|
-
if (isObject(usingComponents) && Reflect.has(usingComponents, name))
|
|
14032
|
-
|
|
14464
|
+
if (isObject(usingComponents) && Reflect.has(usingComponents, name)) {
|
|
14465
|
+
if (usingComponents[name] === resolved.from) injectedEntries.push(resolved.from);
|
|
14466
|
+
continue;
|
|
14467
|
+
}
|
|
14468
|
+
set(json, `usingComponents.${name}`, resolved.from);
|
|
14469
|
+
injectedEntries.push(resolved.from);
|
|
14470
|
+
if (resolved.resolvedId) externalComponentEntryMap?.set(resolved.from.replace(/^\/+/, ""), resolved.resolvedId);
|
|
14033
14471
|
}
|
|
14472
|
+
return injectedEntries;
|
|
14034
14473
|
};
|
|
14035
14474
|
}
|
|
14036
14475
|
//#endregion
|
|
@@ -14112,17 +14551,6 @@ function createExtendedLibManager() {
|
|
|
14112
14551
|
}
|
|
14113
14552
|
//#endregion
|
|
14114
14553
|
//#region src/plugins/hooks/useLoadEntry/jsonEmit.ts
|
|
14115
|
-
function normalizeAppJson(json) {
|
|
14116
|
-
if (!json || typeof json !== "object" || Array.isArray(json)) return json;
|
|
14117
|
-
const subPackages = Array.isArray(json.subPackages) ? json.subPackages : Array.isArray(json.subpackages) ? json.subpackages : [];
|
|
14118
|
-
return {
|
|
14119
|
-
...json,
|
|
14120
|
-
subPackages: subPackages.map((subPackage) => ({
|
|
14121
|
-
...subPackage,
|
|
14122
|
-
pages: Array.isArray(subPackage?.pages) ? subPackage.pages : []
|
|
14123
|
-
}))
|
|
14124
|
-
};
|
|
14125
|
-
}
|
|
14126
14554
|
function createJsonEmitManager(configService) {
|
|
14127
14555
|
const map = /* @__PURE__ */ new Map();
|
|
14128
14556
|
function register(entry) {
|
|
@@ -15077,7 +15505,7 @@ async function collectAppSideFiles(pluginCtx, id, json, jsonService, registerJso
|
|
|
15077
15505
|
registerJsonAsset({
|
|
15078
15506
|
json: await jsonService.read(jsonPath),
|
|
15079
15507
|
jsonPath,
|
|
15080
|
-
type: "
|
|
15508
|
+
type: "page"
|
|
15081
15509
|
});
|
|
15082
15510
|
};
|
|
15083
15511
|
await processSideJson(sitemapLocation);
|
|
@@ -15143,7 +15571,15 @@ async function collectAppEntries(options) {
|
|
|
15143
15571
|
cacheHit: true
|
|
15144
15572
|
};
|
|
15145
15573
|
}
|
|
15146
|
-
if (!isPluginBuild)
|
|
15574
|
+
if (!isPluginBuild) {
|
|
15575
|
+
const appJson = normalizeAppJson(json);
|
|
15576
|
+
registerJsonAsset({
|
|
15577
|
+
json: appJson,
|
|
15578
|
+
jsonPath: id,
|
|
15579
|
+
type: "app"
|
|
15580
|
+
});
|
|
15581
|
+
entries.push(...analyzeAppJson(appJson));
|
|
15582
|
+
}
|
|
15147
15583
|
if (isPluginBuild && pluginJsonForRegistration && pluginJsonPathForRegistration) {
|
|
15148
15584
|
const pluginPages = Object.values(get(pluginJsonForRegistration, "pages") ?? {});
|
|
15149
15585
|
const pluginComponents = Object.values(get(pluginJsonForRegistration, "publicComponents") ?? {});
|
|
@@ -15894,7 +16330,7 @@ function createEntryLoader(options) {
|
|
|
15894
16330
|
}
|
|
15895
16331
|
}
|
|
15896
16332
|
await ctx.autoImportService?.awaitPendingRegistrations?.();
|
|
15897
|
-
applyAutoImports(baseName, json);
|
|
16333
|
+
const injectedAutoImportEntries = applyAutoImports(baseName, json) ?? [];
|
|
15898
16334
|
const componentEntries = analyzeCommonJson(json);
|
|
15899
16335
|
const pendingAutoImportMap = ctx.runtimeState?.autoImport?.pendingEntriesByImporter;
|
|
15900
16336
|
const vueBaseName = vueEntryPath ? removeExtensionDeep(vueEntryPath) : void 0;
|
|
@@ -15908,7 +16344,7 @@ function createEntryLoader(options) {
|
|
|
15908
16344
|
for (const componentEntry of mergedComponentEntries) {
|
|
15909
16345
|
const normalizedComponentEntry = normalizeEntry(componentEntry, jsonPath);
|
|
15910
16346
|
explicitEntryTypes.set(normalizedComponentEntry, "component");
|
|
15911
|
-
if (pendingAutoImportEntries.includes(componentEntry)) forceEmitEntrySet.add(normalizedComponentEntry);
|
|
16347
|
+
if (pendingAutoImportEntries.includes(componentEntry) || injectedAutoImportEntries.includes(componentEntry)) forceEmitEntrySet.add(normalizedComponentEntry);
|
|
15912
16348
|
}
|
|
15913
16349
|
}
|
|
15914
16350
|
const normalizedEntries = shouldSkipAppEntries ? [] : prepareNormalizedEntries({
|
|
@@ -16022,6 +16458,7 @@ function resolveUpstreamPendingReasonSummary(dirtyReasonSummary) {
|
|
|
16022
16458
|
const hasLayoutFallback = dirtyReasonSummary.some((item) => item.startsWith("layout-fallback-full:"));
|
|
16023
16459
|
const hasLayoutPropagation = dirtyReasonSummary.some((item) => item.startsWith("layout-self:") || item.startsWith("layout-dependent:"));
|
|
16024
16460
|
const hasAutoRoutesTopology = dirtyReasonSummary.some((item) => item.startsWith("auto-routes-topology:"));
|
|
16461
|
+
if (dirtyReasonSummary.some((item) => item.startsWith("config-restart:"))) pendingReasonSummary.push("config-restart");
|
|
16025
16462
|
if (hasLayoutFallback) pendingReasonSummary.push("layout-fallback-full");
|
|
16026
16463
|
else if (hasLayoutPropagation) pendingReasonSummary.push("layout-propagation");
|
|
16027
16464
|
if (hasAutoRoutesTopology) pendingReasonSummary.push("auto-routes-topology");
|
|
@@ -16188,7 +16625,7 @@ function useLoadEntry(ctx, options) {
|
|
|
16188
16625
|
registerJsonAsset,
|
|
16189
16626
|
scanTemplateEntry,
|
|
16190
16627
|
emitEntriesChunks,
|
|
16191
|
-
applyAutoImports: createAutoImportAugmenter(ctx.autoImportService, ctx.wxmlService),
|
|
16628
|
+
applyAutoImports: createAutoImportAugmenter(ctx.autoImportService, ctx.wxmlService, ctx.runtimeState.build.hmr.externalComponentEntryMap),
|
|
16192
16629
|
extendedLibManager: createExtendedLibManager(),
|
|
16193
16630
|
buildTarget,
|
|
16194
16631
|
debug
|
|
@@ -16534,7 +16971,7 @@ function collectAffectedEntries(state, startId) {
|
|
|
16534
16971
|
const current = queue.shift();
|
|
16535
16972
|
if (visited.has(current)) continue;
|
|
16536
16973
|
visited.add(current);
|
|
16537
|
-
if (state.entryModuleIds.has(current)) {
|
|
16974
|
+
if (state.entryModuleIds.has(current) || state.resolvedEntryMap.has(current)) {
|
|
16538
16975
|
affected.add(current);
|
|
16539
16976
|
continue;
|
|
16540
16977
|
}
|
|
@@ -19891,6 +20328,18 @@ function isOutputFileChange(state, normalizedId) {
|
|
|
19891
20328
|
const normalizedOutDir = normalizeFsResolvedId(outDir);
|
|
19892
20329
|
return normalizedId === normalizedOutDir || normalizedId.startsWith(`${normalizedOutDir}/`);
|
|
19893
20330
|
}
|
|
20331
|
+
function isAutoRoutesGeneratedFileChange(state, normalizedId) {
|
|
20332
|
+
const configService = state.ctx.configService;
|
|
20333
|
+
if (!configService) return false;
|
|
20334
|
+
return isAutoRoutesGeneratedPath(normalizedId, {
|
|
20335
|
+
cwd: configService.cwd,
|
|
20336
|
+
absoluteSrcRoot: configService.absoluteSrcRoot,
|
|
20337
|
+
managedOutputPaths: resolveAutoRoutesManagedOutputPaths(state.ctx)
|
|
20338
|
+
});
|
|
20339
|
+
}
|
|
20340
|
+
function isConfigFileDependencyChange(state, normalizedId) {
|
|
20341
|
+
return state.ctx.configService.configFileDependencies.some((dependency) => normalizeFsResolvedId(dependency) === normalizedId);
|
|
20342
|
+
}
|
|
19894
20343
|
function isCurrentSubPackageFile(relativeSrc, subPackageMeta) {
|
|
19895
20344
|
const root = subPackageMeta?.subPackage.root;
|
|
19896
20345
|
return !root || relativeSrc === root || relativeSrc.startsWith(`${root}/`);
|
|
@@ -20127,6 +20576,13 @@ async function processChangedFile(state, id, event) {
|
|
|
20127
20576
|
const relativeCwd = configService.relativeCwd(normalizedId);
|
|
20128
20577
|
let handledByIndependentWatcher = false;
|
|
20129
20578
|
let independentMeta;
|
|
20579
|
+
const isConfigDependency = isConfigFileDependencyChange(state, normalizedId);
|
|
20580
|
+
if (isConfigDependency) {
|
|
20581
|
+
loadEntry?.invalidateResolveCache?.();
|
|
20582
|
+
scanService.markDirty();
|
|
20583
|
+
buildService.requestConfigRestart?.(state.buildTarget);
|
|
20584
|
+
for (const entryId of resolvedEntryMap.keys()) markEntryDirtyWithCause(entryId, "direct", "config-restart");
|
|
20585
|
+
}
|
|
20130
20586
|
if (event === "create" || event === "delete") {
|
|
20131
20587
|
loadEntry?.invalidateResolveCache?.();
|
|
20132
20588
|
await invalidateEntryForSidecar(ctx, normalizedId, event);
|
|
@@ -20141,7 +20597,7 @@ async function processChangedFile(state, id, event) {
|
|
|
20141
20597
|
const platformConfigPrefix = `${resolveMultiPlatformProjectConfigDir(configService.multiPlatform, platform)}/`;
|
|
20142
20598
|
shouldMarkProjectConfigDirty = relativeCwd.startsWith(platformConfigPrefix);
|
|
20143
20599
|
}
|
|
20144
|
-
if (relativeSrc === "app.json" || shouldMarkProjectConfigDirty) scanService.markDirty();
|
|
20600
|
+
if (!isConfigDependency && (relativeSrc === "app.json" || shouldMarkProjectConfigDirty)) scanService.markDirty();
|
|
20145
20601
|
const independentRoot = Array.from(scanService.independentSubPackageMap.keys()).find((root) => {
|
|
20146
20602
|
return relativeSrc.startsWith(`${root}/`);
|
|
20147
20603
|
});
|
|
@@ -20165,6 +20621,7 @@ function createWatchChangeHook(state) {
|
|
|
20165
20621
|
const normalizedId = normalizeFsResolvedId(id);
|
|
20166
20622
|
if (isSkippableResolvedId(normalizedId)) return;
|
|
20167
20623
|
if (isOutputFileChange(state, normalizedId)) return;
|
|
20624
|
+
if (isAutoRoutesGeneratedFileChange(state, normalizedId)) return;
|
|
20168
20625
|
const event = await normalizeWatchEvent(normalizedId, change.event, {
|
|
20169
20626
|
loadedEntrySet: state.loadedEntrySet,
|
|
20170
20627
|
resolvedEntryMap: state.resolvedEntryMap
|
|
@@ -20551,7 +21008,7 @@ function resolveBundleOutputExtensions(outputExtensions) {
|
|
|
20551
21008
|
function hasOwn(source, key) {
|
|
20552
21009
|
return Object.prototype.hasOwnProperty.call(source, key);
|
|
20553
21010
|
}
|
|
20554
|
-
function parseJsonSafely(source) {
|
|
21011
|
+
function parseJsonSafely$1(source) {
|
|
20555
21012
|
if (!source) return;
|
|
20556
21013
|
try {
|
|
20557
21014
|
return JSON.parse(source);
|
|
@@ -20559,7 +21016,7 @@ function parseJsonSafely(source) {
|
|
|
20559
21016
|
return;
|
|
20560
21017
|
}
|
|
20561
21018
|
}
|
|
20562
|
-
function normalizeJsonConfigForPlatform(json, compilerCtx) {
|
|
21019
|
+
function normalizeJsonConfigForPlatform$1(json, compilerCtx) {
|
|
20563
21020
|
const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
|
|
20564
21021
|
if (!jsonPlatformOptions.normalizeUsingComponents) return json;
|
|
20565
21022
|
try {
|
|
@@ -20633,7 +21090,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
|
|
|
20633
21090
|
const scopedSlots = result.scopedSlotComponents;
|
|
20634
21091
|
if (!scopedSlots?.length) return;
|
|
20635
21092
|
const { templateExtension, jsonExtension } = resolveBundleOutputExtensions(outputExtensions);
|
|
20636
|
-
const configObj = parseJsonSafely(result.config) ?? {};
|
|
21093
|
+
const configObj = parseJsonSafely$1(result.config) ?? {};
|
|
20637
21094
|
const baseUsingComponents = configObj.usingComponents && typeof configObj.usingComponents === "object" && !Array.isArray(configObj.usingComponents) ? { ...configObj.usingComponents } : {};
|
|
20638
21095
|
const usingComponents = { ...baseUsingComponents };
|
|
20639
21096
|
registerScopedSlotHostGenerics(compilerCtx, scopedSlots, baseUsingComponents);
|
|
@@ -20664,7 +21121,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
|
|
|
20664
21121
|
};
|
|
20665
21122
|
json = mergeJson(defaultConfig, json, "emit");
|
|
20666
21123
|
if (hasOwn(defaultConfig, "component")) json.component = true;
|
|
20667
|
-
const normalizedJson = normalizeJsonConfigForPlatform(json, compilerCtx);
|
|
21124
|
+
const normalizedJson = normalizeJsonConfigForPlatform$1(json, compilerCtx);
|
|
20668
21125
|
ctx.emitFile({
|
|
20669
21126
|
type: "asset",
|
|
20670
21127
|
fileName: jsonFile,
|
|
@@ -20674,7 +21131,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
|
|
|
20674
21131
|
if (scopedSlot.classStyleWxs && classStyleWxs) emitClassStyleWxsAssetIfMissing(ctx, bundle, classStyleWxs.fileName, classStyleWxs.source);
|
|
20675
21132
|
}
|
|
20676
21133
|
configObj.usingComponents = usingComponents;
|
|
20677
|
-
result.config = JSON.stringify(normalizeJsonConfigForPlatform(configObj, compilerCtx), null, 2);
|
|
21134
|
+
result.config = JSON.stringify(normalizeJsonConfigForPlatform$1(configObj, compilerCtx), null, 2);
|
|
20678
21135
|
}
|
|
20679
21136
|
//#endregion
|
|
20680
21137
|
//#region src/plugins/vue/transform/scopedSlot/module.ts
|
|
@@ -20755,6 +21212,70 @@ function loadScopedSlotModule(id, scopedSlotModules) {
|
|
|
20755
21212
|
};
|
|
20756
21213
|
}
|
|
20757
21214
|
//#endregion
|
|
21215
|
+
//#region src/plugins/vue/transform/slotFallbackWrapper.ts
|
|
21216
|
+
function parseJsonSafely(source) {
|
|
21217
|
+
if (!source) return {};
|
|
21218
|
+
try {
|
|
21219
|
+
const parsed = JSON.parse(source);
|
|
21220
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
21221
|
+
} catch {
|
|
21222
|
+
return {};
|
|
21223
|
+
}
|
|
21224
|
+
}
|
|
21225
|
+
function normalizeJsonConfigForPlatform(json, compilerCtx) {
|
|
21226
|
+
const jsonPlatformOptions = resolveVueTransformJsonPlatformOptions(compilerCtx?.configService);
|
|
21227
|
+
if (!jsonPlatformOptions.normalizeUsingComponents) return json;
|
|
21228
|
+
try {
|
|
21229
|
+
const source = resolveJson({ json }, void 0, jsonPlatformOptions.platform, {
|
|
21230
|
+
dependencies: jsonPlatformOptions.dependencies,
|
|
21231
|
+
alipayNpmMode: jsonPlatformOptions.alipayNpmMode
|
|
21232
|
+
});
|
|
21233
|
+
return source ? JSON.parse(source) : json;
|
|
21234
|
+
} catch {
|
|
21235
|
+
return json;
|
|
21236
|
+
}
|
|
21237
|
+
}
|
|
21238
|
+
function emitSlotFallbackWrapperScriptIfMissing(ctx, bundle, fileName, script) {
|
|
21239
|
+
const existing = bundle[fileName];
|
|
21240
|
+
if (existing && existing.type === "asset") {
|
|
21241
|
+
if ((existing.source?.toString?.() ?? "") !== script) existing.source = script;
|
|
21242
|
+
return;
|
|
21243
|
+
}
|
|
21244
|
+
if (!existing) ctx.emitFile({
|
|
21245
|
+
type: "asset",
|
|
21246
|
+
fileName,
|
|
21247
|
+
source: script
|
|
21248
|
+
});
|
|
21249
|
+
}
|
|
21250
|
+
function injectSlotFallbackWrapperUsingComponent(result, relativeBase, compilerCtx) {
|
|
21251
|
+
const component = result.slotFallbackWrapperComponent;
|
|
21252
|
+
if (!component) return;
|
|
21253
|
+
const config = parseJsonSafely(result.config);
|
|
21254
|
+
const usingComponents = config.usingComponents && typeof config.usingComponents === "object" && !Array.isArray(config.usingComponents) ? { ...config.usingComponents } : {};
|
|
21255
|
+
usingComponents[component.tagName] = `/${toPosixPath(`${relativeBase}.${component.componentBase}`)}`;
|
|
21256
|
+
config.usingComponents = usingComponents;
|
|
21257
|
+
result.config = JSON.stringify(normalizeJsonConfigForPlatform(config, compilerCtx), null, 2);
|
|
21258
|
+
}
|
|
21259
|
+
function emitSlotFallbackWrapperComponentAsset(options) {
|
|
21260
|
+
const component = options.result.slotFallbackWrapperComponent;
|
|
21261
|
+
if (!component) return;
|
|
21262
|
+
const { templateExtension, jsonExtension, scriptExtension } = resolveBundleOutputExtensions(options.outputExtensions);
|
|
21263
|
+
const componentBase = `${options.relativeBase}.${component.componentBase}`;
|
|
21264
|
+
emitSfcTemplateIfMissing(options.ctx, options.bundle, componentBase, component.template, templateExtension);
|
|
21265
|
+
const jsonFileName = `${componentBase}.${jsonExtension}`;
|
|
21266
|
+
const mergeJson = createJsonMerger(options.jsonOptions?.mergeStrategy, {
|
|
21267
|
+
filename: jsonFileName,
|
|
21268
|
+
kind: "component"
|
|
21269
|
+
});
|
|
21270
|
+
let config = component.config;
|
|
21271
|
+
if (options.jsonOptions?.defaults && Object.keys(options.jsonOptions.defaults).length > 0) config = mergeJson(config, options.jsonOptions.defaults, "defaults");
|
|
21272
|
+
emitSfcJsonAsset(options.ctx, options.bundle, componentBase, { config: JSON.stringify(normalizeJsonConfigForPlatform(config, options.compilerCtx), null, 2) }, {
|
|
21273
|
+
kind: "component",
|
|
21274
|
+
extension: jsonExtension
|
|
21275
|
+
});
|
|
21276
|
+
emitSlotFallbackWrapperScriptIfMissing(options.ctx, options.bundle, `${componentBase}.${scriptExtension}`, component.script);
|
|
21277
|
+
}
|
|
21278
|
+
//#endregion
|
|
20758
21279
|
//#region src/plugins/vue/transform/bundle/shared/assets.ts
|
|
20759
21280
|
const APP_VUE_LIKE_FILE_RE$1 = /[\\/]app\.(?:vue|jsx|tsx)$/;
|
|
20760
21281
|
function resolveVueBundleAssetContext(configService) {
|
|
@@ -20775,6 +21296,7 @@ function emitSharedVueEntryJsonAsset(options) {
|
|
|
20775
21296
|
pluginCtx: options.pluginCtx,
|
|
20776
21297
|
relativeBase: options.relativeBase,
|
|
20777
21298
|
config: options.config,
|
|
21299
|
+
kind: options.jsonOptions.kind,
|
|
20778
21300
|
outputExtensions: options.outputExtensions,
|
|
20779
21301
|
...options.platformAssetOptions
|
|
20780
21302
|
});
|
|
@@ -20823,6 +21345,19 @@ function emitSharedVueEntryAssets(options) {
|
|
|
20823
21345
|
defaults: scopedSlotDefaults,
|
|
20824
21346
|
mergeStrategy: scopedSlotMergeStrategy
|
|
20825
21347
|
});
|
|
21348
|
+
emitSlotFallbackWrapperComponentAsset({
|
|
21349
|
+
ctx: pluginCtx,
|
|
21350
|
+
bundle,
|
|
21351
|
+
relativeBase,
|
|
21352
|
+
result,
|
|
21353
|
+
compilerCtx: ctx,
|
|
21354
|
+
outputExtensions,
|
|
21355
|
+
jsonOptions: {
|
|
21356
|
+
defaults: scopedSlotDefaults,
|
|
21357
|
+
mergeStrategy: scopedSlotMergeStrategy
|
|
21358
|
+
}
|
|
21359
|
+
});
|
|
21360
|
+
injectSlotFallbackWrapperUsingComponent(result, relativeBase, ctx);
|
|
20826
21361
|
return { classStyleWxs };
|
|
20827
21362
|
}
|
|
20828
21363
|
function emitBundleVueEntryAssets(options) {
|
|
@@ -21020,6 +21555,7 @@ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, conf
|
|
|
21020
21555
|
const scopedSlotsRequireProps = configService.weappViteConfig?.vue?.template?.scopedSlotsRequireProps ?? false;
|
|
21021
21556
|
const slotSingleRootNoWrapper = configService.weappViteConfig?.vue?.template?.slotSingleRootNoWrapper ?? false;
|
|
21022
21557
|
const slotFallbackWrapper = configService.weappViteConfig?.vue?.template?.slotFallbackWrapper;
|
|
21558
|
+
const slotFallbackWrapperStrategy = configService.weappViteConfig?.vue?.template?.slotFallbackWrapperStrategy ?? (configService.platform === "weapp" && slotFallbackWrapper === void 0 ? "virtual-host" : "view");
|
|
21023
21559
|
const slotMultipleInstance = configService.weappViteConfig?.vue?.template?.slotMultipleInstance ?? true;
|
|
21024
21560
|
const htmlTagToWxml = configService.weappViteConfig?.vue?.template?.htmlTagToWxml;
|
|
21025
21561
|
const htmlTagToWxmlTagClass = configService.weappViteConfig?.vue?.template?.htmlTagToWxmlTagClass ?? true;
|
|
@@ -21111,6 +21647,7 @@ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, conf
|
|
|
21111
21647
|
scopedSlotsRequireProps,
|
|
21112
21648
|
slotSingleRootNoWrapper,
|
|
21113
21649
|
slotFallbackWrapper,
|
|
21650
|
+
slotFallbackWrapperStrategy,
|
|
21114
21651
|
slotMultipleInstance,
|
|
21115
21652
|
classStyleRuntime: templatePlatformOptions.classStyleRuntime,
|
|
21116
21653
|
objectLiteralBindMode,
|
|
@@ -23203,9 +23740,9 @@ function resolveMiniprogramWatchInclude(options) {
|
|
|
23203
23740
|
watchInclude.push(path.join(pluginPatternBase, "**"));
|
|
23204
23741
|
}
|
|
23205
23742
|
for (const dependency of options.configFileDependencies ?? []) watchInclude.push(dependency);
|
|
23206
|
-
const
|
|
23743
|
+
const include = [...Array.isArray(options.userInclude) ? options.userInclude : options.userInclude ? [options.userInclude] : [], ...watchInclude];
|
|
23207
23744
|
const seen = /* @__PURE__ */ new Set();
|
|
23208
|
-
return
|
|
23745
|
+
return include.filter((item) => {
|
|
23209
23746
|
if (typeof item !== "string") return true;
|
|
23210
23747
|
if (seen.has(item)) return false;
|
|
23211
23748
|
seen.add(item);
|
|
@@ -23244,6 +23781,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
23244
23781
|
};
|
|
23245
23782
|
if (isDev) {
|
|
23246
23783
|
const hmrWatchBuildDelay = 60;
|
|
23784
|
+
const userBuildWatch = config.build?.watch;
|
|
23247
23785
|
const watchInclude = resolveMiniprogramWatchInclude({
|
|
23248
23786
|
cwd,
|
|
23249
23787
|
srcRoot,
|
|
@@ -23260,6 +23798,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
23260
23798
|
modulePreload: false,
|
|
23261
23799
|
watch: {
|
|
23262
23800
|
buildDelay: hmrWatchBuildDelay,
|
|
23801
|
+
...typeof userBuildWatch === "object" && userBuildWatch ? userBuildWatch : {},
|
|
23263
23802
|
exclude: [...defaultExcluded, mpDistRoot ? path.join(cwd, mpDistRoot, "**") : path.join(cwd, "dist", "**")],
|
|
23264
23803
|
include: watchInclude
|
|
23265
23804
|
},
|
|
@@ -23269,6 +23808,14 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
23269
23808
|
sourcemap: false
|
|
23270
23809
|
}
|
|
23271
23810
|
});
|
|
23811
|
+
inline.build.watch.include = resolveMiniprogramWatchInclude({
|
|
23812
|
+
cwd,
|
|
23813
|
+
srcRoot,
|
|
23814
|
+
pluginRoot: config.weapp?.pluginRoot,
|
|
23815
|
+
buildScope: resolveBuildScope(config.weapp?.buildScope),
|
|
23816
|
+
userInclude: inline.build?.watch?.include,
|
|
23817
|
+
configFileDependencies
|
|
23818
|
+
});
|
|
23272
23819
|
normalizeInlineConfigAfterDefu(inline, {
|
|
23273
23820
|
cwd,
|
|
23274
23821
|
ctx,
|
|
@@ -23290,6 +23837,7 @@ function mergeMiniprogram(options, ...configs) {
|
|
|
23290
23837
|
rolldownOptions: { ...rolldownOptions }
|
|
23291
23838
|
}
|
|
23292
23839
|
});
|
|
23840
|
+
if (inlineConfig.build) delete inlineConfig.build.watch;
|
|
23293
23841
|
normalizeInlineConfigAfterDefu(inlineConfig, {
|
|
23294
23842
|
cwd,
|
|
23295
23843
|
ctx,
|
|
@@ -23618,6 +24166,7 @@ function createConfigService(ctx) {
|
|
|
23618
24166
|
emitDefaultAutoImportOutputs: true,
|
|
23619
24167
|
projectConfig: {},
|
|
23620
24168
|
config: {},
|
|
24169
|
+
loadOptions: input,
|
|
23621
24170
|
packageJson: {},
|
|
23622
24171
|
platform: "weapp",
|
|
23623
24172
|
multiPlatform: resolveMultiPlatformConfig(false),
|
|
@@ -23715,6 +24264,9 @@ function createConfigService(ctx) {
|
|
|
23715
24264
|
get inlineConfig() {
|
|
23716
24265
|
return options.config;
|
|
23717
24266
|
},
|
|
24267
|
+
get loadOptions() {
|
|
24268
|
+
return options.loadOptions;
|
|
24269
|
+
},
|
|
23718
24270
|
get weappViteConfig() {
|
|
23719
24271
|
return options.config.weapp;
|
|
23720
24272
|
},
|
|
@@ -23822,17 +24374,6 @@ function createConfigServicePlugin(ctx) {
|
|
|
23822
24374
|
//#region src/runtime/jsonPlugin.ts
|
|
23823
24375
|
const APP_CONFIG_RE = /app\.json(?:\.[jt]s)?$/;
|
|
23824
24376
|
const SCRIPT_JSON_CONFIG_RE = /\.json\.[jt]s$/;
|
|
23825
|
-
function normalizeAppConfigJson(config) {
|
|
23826
|
-
if (!config || typeof config !== "object" || Array.isArray(config)) return config;
|
|
23827
|
-
const subPackages = Array.isArray(config.subPackages) ? config.subPackages : Array.isArray(config.subpackages) ? config.subpackages : [];
|
|
23828
|
-
return {
|
|
23829
|
-
...config,
|
|
23830
|
-
subPackages: subPackages.map((subPackage) => ({
|
|
23831
|
-
...subPackage,
|
|
23832
|
-
pages: Array.isArray(subPackage?.pages) ? subPackage.pages : []
|
|
23833
|
-
}))
|
|
23834
|
-
};
|
|
23835
|
-
}
|
|
23836
24377
|
function createJsonService(ctx) {
|
|
23837
24378
|
const cache = ctx.runtimeState.json.cache;
|
|
23838
24379
|
async function read(filepath) {
|
|
@@ -23854,25 +24395,20 @@ function createJsonService(ctx) {
|
|
|
23854
24395
|
};
|
|
23855
24396
|
const scriptContent = await fs.readFile(filepath, "utf8");
|
|
23856
24397
|
const inlinedContent = isAppConfig ? inlineAutoRoutesImports(scriptContent, fallbackRoutes) : scriptContent;
|
|
23857
|
-
const
|
|
23858
|
-
|
|
23859
|
-
|
|
23860
|
-
|
|
23861
|
-
|
|
23862
|
-
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
const exportedConfig = hasOwn$5(mod, "default") ? mod.default : mod;
|
|
23870
|
-
resultJson = typeof exportedConfig === "function" ? await exportedConfig(ctx) : exportedConfig;
|
|
23871
|
-
} finally {
|
|
23872
|
-
if (tempFilepath !== filepath) await fs.remove(tempFilepath);
|
|
23873
|
-
}
|
|
24398
|
+
const { mod } = await bundleRequire({
|
|
24399
|
+
filepath,
|
|
24400
|
+
cwd: configService.options.cwd,
|
|
24401
|
+
preserveTemporaryFile: true,
|
|
24402
|
+
...inlinedContent === scriptContent ? {} : { source: inlinedContent },
|
|
24403
|
+
rolldownOptions: {
|
|
24404
|
+
input: { define: configService.importMetaDefineEntries },
|
|
24405
|
+
output: { exports: "named" }
|
|
24406
|
+
}
|
|
24407
|
+
});
|
|
24408
|
+
const exportedConfig = hasOwn$5(mod, "default") ? mod.default : mod;
|
|
24409
|
+
resultJson = typeof exportedConfig === "function" ? await exportedConfig(ctx) : exportedConfig;
|
|
23874
24410
|
} else resultJson = parseCommentJson(await fs.readFile(filepath, "utf8"));
|
|
23875
|
-
if (isAppConfig) resultJson =
|
|
24411
|
+
if (isAppConfig) resultJson = normalizeAppJson(resultJson);
|
|
23876
24412
|
cache.set(filepath, resultJson);
|
|
23877
24413
|
return resultJson;
|
|
23878
24414
|
} catch (error) {
|
|
@@ -23904,244 +24440,6 @@ function createNpmServicePlugin(ctx) {
|
|
|
23904
24440
|
return { name: "weapp-runtime:npm-service" };
|
|
23905
24441
|
}
|
|
23906
24442
|
//#endregion
|
|
23907
|
-
//#region src/cache/file.ts
|
|
23908
|
-
const FNV_OFFSET_BASIS = 14695981039346656037n;
|
|
23909
|
-
const FNV_PRIME = 1099511628211n;
|
|
23910
|
-
const FNV_MASK = 18446744073709551615n;
|
|
23911
|
-
function fnv1aStep(hash, byte) {
|
|
23912
|
-
hash ^= BigInt(byte & 255);
|
|
23913
|
-
return hash * FNV_PRIME & FNV_MASK;
|
|
23914
|
-
}
|
|
23915
|
-
function createSignature(content) {
|
|
23916
|
-
let hash = FNV_OFFSET_BASIS;
|
|
23917
|
-
if (typeof content === "string") for (let i = 0; i < content.length; i++) {
|
|
23918
|
-
const code = content.charCodeAt(i);
|
|
23919
|
-
hash = fnv1aStep(hash, code & 255);
|
|
23920
|
-
const high = code >>> 8;
|
|
23921
|
-
if (high > 0) hash = fnv1aStep(hash, high);
|
|
23922
|
-
}
|
|
23923
|
-
else for (const byte of content) hash = fnv1aStep(hash, byte);
|
|
23924
|
-
return hash.toString(36);
|
|
23925
|
-
}
|
|
23926
|
-
var FileCache = class {
|
|
23927
|
-
cache;
|
|
23928
|
-
mtimeMap;
|
|
23929
|
-
signatureMap;
|
|
23930
|
-
constructor(max = 1024) {
|
|
23931
|
-
this.mtimeMap = /* @__PURE__ */ new Map();
|
|
23932
|
-
this.signatureMap = /* @__PURE__ */ new Map();
|
|
23933
|
-
this.cache = new LRUCache({
|
|
23934
|
-
max,
|
|
23935
|
-
dispose: (_value, key) => {
|
|
23936
|
-
this.mtimeMap.delete(key);
|
|
23937
|
-
this.signatureMap.delete(key);
|
|
23938
|
-
}
|
|
23939
|
-
});
|
|
23940
|
-
}
|
|
23941
|
-
get(id) {
|
|
23942
|
-
return this.cache.get(id);
|
|
23943
|
-
}
|
|
23944
|
-
set(id, content) {
|
|
23945
|
-
return this.cache.set(id, content);
|
|
23946
|
-
}
|
|
23947
|
-
delete(id) {
|
|
23948
|
-
this.mtimeMap.delete(id);
|
|
23949
|
-
this.signatureMap.delete(id);
|
|
23950
|
-
return this.cache.delete(id);
|
|
23951
|
-
}
|
|
23952
|
-
async isInvalidate(id, options) {
|
|
23953
|
-
const checkMtime = options?.checkMtime ?? true;
|
|
23954
|
-
const nextSignature = options?.signature ?? (options?.content !== void 0 ? createSignature(options.content) : void 0);
|
|
23955
|
-
if (!checkMtime) {
|
|
23956
|
-
if (nextSignature === void 0) return true;
|
|
23957
|
-
if (this.signatureMap.get(id) !== nextSignature) {
|
|
23958
|
-
this.signatureMap.set(id, nextSignature);
|
|
23959
|
-
return true;
|
|
23960
|
-
}
|
|
23961
|
-
return false;
|
|
23962
|
-
}
|
|
23963
|
-
let mtimeMs;
|
|
23964
|
-
if (typeof options?.mtimeMs === "number" && Number.isFinite(options.mtimeMs)) mtimeMs = options.mtimeMs;
|
|
23965
|
-
else try {
|
|
23966
|
-
mtimeMs = (await fs.stat(id)).mtimeMs;
|
|
23967
|
-
} catch (error) {
|
|
23968
|
-
if (error && error.code === "ENOENT") {
|
|
23969
|
-
this.cache.delete(id);
|
|
23970
|
-
this.mtimeMap.delete(id);
|
|
23971
|
-
this.signatureMap.delete(id);
|
|
23972
|
-
return true;
|
|
23973
|
-
}
|
|
23974
|
-
throw error;
|
|
23975
|
-
}
|
|
23976
|
-
if (mtimeMs === void 0) return true;
|
|
23977
|
-
const cachedMtime = this.mtimeMap.get(id);
|
|
23978
|
-
const updateSignature = () => {
|
|
23979
|
-
if (nextSignature !== void 0) this.signatureMap.set(id, nextSignature);
|
|
23980
|
-
};
|
|
23981
|
-
if (cachedMtime === void 0) {
|
|
23982
|
-
this.mtimeMap.set(id, mtimeMs);
|
|
23983
|
-
updateSignature();
|
|
23984
|
-
return true;
|
|
23985
|
-
} else if (cachedMtime > mtimeMs) {
|
|
23986
|
-
this.mtimeMap.set(id, mtimeMs);
|
|
23987
|
-
updateSignature();
|
|
23988
|
-
return true;
|
|
23989
|
-
} else if (cachedMtime === mtimeMs) {
|
|
23990
|
-
if (nextSignature !== void 0) {
|
|
23991
|
-
if (this.signatureMap.get(id) !== nextSignature) {
|
|
23992
|
-
updateSignature();
|
|
23993
|
-
return true;
|
|
23994
|
-
}
|
|
23995
|
-
}
|
|
23996
|
-
return false;
|
|
23997
|
-
} else {
|
|
23998
|
-
this.mtimeMap.set(id, mtimeMs);
|
|
23999
|
-
updateSignature();
|
|
24000
|
-
return true;
|
|
24001
|
-
}
|
|
24002
|
-
}
|
|
24003
|
-
};
|
|
24004
|
-
//#endregion
|
|
24005
|
-
//#region src/runtime/runtimeState.ts
|
|
24006
|
-
function createDefaultLoadConfigResult() {
|
|
24007
|
-
return {
|
|
24008
|
-
config: {},
|
|
24009
|
-
aliasEntries: [],
|
|
24010
|
-
outputExtensions: getOutputExtensions(DEFAULT_MP_PLATFORM),
|
|
24011
|
-
packageJson: {},
|
|
24012
|
-
relativeSrcRoot: (p) => p,
|
|
24013
|
-
cwd: process.cwd(),
|
|
24014
|
-
isDev: false,
|
|
24015
|
-
mode: "development",
|
|
24016
|
-
emitDefaultAutoImportOutputs: true,
|
|
24017
|
-
projectConfig: {},
|
|
24018
|
-
projectConfigPath: void 0,
|
|
24019
|
-
projectPrivateConfigPath: void 0,
|
|
24020
|
-
mpDistRoot: "",
|
|
24021
|
-
multiPlatform: resolveMultiPlatformConfig(false),
|
|
24022
|
-
weappLib: void 0,
|
|
24023
|
-
weappLibOutputMap: void 0,
|
|
24024
|
-
packageJsonPath: "",
|
|
24025
|
-
platform: DEFAULT_MP_PLATFORM,
|
|
24026
|
-
srcRoot: "",
|
|
24027
|
-
configFilePath: void 0,
|
|
24028
|
-
configFileDependencies: [],
|
|
24029
|
-
weappWeb: void 0,
|
|
24030
|
-
configMergeInfo: void 0
|
|
24031
|
-
};
|
|
24032
|
-
}
|
|
24033
|
-
function createDefaultPackageInfo() {
|
|
24034
|
-
return {
|
|
24035
|
-
name: "",
|
|
24036
|
-
version: void 0,
|
|
24037
|
-
rootPath: "",
|
|
24038
|
-
packageJsonPath: "",
|
|
24039
|
-
packageJson: {}
|
|
24040
|
-
};
|
|
24041
|
-
}
|
|
24042
|
-
function createDefaultPackageManager() {
|
|
24043
|
-
return {
|
|
24044
|
-
agent: "npm",
|
|
24045
|
-
name: "npm"
|
|
24046
|
-
};
|
|
24047
|
-
}
|
|
24048
|
-
function createRuntimeState() {
|
|
24049
|
-
const emptyAutoRoutesSnapshot = createEmptyAutoRoutesSnapshot();
|
|
24050
|
-
const emptyAutoRoutesArtifacts = createAutoRoutesArtifacts(emptyAutoRoutesSnapshot);
|
|
24051
|
-
return {
|
|
24052
|
-
autoRoutes: {
|
|
24053
|
-
routes: emptyAutoRoutesSnapshot,
|
|
24054
|
-
serialized: emptyAutoRoutesArtifacts.serialized,
|
|
24055
|
-
moduleCode: emptyAutoRoutesArtifacts.moduleCode,
|
|
24056
|
-
typedDefinition: "",
|
|
24057
|
-
watchFiles: /* @__PURE__ */ new Set(),
|
|
24058
|
-
watchDirs: /* @__PURE__ */ new Set(),
|
|
24059
|
-
dirty: true,
|
|
24060
|
-
initialized: false,
|
|
24061
|
-
candidates: /* @__PURE__ */ new Map(),
|
|
24062
|
-
needsFullRescan: true,
|
|
24063
|
-
loadingAppConfig: false
|
|
24064
|
-
},
|
|
24065
|
-
autoImport: {
|
|
24066
|
-
registry: /* @__PURE__ */ new Map(),
|
|
24067
|
-
resolvedResolverComponents: /* @__PURE__ */ new Map(),
|
|
24068
|
-
matcherKey: "",
|
|
24069
|
-
version: 0,
|
|
24070
|
-
pendingEntriesByImporter: /* @__PURE__ */ new Map()
|
|
24071
|
-
},
|
|
24072
|
-
build: {
|
|
24073
|
-
queue: new PQueue({ autoStart: false }),
|
|
24074
|
-
npmBuilt: false,
|
|
24075
|
-
independent: { outputs: /* @__PURE__ */ new Map() },
|
|
24076
|
-
hmr: {
|
|
24077
|
-
loadedEntrySet: /* @__PURE__ */ new Set(),
|
|
24078
|
-
dirtyEntrySet: /* @__PURE__ */ new Set(),
|
|
24079
|
-
dirtyEntryReasons: /* @__PURE__ */ new Map(),
|
|
24080
|
-
resolvedEntryMap: /* @__PURE__ */ new Map(),
|
|
24081
|
-
externalComponentEntryMap: /* @__PURE__ */ new Map(),
|
|
24082
|
-
entriesMap: /* @__PURE__ */ new Map(),
|
|
24083
|
-
layoutEntryDependents: /* @__PURE__ */ new Map(),
|
|
24084
|
-
entryLayoutDependencies: /* @__PURE__ */ new Map(),
|
|
24085
|
-
vueEntryHasTemplate: /* @__PURE__ */ new Map(),
|
|
24086
|
-
vueEntryNonJsonSignatures: /* @__PURE__ */ new Map(),
|
|
24087
|
-
vueEntryScriptSignatures: /* @__PURE__ */ new Map(),
|
|
24088
|
-
dirtyVueEntryIds: /* @__PURE__ */ new Set(),
|
|
24089
|
-
didEmitAllEntries: false,
|
|
24090
|
-
lastHmrEntryIds: /* @__PURE__ */ new Set(),
|
|
24091
|
-
lastEmittedEntryIds: /* @__PURE__ */ new Set(),
|
|
24092
|
-
recentProfiles: [],
|
|
24093
|
-
profile: {}
|
|
24094
|
-
}
|
|
24095
|
-
},
|
|
24096
|
-
json: {
|
|
24097
|
-
cache: new FileCache(),
|
|
24098
|
-
emittedSource: /* @__PURE__ */ new Map()
|
|
24099
|
-
},
|
|
24100
|
-
asset: {
|
|
24101
|
-
emittedBuffer: /* @__PURE__ */ new Map(),
|
|
24102
|
-
scopedSlotGenerics: /* @__PURE__ */ new Map()
|
|
24103
|
-
},
|
|
24104
|
-
css: {
|
|
24105
|
-
importerToDependencies: /* @__PURE__ */ new Map(),
|
|
24106
|
-
dependencyToImporters: /* @__PURE__ */ new Map(),
|
|
24107
|
-
emittedSource: /* @__PURE__ */ new Map()
|
|
24108
|
-
},
|
|
24109
|
-
watcher: {
|
|
24110
|
-
rollupWatcherMap: /* @__PURE__ */ new Map(),
|
|
24111
|
-
sidecarWatcherMap: /* @__PURE__ */ new Map()
|
|
24112
|
-
},
|
|
24113
|
-
wxml: {
|
|
24114
|
-
depsMap: /* @__PURE__ */ new Map(),
|
|
24115
|
-
importerMap: /* @__PURE__ */ new Map(),
|
|
24116
|
-
tokenMap: /* @__PURE__ */ new Map(),
|
|
24117
|
-
componentsMap: /* @__PURE__ */ new Map(),
|
|
24118
|
-
aggregatedComponentsMap: /* @__PURE__ */ new Map(),
|
|
24119
|
-
templatePathMap: /* @__PURE__ */ new Map(),
|
|
24120
|
-
cache: new FileCache(),
|
|
24121
|
-
emittedCode: /* @__PURE__ */ new Map()
|
|
24122
|
-
},
|
|
24123
|
-
scan: {
|
|
24124
|
-
subPackageMap: /* @__PURE__ */ new Map(),
|
|
24125
|
-
independentSubPackageMap: /* @__PURE__ */ new Map(),
|
|
24126
|
-
warnedMessages: /* @__PURE__ */ new Set(),
|
|
24127
|
-
isDirty: true,
|
|
24128
|
-
independentDirtyRoots: /* @__PURE__ */ new Set(),
|
|
24129
|
-
pluginJsonPath: void 0
|
|
24130
|
-
},
|
|
24131
|
-
lib: {
|
|
24132
|
-
enabled: false,
|
|
24133
|
-
entries: /* @__PURE__ */ new Map()
|
|
24134
|
-
},
|
|
24135
|
-
config: {
|
|
24136
|
-
packageInfo: createDefaultPackageInfo(),
|
|
24137
|
-
defineEnv: {},
|
|
24138
|
-
importMetaEnvDefineOverride: void 0,
|
|
24139
|
-
packageManager: createDefaultPackageManager(),
|
|
24140
|
-
options: createDefaultLoadConfigResult()
|
|
24141
|
-
}
|
|
24142
|
-
};
|
|
24143
|
-
}
|
|
24144
|
-
//#endregion
|
|
24145
24443
|
//#region src/runtime/scanPlugin/service/shared.ts
|
|
24146
24444
|
function createWarnOnce(warnedMessages) {
|
|
24147
24445
|
return function warnOnce(message) {
|
|
@@ -24232,10 +24530,10 @@ function mergeAutoRouteSubPackages(subPackages, routeSubPackages) {
|
|
|
24232
24530
|
return [...merged.values(), ...anonymousEntries];
|
|
24233
24531
|
}
|
|
24234
24532
|
function normalizeAppConfigSubPackages(config) {
|
|
24235
|
-
|
|
24236
|
-
|
|
24237
|
-
|
|
24238
|
-
|
|
24533
|
+
const normalized = normalizeAppJson(config);
|
|
24534
|
+
if (!isObject(normalized)) return config;
|
|
24535
|
+
for (const key of Object.keys(config)) delete config[key];
|
|
24536
|
+
Object.assign(config, normalized);
|
|
24239
24537
|
return config;
|
|
24240
24538
|
}
|
|
24241
24539
|
async function applyAutoRoutesToAppConfigIfNeeded(ctx, config) {
|
|
@@ -24273,7 +24571,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
24273
24571
|
const vueAppPath = await findVueEntry(appBasename);
|
|
24274
24572
|
let configFromVue;
|
|
24275
24573
|
if (!appConfigFile && vueAppPath) {
|
|
24276
|
-
const { extractConfigFromVue } = await import("./file-
|
|
24574
|
+
const { extractConfigFromVue } = await import("./file-C85Sj-OD.mjs");
|
|
24277
24575
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
24278
24576
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
24279
24577
|
}
|