weapp-vite 6.17.6 → 6.17.7
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-routes.mjs +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/{createContext-BfOAQZMj.mjs → createContext-DooWF5Wk.mjs} +365 -44
- package/dist/{file-BOLzLiXg.mjs → file-2ZpSECMP.mjs} +1 -1
- package/dist/file-8RU-zw8X.mjs +2 -0
- package/dist/getInstance-CcEF8k1Z.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/file-XBQU6P82.mjs +0 -2
- package/dist/getInstance-BQwQvqtl.mjs +0 -2
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-
|
|
1
|
+
import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-DooWF5Wk.mjs";
|
|
2
2
|
//#region src/auto-routes.ts
|
|
3
3
|
const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
|
|
4
4
|
function createGetter(resolver) {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, a as formatBytes, b as getProjectConfigFileName, d as syncProjectSupportFiles, f as syncManagedTsconfigBootstrapFiles, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, p as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappViteTarget, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-
|
|
1
|
+
import { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, a as formatBytes, b as getProjectConfigFileName, d as syncProjectSupportFiles, f as syncManagedTsconfigBootstrapFiles, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, p as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappViteTarget, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-DooWF5Wk.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
3
|
+
import { h as VERSION } from "./file-2ZpSECMP.mjs";
|
|
4
4
|
import { c as startWeappViteMcpServer, l as detectAiDevelopmentEnvironment, s as resolveWeappMcpConfig } from "./mcp-BG6TliEg.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path, { posix } from "pathe";
|
|
@@ -4122,7 +4122,7 @@ function resolveRunnableHotkeyDefinition(input) {
|
|
|
4122
4122
|
}
|
|
4123
4123
|
//#endregion
|
|
4124
4124
|
//#region package.json
|
|
4125
|
-
var version = "6.17.
|
|
4125
|
+
var version = "6.17.7";
|
|
4126
4126
|
//#endregion
|
|
4127
4127
|
//#region src/cli/devHotkeys/format.ts
|
|
4128
4128
|
const FULLWIDTH_ASCII_START = 65281;
|
|
@@ -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-2ZpSECMP.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";
|
|
@@ -17898,9 +17898,163 @@ function useLoadEntry(ctx, options) {
|
|
|
17898
17898
|
const IMPLICIT_REQUIRE_RE = /\b(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*=\s*require\((`[^`]+`|'[^']+'|"[^"]+")\);?/g;
|
|
17899
17899
|
const REQUIRE_CALL_RE = /\brequire\((`[^`]+`|'[^']+'|"[^"]+")\)/g;
|
|
17900
17900
|
const WEVU_SRC_CHUNK_RE = /(?:^|\/)wevu-src\.js$/;
|
|
17901
|
+
const WEVU_VENDOR_RUNTIME_CHUNK_RE = /(?:^|\/)weapp-vendors\/wevu-[^/]+\.js$/;
|
|
17901
17902
|
const WEVU_EXPORT_ALIASES = [["defineComponent", "__wevuDefineComponent"], ["createWevuComponent", "__wevuCreateWevuComponent"]];
|
|
17902
|
-
const
|
|
17903
|
-
|
|
17903
|
+
const WEVU_SYNTHETIC_SINGLE_PAGE_HOOK_EXPORTS = [
|
|
17904
|
+
"onAddToFavorites",
|
|
17905
|
+
"onSaveExitState",
|
|
17906
|
+
"onShareAppMessage",
|
|
17907
|
+
"onShareTimeline"
|
|
17908
|
+
];
|
|
17909
|
+
const WEVU_INTERNAL_REACTIVITY_EXPORTS = [
|
|
17910
|
+
"addMutationRecorder",
|
|
17911
|
+
"batch",
|
|
17912
|
+
"computed",
|
|
17913
|
+
"customRef",
|
|
17914
|
+
"effect",
|
|
17915
|
+
"effectScope",
|
|
17916
|
+
"endBatch",
|
|
17917
|
+
"getCurrentScope",
|
|
17918
|
+
"getDeepWatchStrategy",
|
|
17919
|
+
"getReactiveVersion",
|
|
17920
|
+
"isProxy",
|
|
17921
|
+
"isRaw",
|
|
17922
|
+
"isReactive",
|
|
17923
|
+
"isReadonly",
|
|
17924
|
+
"isRef",
|
|
17925
|
+
"isShallowReactive",
|
|
17926
|
+
"isShallowRef",
|
|
17927
|
+
"markRaw",
|
|
17928
|
+
"nextTick",
|
|
17929
|
+
"onScopeDispose",
|
|
17930
|
+
"prelinkReactiveTree",
|
|
17931
|
+
"reactive",
|
|
17932
|
+
"readonly",
|
|
17933
|
+
"ref",
|
|
17934
|
+
"removeMutationRecorder",
|
|
17935
|
+
"setDeepWatchStrategy",
|
|
17936
|
+
"shallowReactive",
|
|
17937
|
+
"shallowReadonly",
|
|
17938
|
+
"shallowRef",
|
|
17939
|
+
"startBatch",
|
|
17940
|
+
"stop",
|
|
17941
|
+
"toRaw",
|
|
17942
|
+
"toRef",
|
|
17943
|
+
"toRefs",
|
|
17944
|
+
"toValue",
|
|
17945
|
+
"touchReactive",
|
|
17946
|
+
"traverse",
|
|
17947
|
+
"triggerRef",
|
|
17948
|
+
"unref",
|
|
17949
|
+
"watch",
|
|
17950
|
+
"watchEffect",
|
|
17951
|
+
"watchPostEffect",
|
|
17952
|
+
"watchSyncEffect"
|
|
17953
|
+
];
|
|
17954
|
+
const WEVU_INTERNAL_TEMPLATE_EXPORTS = [
|
|
17955
|
+
"normalizeClass",
|
|
17956
|
+
"normalizeStyle",
|
|
17957
|
+
"resolvePropValue"
|
|
17958
|
+
];
|
|
17959
|
+
const WEVU_INTERNAL_RUNTIME_EXPORTS = [
|
|
17960
|
+
"callHookList",
|
|
17961
|
+
"callHookReturn",
|
|
17962
|
+
"createApp",
|
|
17963
|
+
"createWevuComponent",
|
|
17964
|
+
"createWevuScopedSlotComponent",
|
|
17965
|
+
"defineAppSetup",
|
|
17966
|
+
"defineComponent",
|
|
17967
|
+
"getCurrentInstance",
|
|
17968
|
+
"getCurrentPageStackSnapshot",
|
|
17969
|
+
"getCurrentSetupContext",
|
|
17970
|
+
"getNavigationBarMetrics",
|
|
17971
|
+
"hasInjectionContext",
|
|
17972
|
+
"inject",
|
|
17973
|
+
"injectGlobal",
|
|
17974
|
+
"isNoSetData",
|
|
17975
|
+
"markNoSetData",
|
|
17976
|
+
"mergeModels",
|
|
17977
|
+
"mountRuntimeInstance",
|
|
17978
|
+
"onActivated",
|
|
17979
|
+
"onAddToFavorites",
|
|
17980
|
+
"onAttached",
|
|
17981
|
+
"onBeforeMount",
|
|
17982
|
+
"onBeforeUnmount",
|
|
17983
|
+
"onBeforeUpdate",
|
|
17984
|
+
"onDeactivated",
|
|
17985
|
+
"onDetached",
|
|
17986
|
+
"onError",
|
|
17987
|
+
"onErrorCaptured",
|
|
17988
|
+
"onHide",
|
|
17989
|
+
"onLaunch",
|
|
17990
|
+
"onLoad",
|
|
17991
|
+
"onMemoryWarning",
|
|
17992
|
+
"onMounted",
|
|
17993
|
+
"onMoved",
|
|
17994
|
+
"onPageNotFound",
|
|
17995
|
+
"onPageScroll",
|
|
17996
|
+
"onPullDownRefresh",
|
|
17997
|
+
"onReachBottom",
|
|
17998
|
+
"onReady",
|
|
17999
|
+
"onResize",
|
|
18000
|
+
"onRouteDone",
|
|
18001
|
+
"onSaveExitState",
|
|
18002
|
+
"onServerPrefetch",
|
|
18003
|
+
"onShareAppMessage",
|
|
18004
|
+
"onShareTimeline",
|
|
18005
|
+
"onShow",
|
|
18006
|
+
"onTabItemTap",
|
|
18007
|
+
"onThemeChange",
|
|
18008
|
+
"onUnhandledRejection",
|
|
18009
|
+
"onUnload",
|
|
18010
|
+
"onUnmounted",
|
|
18011
|
+
"onUpdated",
|
|
18012
|
+
"provide",
|
|
18013
|
+
"provideGlobal",
|
|
18014
|
+
"registerApp",
|
|
18015
|
+
"registerComponent",
|
|
18016
|
+
"resetWevuDefaults",
|
|
18017
|
+
"resolveLayoutBridge",
|
|
18018
|
+
"resolveLayoutHost",
|
|
18019
|
+
"resolveRuntimePageLayoutName",
|
|
18020
|
+
"runSetupFunction",
|
|
18021
|
+
"setCurrentInstance",
|
|
18022
|
+
"setCurrentSetupContext",
|
|
18023
|
+
"setGlobalProvidedValue",
|
|
18024
|
+
"setPageLayout",
|
|
18025
|
+
"setRuntimeSetDataVisibility",
|
|
18026
|
+
"setWevuDefaults",
|
|
18027
|
+
"syncRuntimePageLayoutState",
|
|
18028
|
+
"syncRuntimePageLayoutStateFromRuntime",
|
|
18029
|
+
"teardownRuntimeInstance",
|
|
18030
|
+
"use",
|
|
18031
|
+
"useAsyncPullDownRefresh",
|
|
18032
|
+
"useAttrs",
|
|
18033
|
+
"useBindModel",
|
|
18034
|
+
"useBoundingClientRect",
|
|
18035
|
+
"useChangeModel",
|
|
18036
|
+
"useDisposables",
|
|
18037
|
+
"useElementIntersectionObserver",
|
|
18038
|
+
"useIntersectionObserver",
|
|
18039
|
+
"useLayoutBridge",
|
|
18040
|
+
"useLayoutHosts",
|
|
18041
|
+
"useModel",
|
|
18042
|
+
"useNativeInstance",
|
|
18043
|
+
"useNativePageRouter",
|
|
18044
|
+
"useNativeRouter",
|
|
18045
|
+
"useNavigationBarMetrics",
|
|
18046
|
+
"usePageLayout",
|
|
18047
|
+
"usePageScrollThrottle",
|
|
18048
|
+
"usePageStack",
|
|
18049
|
+
"useScrollOffset",
|
|
18050
|
+
"useSelectorFields",
|
|
18051
|
+
"useSelectorQuery",
|
|
18052
|
+
"useSlots",
|
|
18053
|
+
"useTemplateRef",
|
|
18054
|
+
"useUpdatePerformanceListener",
|
|
18055
|
+
"version",
|
|
18056
|
+
"waitForLayoutHost"
|
|
18057
|
+
];
|
|
17904
18058
|
const WEVU_RUNTIME_MODULE_IDS = [
|
|
17905
18059
|
"wevu",
|
|
17906
18060
|
"wevu/router",
|
|
@@ -17931,20 +18085,12 @@ const WEVU_RUNTIME_MODULE_EXPORT_MARKERS = {
|
|
|
17931
18085
|
"wevu/fetch": ["createFetch", "useFetch"],
|
|
17932
18086
|
"wevu/web-apis": ["installWebApis", "createWebApis"],
|
|
17933
18087
|
"wevu/internal-runtime": WEVU_INTERNAL_RUNTIME_EXPORTS,
|
|
17934
|
-
"wevu/internal-reactivity":
|
|
17935
|
-
|
|
17936
|
-
"reactive",
|
|
17937
|
-
"computed",
|
|
17938
|
-
"watch",
|
|
17939
|
-
"watchEffect",
|
|
17940
|
-
"nextTick"
|
|
17941
|
-
],
|
|
17942
|
-
"wevu/internal-template": [
|
|
17943
|
-
"normalizeClass",
|
|
17944
|
-
"normalizeStyle",
|
|
17945
|
-
"resolvePropValue"
|
|
17946
|
-
]
|
|
18088
|
+
"wevu/internal-reactivity": WEVU_INTERNAL_REACTIVITY_EXPORTS,
|
|
18089
|
+
"wevu/internal-template": WEVU_INTERNAL_TEMPLATE_EXPORTS
|
|
17947
18090
|
};
|
|
18091
|
+
const WEVU_INTERNAL_REACTIVITY_EXPORT_SET = new Set(WEVU_INTERNAL_REACTIVITY_EXPORTS);
|
|
18092
|
+
const WEVU_INTERNAL_TEMPLATE_EXPORT_SET = new Set(WEVU_INTERNAL_TEMPLATE_EXPORTS);
|
|
18093
|
+
const WEVU_INTERNAL_RUNTIME_EXPORT_SET = new Set(WEVU_INTERNAL_RUNTIME_EXPORTS);
|
|
17948
18094
|
const JS_IDENTIFIER_RE = /^[A-Z_$][\w$]*$/i;
|
|
17949
18095
|
function filterPluginBundleOutputs(bundle, configService) {
|
|
17950
18096
|
if (configService.pluginOnly) return;
|
|
@@ -18115,6 +18261,7 @@ function rememberWevuRuntimeChunk(moduleId, chunk, options) {
|
|
|
18115
18261
|
function rememberCurrentWevuRuntimeChunks(bundle, options) {
|
|
18116
18262
|
const rememberedFileNames = /* @__PURE__ */ new Set();
|
|
18117
18263
|
for (const moduleId of WEVU_RUNTIME_MODULE_IDS) {
|
|
18264
|
+
if (moduleId === "wevu") continue;
|
|
18118
18265
|
const chunk = resolveWevuRuntimeChunkByModuleId(bundle, moduleId) ?? resolveWevuInternalChunkByExportMarkers(bundle, WEVU_RUNTIME_MODULE_EXPORT_MARKERS[moduleId], rememberedFileNames);
|
|
18119
18266
|
rememberWevuRuntimeChunk(moduleId, chunk, options);
|
|
18120
18267
|
if (chunk?.fileName) rememberedFileNames.add(chunk.fileName);
|
|
@@ -18138,6 +18285,61 @@ function formatNamedRequireBindings(bindings) {
|
|
|
18138
18285
|
return importedName === localName ? importedName : `${importedName}: ${localName}`;
|
|
18139
18286
|
}).join(", ");
|
|
18140
18287
|
}
|
|
18288
|
+
function resolveRootWevuInternalModuleId(importedName) {
|
|
18289
|
+
if (WEVU_INTERNAL_REACTIVITY_EXPORT_SET.has(importedName)) return "wevu/internal-reactivity";
|
|
18290
|
+
if (WEVU_INTERNAL_TEMPLATE_EXPORT_SET.has(importedName)) return "wevu/internal-template";
|
|
18291
|
+
if (WEVU_INTERNAL_RUNTIME_EXPORT_SET.has(importedName)) return "wevu/internal-runtime";
|
|
18292
|
+
}
|
|
18293
|
+
function resolveWevuRuntimeChunkForModuleId(bundle, moduleId, importedNames) {
|
|
18294
|
+
return resolveWevuRuntimeChunkByModuleId(bundle, moduleId) ?? resolveWevuInternalChunk(bundle, importedNames);
|
|
18295
|
+
}
|
|
18296
|
+
function resolveRememberedWevuRuntimeFileName(moduleId, importedNames, options) {
|
|
18297
|
+
const names = [...importedNames];
|
|
18298
|
+
const canUseLegacyRuntimeFileName = moduleId === "wevu/internal-runtime" && names.every((importedName) => WEVU_INTERNAL_RUNTIME_EXPORT_SET.has(importedName));
|
|
18299
|
+
return options.runtimeFileNames?.get(moduleId) ?? (canUseLegacyRuntimeFileName ? options.runtimeFileName : void 0);
|
|
18300
|
+
}
|
|
18301
|
+
function formatWevuRuntimeRequire(fileName, runtimeFileName, bindings) {
|
|
18302
|
+
const specifier = normalizeRelativeRequireSpecifier(fileName, runtimeFileName);
|
|
18303
|
+
return `const { ${formatNamedRequireBindings(bindings)} } = require(${JSON.stringify(specifier)});`;
|
|
18304
|
+
}
|
|
18305
|
+
function rewriteRootWevuImport(bundle, fileName, full, bindings, options, requiredRuntimeFileNames) {
|
|
18306
|
+
const groupedBindings = /* @__PURE__ */ new Map();
|
|
18307
|
+
const remainingBindings = [];
|
|
18308
|
+
for (const binding of bindings) {
|
|
18309
|
+
const moduleId = resolveRootWevuInternalModuleId(binding.importedName);
|
|
18310
|
+
if (!moduleId) {
|
|
18311
|
+
remainingBindings.push(binding);
|
|
18312
|
+
continue;
|
|
18313
|
+
}
|
|
18314
|
+
const group = groupedBindings.get(moduleId) ?? [];
|
|
18315
|
+
group.push(binding);
|
|
18316
|
+
groupedBindings.set(moduleId, group);
|
|
18317
|
+
}
|
|
18318
|
+
if (!groupedBindings.size) return {
|
|
18319
|
+
code: full,
|
|
18320
|
+
changed: false
|
|
18321
|
+
};
|
|
18322
|
+
const statements = [];
|
|
18323
|
+
for (const [moduleId, moduleBindings] of groupedBindings) {
|
|
18324
|
+
const importedNames = moduleBindings.map((binding) => binding.importedName);
|
|
18325
|
+
const runtimeChunk = resolveWevuRuntimeChunkForModuleId(bundle, moduleId, importedNames);
|
|
18326
|
+
const runtimeFileName = runtimeChunk?.fileName ?? resolveRememberedWevuRuntimeFileName(moduleId, importedNames, options);
|
|
18327
|
+
if (!runtimeFileName) return {
|
|
18328
|
+
code: full,
|
|
18329
|
+
changed: false
|
|
18330
|
+
};
|
|
18331
|
+
rememberWevuRuntimeChunk(moduleId, runtimeChunk, options);
|
|
18332
|
+
requiredRuntimeFileNames.add(runtimeFileName);
|
|
18333
|
+
statements.push(formatWevuRuntimeRequire(fileName, runtimeFileName, moduleBindings));
|
|
18334
|
+
}
|
|
18335
|
+
if (remainingBindings.length) statements.push(`import { ${remainingBindings.map(({ importedName, localName }) => {
|
|
18336
|
+
return importedName === localName ? importedName : `${importedName} as ${localName}`;
|
|
18337
|
+
}).join(", ")} } from "wevu";`);
|
|
18338
|
+
return {
|
|
18339
|
+
code: statements.join("\n"),
|
|
18340
|
+
changed: true
|
|
18341
|
+
};
|
|
18342
|
+
}
|
|
18141
18343
|
function rewriteWevuInternalRuntimeImports(bundle, options = {}) {
|
|
18142
18344
|
const importRe = /\bimport\s*\{([^}]*)\}\s*from\s*["'](wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?)["'];?/g;
|
|
18143
18345
|
const requireRe = /\brequire\(\s*(`wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?`|'wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?'|"wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?")\s*\)/g;
|
|
@@ -18156,10 +18358,14 @@ function rewriteWevuInternalRuntimeImports(bundle, options = {}) {
|
|
|
18156
18358
|
rewritten = rewritten.replace(importRe, (full, importClause, source) => {
|
|
18157
18359
|
const bindings = parseNamedImportBindings(importClause);
|
|
18158
18360
|
const importedNames = bindings.map((binding) => binding.importedName);
|
|
18159
|
-
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18361
|
+
if (source === "wevu") {
|
|
18362
|
+
const result = rewriteRootWevuImport(bundle, fileName, full, bindings, options, requiredRuntimeFileNames);
|
|
18363
|
+
changed ||= result.changed;
|
|
18364
|
+
return result.code;
|
|
18365
|
+
}
|
|
18366
|
+
const resolvedInternalModuleId = source;
|
|
18367
|
+
const runtimeChunk = resolveWevuRuntimeChunkForModuleId(bundle, resolvedInternalModuleId, importedNames);
|
|
18368
|
+
const rememberedRuntimeFileName = resolveRememberedWevuRuntimeFileName(resolvedInternalModuleId, importedNames, options);
|
|
18163
18369
|
const runtimeFileName = runtimeChunk?.fileName ?? rememberedRuntimeFileName;
|
|
18164
18370
|
if (!runtimeFileName) return full;
|
|
18165
18371
|
rememberWevuRuntimeChunk(resolvedInternalModuleId, runtimeChunk, options);
|
|
@@ -18282,6 +18488,56 @@ function appendWevuRuntimeExports(chunk, aliases, importedMembers) {
|
|
|
18282
18488
|
}
|
|
18283
18489
|
if (lines.length) chunk.code = `${chunk.code}\n${lines.join("\n")}`;
|
|
18284
18490
|
}
|
|
18491
|
+
function formatSyntheticSinglePageHookExport(exportName) {
|
|
18492
|
+
return [
|
|
18493
|
+
`function ${exportName}(handler) {`,
|
|
18494
|
+
`\tconst instance = require_weapp_vendors_wevu_base.assertInSetup(${JSON.stringify(exportName)});`,
|
|
18495
|
+
`\trequire_weapp_vendors_wevu_base.pushHook(instance, ${JSON.stringify(exportName)}, handler, { single: true });`,
|
|
18496
|
+
`}`,
|
|
18497
|
+
`Object.defineProperty(exports, ${JSON.stringify(exportName)}, { enumerable: true, get: function() { return ${exportName}; } });`
|
|
18498
|
+
].join("\n");
|
|
18499
|
+
}
|
|
18500
|
+
function appendSyntheticWevuHookExports(chunk, importedMembers) {
|
|
18501
|
+
if (!chunk.code.includes("require_weapp_vendors_wevu_base")) return;
|
|
18502
|
+
const existingExports = collectExistingExportNames(chunk.code);
|
|
18503
|
+
const lines = [];
|
|
18504
|
+
for (const exportName of WEVU_SYNTHETIC_SINGLE_PAGE_HOOK_EXPORTS) {
|
|
18505
|
+
if (!importedMembers.has(exportName) || existingExports.has(exportName)) continue;
|
|
18506
|
+
lines.push(formatSyntheticSinglePageHookExport(exportName));
|
|
18507
|
+
existingExports.add(exportName);
|
|
18508
|
+
}
|
|
18509
|
+
if (lines.length) chunk.code = `${chunk.code}\n${lines.join("\n")}`;
|
|
18510
|
+
}
|
|
18511
|
+
function resolveWevuBaseChunk(bundle) {
|
|
18512
|
+
return resolveWevuInternalChunk(bundle, ["assertInSetup", "pushHook"]);
|
|
18513
|
+
}
|
|
18514
|
+
function formatSyntheticSinglePageHookFallback(hookName, receiverAccess, baseRequireSpecifier) {
|
|
18515
|
+
const baseRequire = `require(${JSON.stringify(baseRequireSpecifier)})`;
|
|
18516
|
+
return `(${receiverAccess} || function(handler) { const instance = ${baseRequire}.assertInSetup(${JSON.stringify(hookName)}); ${baseRequire}.pushHook(instance, ${JSON.stringify(hookName)}, handler, { single: true }); })(`;
|
|
18517
|
+
}
|
|
18518
|
+
function rewriteSyntheticWevuHookAccess(chunk, wevuChunkFileName, baseChunkFileName, importedMembers) {
|
|
18519
|
+
const hookNames = WEVU_SYNTHETIC_SINGLE_PAGE_HOOK_EXPORTS.filter((name) => importedMembers.has(name));
|
|
18520
|
+
if (!hookNames.length) return;
|
|
18521
|
+
const baseRequireSpecifier = normalizeRelativeRequireSpecifier(chunk.fileName, baseChunkFileName);
|
|
18522
|
+
let nextCode = chunk.code;
|
|
18523
|
+
const localRequireRe = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*require\((`[^`]+`|'[^']+'|"[^"]+")\);?/g;
|
|
18524
|
+
const runtimeRefs = /* @__PURE__ */ new Set();
|
|
18525
|
+
for (const match of nextCode.matchAll(localRequireRe)) if (resolveRequireTarget(chunk.fileName, stripQuotes(match[2])) === wevuChunkFileName) runtimeRefs.add(match[1]);
|
|
18526
|
+
for (const hookName of hookNames) {
|
|
18527
|
+
for (const ref of runtimeRefs) {
|
|
18528
|
+
const memberRe = new RegExp(`\\b${escapeRegExp(ref)}\\.${hookName}\\s*\\(`, "g");
|
|
18529
|
+
nextCode = nextCode.replace(memberRe, () => {
|
|
18530
|
+
return formatSyntheticSinglePageHookFallback(hookName, `${ref}.${hookName}`, baseRequireSpecifier);
|
|
18531
|
+
});
|
|
18532
|
+
}
|
|
18533
|
+
nextCode = nextCode.replace(/require\((`[^`]+`|'[^']+'|"[^"]+")\)\.([A-Za-z_$][\w$]*)\s*\(/g, (full, rawSpecifier, property) => {
|
|
18534
|
+
if (property !== hookName) return full;
|
|
18535
|
+
if (resolveRequireTarget(chunk.fileName, stripQuotes(rawSpecifier)) !== wevuChunkFileName) return full;
|
|
18536
|
+
return formatSyntheticSinglePageHookFallback(hookName, `require(${rawSpecifier}).${hookName}`, baseRequireSpecifier);
|
|
18537
|
+
});
|
|
18538
|
+
}
|
|
18539
|
+
chunk.code = nextCode;
|
|
18540
|
+
}
|
|
18285
18541
|
function rewriteStableWevuRuntimeAccess(chunk, wevuChunkFileName, aliases) {
|
|
18286
18542
|
if (!aliases.size) return;
|
|
18287
18543
|
let nextCode = chunk.code;
|
|
@@ -18306,15 +18562,29 @@ function rewriteStableWevuRuntimeAccess(chunk, wevuChunkFileName, aliases) {
|
|
|
18306
18562
|
chunk.code = nextCode;
|
|
18307
18563
|
}
|
|
18308
18564
|
function stabilizeWevuRuntimeChunkAccess(bundle) {
|
|
18309
|
-
const
|
|
18310
|
-
return output?.type === "chunk" && WEVU_SRC_CHUNK_RE.test(output.fileName);
|
|
18565
|
+
const wevuChunks = Object.values(bundle).filter((output) => {
|
|
18566
|
+
return output?.type === "chunk" && (WEVU_SRC_CHUNK_RE.test(output.fileName) || WEVU_VENDOR_RUNTIME_CHUNK_RE.test(output.fileName));
|
|
18311
18567
|
});
|
|
18312
|
-
if (!
|
|
18313
|
-
const
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18568
|
+
if (!wevuChunks.length) return;
|
|
18569
|
+
const baseChunk = resolveWevuBaseChunk(bundle);
|
|
18570
|
+
for (const wevuChunk of wevuChunks) {
|
|
18571
|
+
const aliases = resolveWevuExportAliasMap(wevuChunk);
|
|
18572
|
+
const importedMembers = collectImportedWevuRuntimeMembers(bundle, wevuChunk.fileName);
|
|
18573
|
+
appendWevuRuntimeExports(wevuChunk, aliases, importedMembers);
|
|
18574
|
+
appendSyntheticWevuHookExports(wevuChunk, importedMembers);
|
|
18575
|
+
for (const output of Object.values(bundle)) {
|
|
18576
|
+
if (!output || output.type !== "chunk" || typeof output.code !== "string" || output.fileName === wevuChunk.fileName) continue;
|
|
18577
|
+
const chunk = output;
|
|
18578
|
+
rewriteStableWevuRuntimeAccess(chunk, wevuChunk.fileName, aliases);
|
|
18579
|
+
if (baseChunk?.fileName) {
|
|
18580
|
+
rewriteSyntheticWevuHookAccess(chunk, wevuChunk.fileName, baseChunk.fileName, importedMembers);
|
|
18581
|
+
if (chunk.code.includes(normalizeRelativeRequireSpecifier(chunk.fileName, baseChunk.fileName))) {
|
|
18582
|
+
const nextImports = new Set(Array.isArray(chunk.imports) ? chunk.imports : []);
|
|
18583
|
+
nextImports.add(baseChunk.fileName);
|
|
18584
|
+
chunk.imports = [...nextImports];
|
|
18585
|
+
}
|
|
18586
|
+
}
|
|
18587
|
+
}
|
|
18318
18588
|
}
|
|
18319
18589
|
}
|
|
18320
18590
|
//#endregion
|
|
@@ -18374,26 +18644,73 @@ function collectAffectedSharedChunks(state, startId) {
|
|
|
18374
18644
|
for (const chunkId of chunkIds) affected.add(chunkId);
|
|
18375
18645
|
return affected;
|
|
18376
18646
|
}
|
|
18377
|
-
function refreshModuleGraph(pluginCtx, state) {
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18647
|
+
function refreshModuleGraph(pluginCtx, state, bundle, options) {
|
|
18648
|
+
const mode = options?.mode ?? "replace";
|
|
18649
|
+
if (mode === "replace") {
|
|
18650
|
+
state.moduleImporters.clear();
|
|
18651
|
+
state.entryModuleIds.clear();
|
|
18652
|
+
}
|
|
18653
|
+
const addModuleImporter = (moduleId, importerId) => {
|
|
18654
|
+
const normalizedModuleId = normalizeFsResolvedId(moduleId);
|
|
18655
|
+
const normalizedImporterId = normalizeFsResolvedId(importerId);
|
|
18656
|
+
if (normalizedModuleId === normalizedImporterId || isSkippableResolvedId(normalizedModuleId) || isSkippableResolvedId(normalizedImporterId)) return;
|
|
18657
|
+
const importers = state.moduleImporters.get(normalizedModuleId) ?? /* @__PURE__ */ new Set();
|
|
18658
|
+
importers.add(normalizedImporterId);
|
|
18659
|
+
state.moduleImporters.set(normalizedModuleId, importers);
|
|
18660
|
+
};
|
|
18661
|
+
const removeEntryImporter = (entryId) => {
|
|
18662
|
+
const normalizedEntryId = normalizeFsResolvedId(entryId);
|
|
18663
|
+
for (const [moduleId, importers] of state.moduleImporters) {
|
|
18664
|
+
importers.delete(normalizedEntryId);
|
|
18665
|
+
if (!importers.size) state.moduleImporters.delete(moduleId);
|
|
18666
|
+
}
|
|
18667
|
+
};
|
|
18668
|
+
const collectChunkModuleIds = (chunk) => {
|
|
18669
|
+
const moduleIds = /* @__PURE__ */ new Set();
|
|
18670
|
+
if (Array.isArray(chunk.moduleIds)) for (const moduleId of chunk.moduleIds) moduleIds.add(moduleId);
|
|
18671
|
+
for (const moduleId of Object.keys(chunk.modules ?? {})) moduleIds.add(moduleId);
|
|
18672
|
+
return moduleIds;
|
|
18673
|
+
};
|
|
18674
|
+
const collectChunkEntryIds = (chunk, moduleIds) => {
|
|
18675
|
+
const entryIds = /* @__PURE__ */ new Set();
|
|
18676
|
+
const addEntryIfTracked = (rawId) => {
|
|
18677
|
+
if (!rawId) return;
|
|
18678
|
+
const entryId = normalizeFsResolvedId(rawId);
|
|
18679
|
+
if (!isSkippableResolvedId(entryId) && state.resolvedEntryMap.has(entryId)) entryIds.add(entryId);
|
|
18680
|
+
};
|
|
18681
|
+
addEntryIfTracked(chunk.facadeModuleId);
|
|
18682
|
+
for (const moduleId of moduleIds) addEntryIfTracked(moduleId);
|
|
18683
|
+
return entryIds;
|
|
18684
|
+
};
|
|
18685
|
+
if (typeof pluginCtx.getModuleIds === "function" && typeof pluginCtx.getModuleInfo === "function") for (const rawId of pluginCtx.getModuleIds()) {
|
|
18382
18686
|
const normalizedId = normalizeFsResolvedId(rawId);
|
|
18383
18687
|
if (isSkippableResolvedId(normalizedId)) continue;
|
|
18384
18688
|
const info = pluginCtx.getModuleInfo(rawId);
|
|
18385
18689
|
if (!info) continue;
|
|
18386
18690
|
if (info.isEntry) state.entryModuleIds.add(normalizedId);
|
|
18387
|
-
const importers = /* @__PURE__ */ new Set();
|
|
18388
18691
|
const importerIds = [];
|
|
18389
18692
|
if (Array.isArray(info.importers)) importerIds.push(...info.importers);
|
|
18390
18693
|
if (Array.isArray(info.dynamicImporters)) importerIds.push(...info.dynamicImporters);
|
|
18391
|
-
for (const importer of importerIds)
|
|
18392
|
-
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
18396
|
-
if (
|
|
18694
|
+
for (const importer of importerIds) addModuleImporter(normalizedId, importer);
|
|
18695
|
+
}
|
|
18696
|
+
if (!bundle) return;
|
|
18697
|
+
const chunkRecords = [];
|
|
18698
|
+
for (const output of Object.values(bundle)) {
|
|
18699
|
+
if (output?.type !== "chunk") continue;
|
|
18700
|
+
const chunk = output;
|
|
18701
|
+
const moduleIds = collectChunkModuleIds(chunk);
|
|
18702
|
+
const entryIds = collectChunkEntryIds(chunk, moduleIds);
|
|
18703
|
+
if (!entryIds.size) continue;
|
|
18704
|
+
chunkRecords.push({
|
|
18705
|
+
chunk,
|
|
18706
|
+
entryIds,
|
|
18707
|
+
moduleIds
|
|
18708
|
+
});
|
|
18709
|
+
}
|
|
18710
|
+
if (mode === "merge") for (const { entryIds } of chunkRecords) for (const entryId of entryIds) removeEntryImporter(entryId);
|
|
18711
|
+
for (const { entryIds, moduleIds } of chunkRecords) for (const entryId of entryIds) {
|
|
18712
|
+
state.entryModuleIds.add(entryId);
|
|
18713
|
+
for (const moduleId of moduleIds) addModuleImporter(moduleId, entryId);
|
|
18397
18714
|
}
|
|
18398
18715
|
}
|
|
18399
18716
|
function appendSharedChunkImporters(bundle, state, onlyEntryIds, previousImporters, previousDependencies) {
|
|
@@ -19565,6 +19882,7 @@ function pruneUnchangedDevHmrOutputs(ctx, bundle, rewriteOptions) {
|
|
|
19565
19882
|
const isHmrBuild = ctx.runtimeState?.build?.hmr?.profile?.event !== void 0;
|
|
19566
19883
|
const emittedChunkFileNames = ctx.runtimeState?.build?.hmr?.lastEmittedChunkFileNames;
|
|
19567
19884
|
rewriteWevuInternalRuntimeImports(bundle, rewriteOptions);
|
|
19885
|
+
stabilizeWevuRuntimeChunkAccess(bundle);
|
|
19568
19886
|
pruneUneventedDevHmrChunks(ctx, bundle);
|
|
19569
19887
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
19570
19888
|
const source = outputSourceToString(output);
|
|
@@ -19601,6 +19919,7 @@ function createOutputFinalizerPlugin(ctx) {
|
|
|
19601
19919
|
enforce: "post",
|
|
19602
19920
|
generateBundle(_options, bundle) {
|
|
19603
19921
|
rewriteWevuInternalRuntimeImports(bundle, wevuRuntimeRewriteOptions);
|
|
19922
|
+
stabilizeWevuRuntimeChunkAccess(bundle);
|
|
19604
19923
|
normalizePreprocessorStyleAssets(bundle, ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
|
|
19605
19924
|
pruneUnchangedDevHmrOutputs(ctx, bundle, wevuRuntimeRewriteOptions);
|
|
19606
19925
|
}
|
|
@@ -20843,7 +21162,6 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
20843
21162
|
state.hmrState.affectedSharedChunkIds?.clear();
|
|
20844
21163
|
if (assetOnlyDevHmrBundle) {
|
|
20845
21164
|
normalizePreprocessorStyleAssets(rolldownBundle, state.ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
|
|
20846
|
-
refreshModuleGraph(this, state);
|
|
20847
21165
|
return;
|
|
20848
21166
|
}
|
|
20849
21167
|
function matchSubPackage(filePath) {
|
|
@@ -21005,7 +21323,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
21005
21323
|
stabilizeWevuRuntimeChunkAccess(rolldownBundle);
|
|
21006
21324
|
syncChunkImportsFromRequireCalls(rolldownBundle);
|
|
21007
21325
|
normalizePreprocessorStyleAssets(rolldownBundle, state.ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
|
|
21008
|
-
refreshModuleGraph(this, state);
|
|
21326
|
+
refreshModuleGraph(this, state, rolldownBundle, { mode: state.ctx.configService.isDev && state.hmrState.hasBuiltOnce ? "merge" : "replace" });
|
|
21009
21327
|
if (configService.weappViteConfig?.debug?.watchFiles) {
|
|
21010
21328
|
const watcherService = ctx.watcherService;
|
|
21011
21329
|
const watcherRoot = subPackageMeta?.subPackage.root ?? "/";
|
|
@@ -21947,6 +22265,7 @@ function isCurrentSubPackageFile(relativeSrc, subPackageMeta) {
|
|
|
21947
22265
|
}
|
|
21948
22266
|
async function normalizeWatchEvent(id, event, options) {
|
|
21949
22267
|
if (event === "create" && (options.loadedEntrySet.has(id) || options.resolvedEntryMap.has(id)) && await fs.pathExists(id)) return "update";
|
|
22268
|
+
if (event === "create" && (options.moduleImporters?.has(id) || options.sharedChunkSourceModuleIds?.has(id)) && await fs.pathExists(id)) return "update";
|
|
21950
22269
|
if (event === "create" && await fs.pathExists(id)) {
|
|
21951
22270
|
const ext = path.extname(id);
|
|
21952
22271
|
if (ext) {
|
|
@@ -22263,7 +22582,9 @@ function createWatchChangeHook(state) {
|
|
|
22263
22582
|
const event = await normalizeWatchEvent(normalizedId, change.event, {
|
|
22264
22583
|
emittedJsonPaths: new Set([...state.jsonEmitFilesMap.values()].map((record) => record.entry.jsonPath ? normalizeFsResolvedId(record.entry.jsonPath) : "").filter(Boolean)),
|
|
22265
22584
|
loadedEntrySet: state.loadedEntrySet,
|
|
22266
|
-
|
|
22585
|
+
moduleImporters: state.moduleImporters,
|
|
22586
|
+
resolvedEntryMap: state.resolvedEntryMap,
|
|
22587
|
+
sharedChunkSourceModuleIds: state.ctx.runtimeState.build.hmr.sharedChunkSourceModuleIds
|
|
22267
22588
|
});
|
|
22268
22589
|
state.ctx.runtimeState.build.hmr.profile = {
|
|
22269
22590
|
...state.ctx.runtimeState.build.hmr.profile,
|
|
@@ -26151,7 +26472,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
26151
26472
|
const vueAppPath = await findVueEntry(appBasename);
|
|
26152
26473
|
let configFromVue;
|
|
26153
26474
|
if (!appConfigFile && vueAppPath) {
|
|
26154
|
-
const { extractConfigFromVue } = await import("./file-
|
|
26475
|
+
const { extractConfigFromVue } = await import("./file-8RU-zw8X.mjs");
|
|
26155
26476
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
26156
26477
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
26157
26478
|
}
|
|
@@ -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-CcEF8k1Z.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-BL8Dhhk6.mjs";
|
|
2
2
|
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost--CaeyWpA.mjs";
|
|
3
3
|
import { t as defineConfig } from "./config-DRGcCi3h.mjs";
|
|
4
|
-
import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-
|
|
4
|
+
import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-DooWF5Wk.mjs";
|
|
5
5
|
import { a as resolveLayoutHost, c as createWevuComponent, i as registerLayoutHosts, n as defineProps, o as unregisterLayoutHosts, r as setPageLayout, s as waitForLayoutHost, t as defineEmits } from "./runtime-CRoKWQZn.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, registerLayoutHosts, resolveLayoutHost, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.17.
|
|
4
|
+
"version": "6.17.7",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"@weapp-core/logger": "3.1.1",
|
|
125
125
|
"@weapp-core/schematics": "6.0.4",
|
|
126
126
|
"@weapp-core/shared": "3.0.5",
|
|
127
|
-
"@weapp-vite/ast": "6.17.
|
|
127
|
+
"@weapp-vite/ast": "6.17.7",
|
|
128
128
|
"@weapp-vite/mcp": "1.4.6",
|
|
129
129
|
"@weapp-vite/miniprogram-automator": "1.2.5",
|
|
130
130
|
"@weapp-vite/volar": "2.1.0",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"rolldown-require": "2.0.19",
|
|
135
135
|
"vite-plugin-performance": "2.0.1",
|
|
136
136
|
"weapp-ide-cli": "5.4.10",
|
|
137
|
-
"wevu": "6.17.
|
|
137
|
+
"wevu": "6.17.7"
|
|
138
138
|
},
|
|
139
139
|
"publishConfig": {
|
|
140
140
|
"access": "public",
|
package/dist/file-XBQU6P82.mjs
DELETED