weapp-vite 6.16.4 → 6.16.6
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/dist/auto-import-components/resolvers.mjs +1 -1
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +2189 -2097
- package/dist/{createContext-CoTaL8he.mjs → createContext-BEnghhM9.mjs} +96 -55
- package/dist/{file-D57m5ljp.mjs → file-CR2wVRDX.mjs} +1 -1
- package/dist/file-DcukQfQc.mjs +2 -0
- package/dist/getInstance-BAXgOqBQ.mjs +2 -0
- package/dist/index.mjs +2 -2
- package/dist/{runtime-DN3lxU9s.mjs → runtime-spnjzaP2.mjs} +2 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +14 -14
- package/dist/file-Dxf7qCi6.mjs +0 -2
- package/dist/getInstance-BWhJaTcd.mjs +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as applyWeappViteHostMeta } from "./pluginHost-BEnGeaSo.mjs";
|
|
2
2
|
import { n as configureLogger, r as logger_default } from "./logger-CgxdNjvb.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-CR2wVRDX.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";
|
|
@@ -464,6 +464,9 @@ function createDebugger(namespace) {
|
|
|
464
464
|
//#endregion
|
|
465
465
|
//#region src/context/shared.ts
|
|
466
466
|
const debug$2 = createDebugger("weapp-vite:context");
|
|
467
|
+
function hasOwn$6(source, key) {
|
|
468
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
469
|
+
}
|
|
467
470
|
function resolvedComponentName(entry) {
|
|
468
471
|
const base = path.basename(entry);
|
|
469
472
|
if (base === "index") {
|
|
@@ -480,7 +483,7 @@ function resolvedComponentName(entry) {
|
|
|
480
483
|
};
|
|
481
484
|
}
|
|
482
485
|
function isEmptyObject$1(obj) {
|
|
483
|
-
for (const key in obj) if (
|
|
486
|
+
for (const key in obj) if (hasOwn$6(obj, key)) return false;
|
|
484
487
|
return true;
|
|
485
488
|
}
|
|
486
489
|
//#endregion
|
|
@@ -792,6 +795,11 @@ function extractComponentProps(code, options) {
|
|
|
792
795
|
return collectComponentPropsFromCode(code, options);
|
|
793
796
|
}
|
|
794
797
|
//#endregion
|
|
798
|
+
//#region src/runtime/utils/object.ts
|
|
799
|
+
function hasOwn$5(source, key) {
|
|
800
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
801
|
+
}
|
|
802
|
+
//#endregion
|
|
795
803
|
//#region src/runtime/utils/constructorType.ts
|
|
796
804
|
const CONSTRUCTOR_TYPE_MAP = {
|
|
797
805
|
String: "string",
|
|
@@ -809,7 +817,7 @@ const CONSTRUCTOR_TYPE_MAP = {
|
|
|
809
817
|
NullConstructor: "any"
|
|
810
818
|
};
|
|
811
819
|
function mapConstructorName(name) {
|
|
812
|
-
if (
|
|
820
|
+
if (hasOwn$5(CONSTRUCTOR_TYPE_MAP, name)) return CONSTRUCTOR_TYPE_MAP[name];
|
|
813
821
|
return CONSTRUCTOR_TYPE_MAP[name.endsWith("Constructor") ? name.slice(0, -11) : name] ?? "any";
|
|
814
822
|
}
|
|
815
823
|
//#endregion
|
|
@@ -6216,15 +6224,6 @@ function createMiniProgramGlobalResolveExpression(options) {
|
|
|
6216
6224
|
const hostExpression = resolveMiniProgramGlobalHostExpression(options?.hostExpression);
|
|
6217
6225
|
return `(${globalKeys.map((key) => `${hostExpression}.${key}`).join(" ?? ")})`;
|
|
6218
6226
|
}
|
|
6219
|
-
function createMiniProgramHostOrTopLevelResolveExpression(options) {
|
|
6220
|
-
return `(${createMiniProgramGlobalResolveExpression({
|
|
6221
|
-
globalKeys: options?.globalKeys,
|
|
6222
|
-
hostExpression: options?.hostExpression
|
|
6223
|
-
})} ?? ${createMiniProgramTopLevelResolveExpression({
|
|
6224
|
-
globalKeys: options?.globalKeys,
|
|
6225
|
-
fallbackExpression: options?.fallbackExpression
|
|
6226
|
-
})})`;
|
|
6227
|
-
}
|
|
6228
6227
|
//#endregion
|
|
6229
6228
|
//#region src/runtime/autoRoutesPlugin/service/shared.ts
|
|
6230
6229
|
const AUTO_ROUTES_CACHE_FILE = ".weapp-vite/auto-routes.cache.json";
|
|
@@ -7554,8 +7553,8 @@ async function generateLibDts(configService) {
|
|
|
7554
7553
|
const tsconfigPath = path.resolve(configService.cwd, "tsconfig.json");
|
|
7555
7554
|
const hasTsconfig = await fs.pathExists(tsconfigPath);
|
|
7556
7555
|
const userRolldownOptions = dtsOptions?.rolldown ?? {};
|
|
7557
|
-
const hasUserTsconfig =
|
|
7558
|
-
const hasUserBuild =
|
|
7556
|
+
const hasUserTsconfig = hasOwn$5(userRolldownOptions, "tsconfig");
|
|
7557
|
+
const hasUserBuild = hasOwn$5(userRolldownOptions, "build");
|
|
7559
7558
|
const userTsconfig = userRolldownOptions.tsconfig;
|
|
7560
7559
|
const resolvedTsconfig = hasUserTsconfig ? typeof userTsconfig === "string" || userTsconfig === false ? userTsconfig : hasTsconfig ? tsconfigPath : false : hasTsconfig ? tsconfigPath : false;
|
|
7561
7560
|
const shouldUseBuildMode = !hasUserBuild && await tsconfigHasProjectReferences(resolvedTsconfig);
|
|
@@ -10560,7 +10559,7 @@ function createBuildService(ctx) {
|
|
|
10560
10559
|
const recentProfiles = ctx.runtimeState.build.hmr.recentProfiles;
|
|
10561
10560
|
if (recentProfiles.length < 4) return false;
|
|
10562
10561
|
if (recentProfiles.length - lastHmrSlowTipProfileCount < 3) return false;
|
|
10563
|
-
const currentProfile = recentProfiles.
|
|
10562
|
+
const currentProfile = recentProfiles[recentProfiles.length - 1];
|
|
10564
10563
|
if (!currentProfile) return false;
|
|
10565
10564
|
const previousProfiles = recentProfiles.slice(0, -1);
|
|
10566
10565
|
const previousAverage = previousProfiles.reduce((sum, item) => sum + item.totalMs, 0) / previousProfiles.length;
|
|
@@ -11223,7 +11222,7 @@ const enhanceKeys = [
|
|
|
11223
11222
|
let hasLoggedEnhanceDeprecation = false;
|
|
11224
11223
|
function hasDeprecatedEnhanceUsage(enhance) {
|
|
11225
11224
|
if (!enhance || typeof enhance !== "object") return false;
|
|
11226
|
-
return enhanceKeys.some((key) =>
|
|
11225
|
+
return enhanceKeys.some((key) => hasOwn$5(enhance, key));
|
|
11227
11226
|
}
|
|
11228
11227
|
function migrateEnhanceOptions(target, options) {
|
|
11229
11228
|
if (!target) return;
|
|
@@ -12192,6 +12191,9 @@ const AUTO_IMPORT_CONFIG_SUFFIXES = configExtensions.map((ext) => `.${ext}`);
|
|
|
12192
12191
|
const AUTO_IMPORT_JS_SUFFIXES = new Set(jsExtensions.map((ext) => `.${ext}`));
|
|
12193
12192
|
const AUTO_IMPORT_TEMPLATE_SUFFIXES = new Set(templateExtensions.map((ext) => `.${ext}`));
|
|
12194
12193
|
const AUTO_IMPORT_VUE_SUFFIXES = new Set(vueExtensions.map((ext) => `.${ext}`));
|
|
12194
|
+
function hasOwn$4(source, key) {
|
|
12195
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
12196
|
+
}
|
|
12195
12197
|
function isEnabledOutputOption(option) {
|
|
12196
12198
|
if (option === true) return true;
|
|
12197
12199
|
if (typeof option === "string") return option.trim().length > 0;
|
|
@@ -12308,7 +12310,7 @@ async function refreshAutoImportImporters(ctx, filePath) {
|
|
|
12308
12310
|
const touchedImporters = /* @__PURE__ */ new Set();
|
|
12309
12311
|
const entries = Array.from(wxmlService.wxmlComponentsMap.entries());
|
|
12310
12312
|
for (const [baseName, components] of entries) {
|
|
12311
|
-
if (!
|
|
12313
|
+
if (!hasOwn$4(components, componentName)) continue;
|
|
12312
12314
|
const pendingEntriesByImporter = ctx.runtimeState?.autoImport?.pendingEntriesByImporter;
|
|
12313
12315
|
const pendingEntry = (autoImportService?.resolve(componentName, baseName))?.value.from;
|
|
12314
12316
|
if (pendingEntriesByImporter && pendingEntry) {
|
|
@@ -13453,7 +13455,7 @@ async function collectLayoutFiles(root) {
|
|
|
13453
13455
|
const base = full.slice(0, -path.extname(full).length);
|
|
13454
13456
|
if (!(await findJsonEntry(base)).path) continue;
|
|
13455
13457
|
const parts = path.relative(comparableRoot, normalizeComparablePath(base)).split(PATH_SEGMENT_RE).filter(Boolean);
|
|
13456
|
-
if (parts.
|
|
13458
|
+
if (parts[parts.length - 1] === "index") parts.pop();
|
|
13457
13459
|
const layoutName = normalizeLayoutName(parts.join("/"));
|
|
13458
13460
|
if (!layoutName) continue;
|
|
13459
13461
|
const duplicated = layoutMap.get(layoutName);
|
|
@@ -13469,7 +13471,7 @@ async function collectLayoutFiles(root) {
|
|
|
13469
13471
|
const relativePath = path.relative(comparableRoot, normalizeComparablePath(full));
|
|
13470
13472
|
const ext = path.extname(relativePath);
|
|
13471
13473
|
const parts = relativePath.slice(0, -ext.length).split(PATH_SEGMENT_RE).filter(Boolean);
|
|
13472
|
-
if (parts.
|
|
13474
|
+
if (parts[parts.length - 1] === "index") parts.pop();
|
|
13473
13475
|
const layoutName = normalizeLayoutName(parts.join("/"));
|
|
13474
13476
|
if (!layoutName) continue;
|
|
13475
13477
|
const duplicated = layoutMap.get(layoutName);
|
|
@@ -14933,7 +14935,10 @@ function resolvePendingEntryIds(options) {
|
|
|
14933
14935
|
}
|
|
14934
14936
|
}
|
|
14935
14937
|
if (expandedImporters.size > 0) {
|
|
14936
|
-
const chunkPreview = [...relatedChunkIds].slice(0, 2).map((chunkId) =>
|
|
14938
|
+
const chunkPreview = [...relatedChunkIds].slice(0, 2).map((chunkId) => {
|
|
14939
|
+
const segments = chunkId.split("/");
|
|
14940
|
+
return segments[segments.length - 1];
|
|
14941
|
+
}).join(",");
|
|
14937
14942
|
const overflow = relatedChunkIds.size > 2 ? "+" : "";
|
|
14938
14943
|
const mode = expansionMode ? `:${expansionMode}` : "";
|
|
14939
14944
|
pendingReasonSummary.push(`shared-chunk(${chunkPreview}${overflow})+${expandedImporters.size}${mode}`);
|
|
@@ -15104,7 +15109,7 @@ function emitJsonAssets(state) {
|
|
|
15104
15109
|
function stripQuotes(value) {
|
|
15105
15110
|
if (!value) return value;
|
|
15106
15111
|
const first = value[0];
|
|
15107
|
-
const last = value.
|
|
15112
|
+
const last = value[value.length - 1];
|
|
15108
15113
|
if (first === last && (first === "\"" || first === "'") || first === "`" && last === "`") return value.slice(1, -1);
|
|
15109
15114
|
return value;
|
|
15110
15115
|
}
|
|
@@ -15541,7 +15546,7 @@ function hasCustomAutoRuleConfig(config) {
|
|
|
15541
15546
|
return Boolean(Array.isArray(config.dependencies) && config.dependencies.length > 0 || Array.isArray(config.targets) && config.targets.length > 0);
|
|
15542
15547
|
}
|
|
15543
15548
|
function hasConfiguredNetworkDefaults(config) {
|
|
15544
|
-
return Boolean(config && typeof config === "object" &&
|
|
15549
|
+
return Boolean(config && typeof config === "object" && hasOwn$5(config, "networkDefaults"));
|
|
15545
15550
|
}
|
|
15546
15551
|
function resolveAutoRules(config) {
|
|
15547
15552
|
if (hasCustomAutoRuleConfig(config)) return [{
|
|
@@ -15828,6 +15833,9 @@ function injectRequestGlobalsIntoSfc(source, targets, options) {
|
|
|
15828
15833
|
}
|
|
15829
15834
|
//#endregion
|
|
15830
15835
|
//#region src/plugins/core/lifecycle/transform/importMeta.ts
|
|
15836
|
+
function hasOwn$3(source, key) {
|
|
15837
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
15838
|
+
}
|
|
15831
15839
|
function isImportMetaNode(node) {
|
|
15832
15840
|
return node?.type === "MetaProperty" && node.meta?.type === "Identifier" && node.meta.name === "import" && node.property?.type === "Identifier" && node.property.name === "meta";
|
|
15833
15841
|
}
|
|
@@ -15893,7 +15901,7 @@ function replaceImportMetaAccess(code, options) {
|
|
|
15893
15901
|
MemberExpression(path) {
|
|
15894
15902
|
const envPropertyName = getImportMetaEnvPropertyName(path.node);
|
|
15895
15903
|
if (envPropertyName) {
|
|
15896
|
-
const envValue =
|
|
15904
|
+
const envValue = hasOwn$3(values.envAccess, envPropertyName) ? values.envAccess[envPropertyName] : void 0;
|
|
15897
15905
|
addReplacement(path.node, toInlineLiteral(envValue));
|
|
15898
15906
|
return;
|
|
15899
15907
|
}
|
|
@@ -15914,7 +15922,7 @@ function replaceImportMetaAccess(code, options) {
|
|
|
15914
15922
|
OptionalMemberExpression(path) {
|
|
15915
15923
|
const envPropertyName = getImportMetaEnvPropertyName(path.node);
|
|
15916
15924
|
if (envPropertyName) {
|
|
15917
|
-
const envValue =
|
|
15925
|
+
const envValue = hasOwn$3(values.envAccess, envPropertyName) ? values.envAccess[envPropertyName] : void 0;
|
|
15918
15926
|
addReplacement(path.node, toInlineLiteral(envValue));
|
|
15919
15927
|
return;
|
|
15920
15928
|
}
|
|
@@ -16038,30 +16046,35 @@ function prependChunkCodePreservingDirectives(code, injectedCode) {
|
|
|
16038
16046
|
}
|
|
16039
16047
|
//#endregion
|
|
16040
16048
|
//#region src/utils/weapi.ts
|
|
16041
|
-
function
|
|
16049
|
+
function getWeapiGlobalRootCandidateItems() {
|
|
16042
16050
|
return [
|
|
16043
|
-
`(
|
|
16044
|
-
`
|
|
16045
|
-
`
|
|
16046
|
-
`
|
|
16047
|
-
...getMiniProgramGlobalKeys().map((key) => {
|
|
16048
|
-
return ` || (typeof ${key} !== 'undefined' && ${key})`;
|
|
16049
|
-
}),
|
|
16050
|
-
` || {})`
|
|
16051
|
+
`(typeof globalThis !== 'undefined' && globalThis)`,
|
|
16052
|
+
`(typeof self !== 'undefined' && self)`,
|
|
16053
|
+
`(typeof window !== 'undefined' && window)`,
|
|
16054
|
+
`(typeof global !== 'undefined' && global)`
|
|
16051
16055
|
];
|
|
16052
16056
|
}
|
|
16053
|
-
function
|
|
16054
|
-
return
|
|
16057
|
+
function getWeapiGlobalHostCandidateItems() {
|
|
16058
|
+
return [...getWeapiGlobalRootCandidateItems(), ...getMiniProgramGlobalKeys().map((key) => `(typeof ${key} !== 'undefined' && ${key})`)];
|
|
16059
|
+
}
|
|
16060
|
+
function createUniqueCandidatesExpression(items) {
|
|
16061
|
+
return `([${items.join(",")}].filter(Boolean).filter((item,index,list)=>list.indexOf(item)===index))`;
|
|
16062
|
+
}
|
|
16063
|
+
function createGlobalRootCandidatesExpression() {
|
|
16064
|
+
return createUniqueCandidatesExpression(getWeapiGlobalRootCandidateItems());
|
|
16065
|
+
}
|
|
16066
|
+
function createGlobalHostCandidatesExpression() {
|
|
16067
|
+
return createUniqueCandidatesExpression(getWeapiGlobalHostCandidateItems());
|
|
16055
16068
|
}
|
|
16056
16069
|
function createNativeApiFallbackExpression() {
|
|
16057
16070
|
return createMiniProgramTopLevelResolveExpression({ globalKeys: getMiniProgramGlobalKeys() });
|
|
16058
16071
|
}
|
|
16059
|
-
function
|
|
16060
|
-
return
|
|
16072
|
+
function createWeapiHostCandidatesExpression() {
|
|
16073
|
+
return createGlobalRootCandidatesExpression();
|
|
16061
16074
|
}
|
|
16062
16075
|
function createWeapiAccessExpression(globalName) {
|
|
16063
16076
|
const globalKey = JSON.stringify(globalName);
|
|
16064
|
-
return `((${
|
|
16077
|
+
return `((${createGlobalHostCandidatesExpression()}.map(item=>item&&item[${globalKey}]).find(Boolean)) || ${createNativeApiFallbackExpression()})`;
|
|
16065
16078
|
}
|
|
16066
16079
|
//#endregion
|
|
16067
16080
|
//#region src/plugins/core/lifecycle/platformApiRewrite.ts
|
|
@@ -17146,6 +17159,9 @@ function createBuildEndHook(state) {
|
|
|
17146
17159
|
}
|
|
17147
17160
|
//#endregion
|
|
17148
17161
|
//#region src/plugins/utils/parse.ts
|
|
17162
|
+
function hasOwn$2(source, key) {
|
|
17163
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
17164
|
+
}
|
|
17149
17165
|
/**
|
|
17150
17166
|
* 参考:https://github.com/tailwindlabs/tailwindcss/blob/main/packages/%40tailwindcss-vite/src/index.ts
|
|
17151
17167
|
* 解析请求ID,返回包含文件名和查询参数的对象。
|
|
@@ -17159,7 +17175,7 @@ function parseRequest(id) {
|
|
|
17159
17175
|
if (rawQuery) {
|
|
17160
17176
|
const params = new URLSearchParams(rawQuery);
|
|
17161
17177
|
for (const [key, value] of params.entries()) query[key] = value;
|
|
17162
|
-
if (
|
|
17178
|
+
if (hasOwn$2(query, "wxss")) query.wxss = true;
|
|
17163
17179
|
}
|
|
17164
17180
|
return {
|
|
17165
17181
|
filename,
|
|
@@ -17217,23 +17233,31 @@ function resolveInjectWeapiOptions$1(configService) {
|
|
|
17217
17233
|
function createWeapiInjectionCode(options) {
|
|
17218
17234
|
const globalKey = JSON.stringify(options.globalName);
|
|
17219
17235
|
const platform = JSON.stringify(options.platform);
|
|
17220
|
-
const
|
|
17221
|
-
const
|
|
17236
|
+
const hostCandidatesExpression = createWeapiHostCandidatesExpression();
|
|
17237
|
+
const nativeApiResolveExpression = [`(${getMiniProgramGlobalKeys().map((globalKey) => `__weappResolveRootGlobal(${JSON.stringify(globalKey)})`).join(" ?? ")}`, ` ?? ${createMiniProgramTopLevelResolveExpression()})`].join("");
|
|
17238
|
+
const nativeApiFallbackExpression = [`(${getMiniProgramGlobalKeys().map((globalKey) => `__weappResolveGlobal(${JSON.stringify(globalKey)})`).join(" ?? ")}`, ` ?? ${createMiniProgramTopLevelResolveExpression()})`].join("");
|
|
17222
17239
|
const replaceLines = options.replaceWx ? [
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
`
|
|
17226
|
-
`
|
|
17240
|
+
` for (const __weappGlobal of __weappGlobals) {`,
|
|
17241
|
+
...getMiniProgramRuntimeGlobalKeys().map((globalKey) => ` __weappGlobal.${globalKey} = __weappInstance`),
|
|
17242
|
+
` if (__weappPlatformKey) {`,
|
|
17243
|
+
` __weappGlobal[__weappPlatformKey] = __weappInstance`,
|
|
17244
|
+
` }`,
|
|
17245
|
+
` }`
|
|
17227
17246
|
] : [];
|
|
17228
17247
|
return [
|
|
17229
17248
|
`import { wpi as __weappWpi } from '@wevu/api'`,
|
|
17230
|
-
`const
|
|
17249
|
+
`const __weappRootGlobals = ${hostCandidatesExpression}`,
|
|
17250
|
+
`const __weappResolveRootGlobal = key => __weappRootGlobals.map(item => item && item[key]).find(Boolean)`,
|
|
17251
|
+
`const __weappNativeApi = ${nativeApiResolveExpression}`,
|
|
17252
|
+
`const __weappGlobals = __weappRootGlobals.length ? __weappRootGlobals : [__weappNativeApi].filter(Boolean)`,
|
|
17253
|
+
`const __weappGlobal = __weappGlobals[0] || {}`,
|
|
17254
|
+
`const __weappResolveGlobal = key => __weappGlobals.map(item => item && item[key]).find(Boolean)`,
|
|
17231
17255
|
`const __weappPlatformKey = ${platform}`,
|
|
17232
17256
|
`if (__weappGlobal) {`,
|
|
17233
|
-
` const __weappExistingWpi =
|
|
17257
|
+
` const __weappExistingWpi = __weappResolveGlobal(${globalKey})`,
|
|
17234
17258
|
` const __weappInstance = __weappExistingWpi || __weappWpi`,
|
|
17235
17259
|
` if (!__weappExistingWpi) {`,
|
|
17236
|
-
` const __weappRawApi = (__weappPlatformKey ?
|
|
17260
|
+
` const __weappRawApi = (__weappPlatformKey ? __weappResolveGlobal(__weappPlatformKey) : undefined) ?? ${nativeApiFallbackExpression}`,
|
|
17237
17261
|
` if (__weappRawApi && __weappRawApi !== __weappWpi) {`,
|
|
17238
17262
|
` __weappWpi.setAdapter(__weappRawApi, __weappPlatformKey)`,
|
|
17239
17263
|
` }`,
|
|
@@ -18896,6 +18920,9 @@ function getSourceFromVirtualId(id) {
|
|
|
18896
18920
|
//#endregion
|
|
18897
18921
|
//#region src/plugins/vue/transform/emitAssets.ts
|
|
18898
18922
|
const emittedAssetSourceCache = /* @__PURE__ */ new Map();
|
|
18923
|
+
function hasOwn$1(source, key) {
|
|
18924
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
18925
|
+
}
|
|
18899
18926
|
/**
|
|
18900
18927
|
* 统一拼接 SFC 相关产物文件名。
|
|
18901
18928
|
*/
|
|
@@ -18957,7 +18984,7 @@ function emitSfcJsonAsset(ctx, bundle, relativeBase, result, options) {
|
|
|
18957
18984
|
if (!nextConfig && options.defaults) nextConfig = mergeJson({}, options.defaults, "defaults");
|
|
18958
18985
|
if (defaultConfig) nextConfig = mergeJson(defaultConfig, nextConfig ?? {}, "emit");
|
|
18959
18986
|
if (defaultConfig && nextConfig) {
|
|
18960
|
-
if (
|
|
18987
|
+
if (hasOwn$1(defaultConfig, "component") && !hasOwn$1(nextConfig, "component")) nextConfig.component = true;
|
|
18961
18988
|
}
|
|
18962
18989
|
if (!nextConfig && defaultConfig) nextConfig = defaultConfig;
|
|
18963
18990
|
if (!nextConfig) return;
|
|
@@ -19058,6 +19085,9 @@ function resolveVueTransformJsonPlatformOptions(configService) {
|
|
|
19058
19085
|
}
|
|
19059
19086
|
//#endregion
|
|
19060
19087
|
//#region src/plugins/vue/transform/scopedSlot/assets.ts
|
|
19088
|
+
function hasOwn(source, key) {
|
|
19089
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
19090
|
+
}
|
|
19061
19091
|
function parseJsonSafely(source) {
|
|
19062
19092
|
if (!source) return;
|
|
19063
19093
|
try {
|
|
@@ -19089,14 +19119,14 @@ function resolveScopedSlotAutoImports(compilerCtx, baseUsingComponents, componen
|
|
|
19089
19119
|
const token = wxmlService.analyze(template);
|
|
19090
19120
|
const depComponentNames = Object.keys(token.components ?? {});
|
|
19091
19121
|
for (const depComponentName of depComponentNames) {
|
|
19092
|
-
if (
|
|
19122
|
+
if (hasOwn(baseUsingComponents, depComponentName)) {
|
|
19093
19123
|
usingComponents[depComponentName] = baseUsingComponents[depComponentName];
|
|
19094
19124
|
continue;
|
|
19095
19125
|
}
|
|
19096
19126
|
const match = autoImportService.resolve(depComponentName, componentBase);
|
|
19097
19127
|
if (!match) continue;
|
|
19098
19128
|
const { value } = match;
|
|
19099
|
-
if (
|
|
19129
|
+
if (hasOwn(usingComponents, value.name)) continue;
|
|
19100
19130
|
usingComponents[value.name] = value.from;
|
|
19101
19131
|
}
|
|
19102
19132
|
} catch {
|
|
@@ -19104,6 +19134,15 @@ function resolveScopedSlotAutoImports(compilerCtx, baseUsingComponents, componen
|
|
|
19104
19134
|
}
|
|
19105
19135
|
return usingComponents;
|
|
19106
19136
|
}
|
|
19137
|
+
function resolveNestedScopedSlotUsingComponents(scopedSlots, currentComponentName, relativeBase, template) {
|
|
19138
|
+
const usingComponents = {};
|
|
19139
|
+
for (const scopedSlot of scopedSlots) {
|
|
19140
|
+
if (scopedSlot.componentName === currentComponentName) continue;
|
|
19141
|
+
if (!template.includes(scopedSlot.componentName)) continue;
|
|
19142
|
+
usingComponents[scopedSlot.componentName] = `/${toPosixPath(`${relativeBase}.__scoped-slot-${scopedSlot.id}`)}`;
|
|
19143
|
+
}
|
|
19144
|
+
return usingComponents;
|
|
19145
|
+
}
|
|
19107
19146
|
function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, classStyleWxs, outputExtensions, jsonOptions) {
|
|
19108
19147
|
const scopedSlots = result.scopedSlotComponents;
|
|
19109
19148
|
if (!scopedSlots?.length) return;
|
|
@@ -19118,6 +19157,7 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
|
|
|
19118
19157
|
const wxmlFile = `${componentBase}.${templateExtension}`;
|
|
19119
19158
|
const jsonFile = `${componentBase}.${jsonExtension}`;
|
|
19120
19159
|
const scopedUsingComponents = resolveScopedSlotAutoImports(compilerCtx, baseUsingComponents, componentBase, scopedSlot.template);
|
|
19160
|
+
Object.assign(scopedUsingComponents, resolveNestedScopedSlotUsingComponents(scopedSlots, scopedSlot.componentName, relativeBase, scopedSlot.template));
|
|
19121
19161
|
if (!bundle[wxmlFile]) ctx.emitFile({
|
|
19122
19162
|
type: "asset",
|
|
19123
19163
|
fileName: wxmlFile,
|
|
@@ -19129,13 +19169,14 @@ function emitScopedSlotAssets(ctx, bundle, relativeBase, result, compilerCtx, cl
|
|
|
19129
19169
|
kind: "component"
|
|
19130
19170
|
});
|
|
19131
19171
|
let json = mergeJson({}, { usingComponents: scopedUsingComponents }, "auto-using-components");
|
|
19172
|
+
if (scopedSlot.componentGenerics && Object.keys(scopedSlot.componentGenerics).length > 0) json = mergeJson(json, { componentGenerics: scopedSlot.componentGenerics }, "component-generics");
|
|
19132
19173
|
if (jsonOptions?.defaults && Object.keys(jsonOptions.defaults).length > 0) json = mergeJson(json, jsonOptions.defaults, "defaults");
|
|
19133
19174
|
const defaultConfig = {
|
|
19134
19175
|
component: true,
|
|
19135
19176
|
styleIsolation: "apply-shared"
|
|
19136
19177
|
};
|
|
19137
19178
|
json = mergeJson(defaultConfig, json, "emit");
|
|
19138
|
-
if (
|
|
19179
|
+
if (hasOwn(defaultConfig, "component")) json.component = true;
|
|
19139
19180
|
const normalizedJson = normalizeJsonConfigForPlatform(json, compilerCtx);
|
|
19140
19181
|
ctx.emitFile({
|
|
19141
19182
|
type: "asset",
|
|
@@ -22482,7 +22523,7 @@ function createJsonService(ctx) {
|
|
|
22482
22523
|
output: { exports: "named" }
|
|
22483
22524
|
}
|
|
22484
22525
|
});
|
|
22485
|
-
const exportedConfig =
|
|
22526
|
+
const exportedConfig = hasOwn$5(mod, "default") ? mod.default : mod;
|
|
22486
22527
|
resultJson = typeof exportedConfig === "function" ? await exportedConfig(ctx) : exportedConfig;
|
|
22487
22528
|
} finally {
|
|
22488
22529
|
if (tempFilepath !== filepath) await fs.remove(tempFilepath);
|
|
@@ -22880,7 +22921,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
22880
22921
|
const vueAppPath = await findVueEntry(appBasename);
|
|
22881
22922
|
let configFromVue;
|
|
22882
22923
|
if (!appConfigFile && vueAppPath) {
|
|
22883
|
-
const { extractConfigFromVue } = await import("./file-
|
|
22924
|
+
const { extractConfigFromVue } = await import("./file-DcukQfQc.mjs");
|
|
22884
22925
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
22885
22926
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
22886
22927
|
}
|
|
@@ -22988,7 +23029,7 @@ function coerceStyleConfig(entry) {
|
|
|
22988
23029
|
if (!entry || typeof entry !== "object") return;
|
|
22989
23030
|
const source = entry.source?.toString().trim();
|
|
22990
23031
|
if (!source) return;
|
|
22991
|
-
const hasExplicitScope =
|
|
23032
|
+
const hasExplicitScope = hasOwn$5(entry, "scope") && entry.scope != null;
|
|
22992
23033
|
return {
|
|
22993
23034
|
source,
|
|
22994
23035
|
scope: hasExplicitScope ? coerceScope(entry.scope) : "all",
|
|
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
84
84
|
}
|
|
85
85
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
86
86
|
try {
|
|
87
|
-
const { getCompilerContext } = await import("./getInstance-
|
|
87
|
+
const { getCompilerContext } = await import("./getInstance-BAXgOqBQ.mjs");
|
|
88
88
|
const compilerContext = getCompilerContext();
|
|
89
89
|
const service = compilerContext.autoRoutesService;
|
|
90
90
|
const reference = service?.getReference?.();
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-D0HkutE0.mjs";
|
|
2
2
|
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BEnGeaSo.mjs";
|
|
3
3
|
import { t as defineConfig } from "./config-DJjSbpNX.mjs";
|
|
4
|
-
import { c as WEB_PLATFORM_ALIASES, d as isWebPlatform, f as resolveWeappViteTarget, l as getSupportedWeappVitePlatforms, t as createCompilerContext, u as getSupportedWeappViteTargetDescriptors } from "./createContext-
|
|
5
|
-
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-
|
|
4
|
+
import { c as WEB_PLATFORM_ALIASES, d as isWebPlatform, f as resolveWeappViteTarget, l as getSupportedWeappVitePlatforms, t as createCompilerContext, u as getSupportedWeappViteTargetDescriptors } from "./createContext-BEnghhM9.mjs";
|
|
5
|
+
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-spnjzaP2.mjs";
|
|
6
6
|
export { WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout };
|
|
@@ -25,7 +25,8 @@ function resolveCurrentPageInstance() {
|
|
|
25
25
|
const getCurrentPagesFn = globalThis.getCurrentPages;
|
|
26
26
|
if (typeof getCurrentPagesFn !== "function") return;
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
const pages = getCurrentPagesFn();
|
|
29
|
+
return pages[pages.length - 1];
|
|
29
30
|
} catch {
|
|
30
31
|
return;
|
|
31
32
|
}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-
|
|
1
|
+
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-spnjzaP2.mjs";
|
|
2
2
|
export { createWevuComponent, defineEmits, defineProps, setPageLayout };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.16.
|
|
4
|
+
"version": "6.16.6",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -109,30 +109,30 @@
|
|
|
109
109
|
"pathe": "^2.0.3",
|
|
110
110
|
"picomatch": "^4.0.4",
|
|
111
111
|
"postcss": "^8.5.14",
|
|
112
|
-
"rolldown": "1.0.0-rc.
|
|
113
|
-
"rolldown-plugin-dts": "0.
|
|
112
|
+
"rolldown": "1.0.0-rc.18",
|
|
113
|
+
"rolldown-plugin-dts": "0.24.1",
|
|
114
114
|
"semver": "^7.7.4",
|
|
115
115
|
"typescript": "^6.0.3",
|
|
116
|
-
"vite": "8.0.
|
|
116
|
+
"vite": "8.0.11",
|
|
117
117
|
"vite-tsconfig-paths": "^6.1.1",
|
|
118
|
-
"vue": "^3.5.
|
|
118
|
+
"vue": "^3.5.34",
|
|
119
119
|
"vue-tsc": "^3.2.8",
|
|
120
120
|
"@weapp-core/constants": "^0.1.4",
|
|
121
121
|
"@weapp-core/init": "6.0.8",
|
|
122
122
|
"@weapp-core/logger": "3.1.1",
|
|
123
|
-
"@weapp-core/schematics": "6.0.4",
|
|
124
123
|
"@weapp-core/shared": "3.0.4",
|
|
125
|
-
"@weapp-vite/ast": "6.16.
|
|
126
|
-
"@weapp-
|
|
127
|
-
"@weapp-vite/
|
|
124
|
+
"@weapp-vite/ast": "6.16.6",
|
|
125
|
+
"@weapp-core/schematics": "6.0.4",
|
|
126
|
+
"@weapp-vite/mcp": "1.3.2",
|
|
127
|
+
"@weapp-vite/miniprogram-automator": "1.1.0",
|
|
128
|
+
"@weapp-vite/web": "1.3.20",
|
|
129
|
+
"@wevu/api": "0.2.8",
|
|
130
|
+
"@wevu/web-apis": "1.2.12",
|
|
128
131
|
"@weapp-vite/volar": "2.1.0",
|
|
129
|
-
"@weapp-vite/web": "1.3.19",
|
|
130
|
-
"@wevu/api": "0.2.6",
|
|
131
|
-
"@wevu/web-apis": "1.2.10",
|
|
132
132
|
"rolldown-require": "2.0.15",
|
|
133
133
|
"vite-plugin-performance": "2.0.1",
|
|
134
|
-
"weapp-ide-cli": "5.2.
|
|
135
|
-
"wevu": "6.16.
|
|
134
|
+
"weapp-ide-cli": "5.2.9",
|
|
135
|
+
"wevu": "6.16.6"
|
|
136
136
|
},
|
|
137
137
|
"publishConfig": {
|
|
138
138
|
"access": "public",
|
package/dist/file-Dxf7qCi6.mjs
DELETED