weapp-vite 6.18.2 → 6.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-DC-ADEdC.mjs";
1
+ import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-giYv1R-U.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-DC-ADEdC.mjs";
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-giYv1R-U.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
3
- import { h as VERSION } from "./file-DLA_2D0c.mjs";
3
+ import { h as VERSION } from "./file-CWu9BDPF.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";
@@ -4496,7 +4496,7 @@ function resolveRunnableHotkeyDefinition(input) {
4496
4496
  }
4497
4497
  //#endregion
4498
4498
  //#region package.json
4499
- var version = "6.18.2";
4499
+ var version = "6.18.4";
4500
4500
  //#endregion
4501
4501
  //#region src/cli/devHotkeys/format.ts
4502
4502
  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-DLA_2D0c.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-CWu9BDPF.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";
@@ -14,7 +14,7 @@ import fs$1, { existsSync, readFileSync } from "node:fs";
14
14
  import { compileScript, parse } from "vue/compiler-sfc";
15
15
  import { BABEL_TS_MODULE_PARSER_OPTIONS, generate, getVisitorKeys, parse as parse$2, parseJsLike, traverse } from "@weapp-vite/ast/babel";
16
16
  import pm from "picomatch";
17
- import { VUE_COMPONENT_TAG_RE, WE_VU_INTERNAL_REACTIVITY_MODULE_ID, WE_VU_INTERNAL_RUNTIME_MODULE_ID, WE_VU_INTERNAL_TEMPLATE_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, collectVueTemplateTags, compileJsxFile, compileVueFile, compileVueStyleToWxss, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, pathExists, readAndParseSfc, readFile as readFile$1, resolveClassStyleWxsLocation, stripJsonMacroCallsFromCode } from "wevu/compiler";
17
+ import { VUE_COMPONENT_TAG_RE, WE_VU_INTERNAL_REACTIVITY_MODULE_ID, WE_VU_INTERNAL_RUNTIME_MODULE_ID, WE_VU_INTERNAL_TEMPLATE_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, collectVueTemplateTags, compileJsxFile, compileVueFile, compileVueStyleToWxss, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, pathExists, readAndParseSfc, readFile as readFile$1, refreshVueFileJsonConfig, resolveClassStyleWxsLocation, stripJsonMacroCallsFromCode } from "wevu/compiler";
18
18
  import process from "node:process";
19
19
  import { parse as parse$1, stringify } from "comment-json";
20
20
  import fs$2, { appendFile, copyFile, mkdir, readFile, readdir, rm } from "node:fs/promises";
@@ -28795,6 +28795,168 @@ function parseUsingComponents(config) {
28795
28795
  }
28796
28796
  }
28797
28797
  //#endregion
28798
+ //#region src/plugins/vue/transform/plugin/transformFile/finalize.ts
28799
+ async function finalizeVueTransform(options) {
28800
+ const { ctx, pluginCtx, filename, source, autoRoutesSignature, result, compilationCache, currentStyleIndependentSignature, previousStyleSignature, dirtyEntryId, dirtyVueEntryIds, isCssImporterDirty, isPage, isApp, sourceMap, styleBlocksCache, styleRefreshTokens, scopedSlotModules, emittedScopedSlotChunks, setAppShell, readAndParseSfc, createReadAndParseSfcOptions, measureStage, measureVueHmrStage, reportTiming } = options;
28801
+ const configService = ctx.configService;
28802
+ let currentStyleBlocks = Array.isArray(result.meta?.styleBlocks) ? result.meta.styleBlocks : styleBlocksCache.get(filename);
28803
+ if (!currentStyleBlocks) currentStyleBlocks = await measureStage("preloadSfcStyles", async () => await loadStyleBlocksForStyleOnlyRefresh({
28804
+ filename,
28805
+ source,
28806
+ styleBlocksCache,
28807
+ readAndParseSfc,
28808
+ createReadAndParseSfcOptions,
28809
+ pluginCtx,
28810
+ configService
28811
+ }));
28812
+ if (currentStyleBlocks) styleBlocksCache.set(filename, currentStyleBlocks);
28813
+ if (configService.isDev && dirtyEntryId) {
28814
+ const currentStyleSignature = createSfcStyleBlocksSignature(currentStyleBlocks);
28815
+ const hmrEventId = ctx.runtimeState.build?.hmr?.profile?.eventId;
28816
+ if (hmrEventId != null && (isCssImporterDirty || currentStyleSignature && currentStyleSignature !== previousStyleSignature)) styleRefreshTokens.set(filename, hmrEventId);
28817
+ else styleRefreshTokens.delete(filename);
28818
+ dirtyVueEntryIds?.delete(dirtyEntryId);
28819
+ }
28820
+ const sfcStyleDependencies = syncVueSfcStyleDependencies(ctx, filename, currentStyleBlocks);
28821
+ for (const dependency of sfcStyleDependencies) addNormalizedWatchFile(pluginCtx, dependency);
28822
+ registerScopedSlotHostGenerics(ctx, result.scopedSlotComponents, parseUsingComponents(result.config));
28823
+ await measureVueHmrStage("finalizeCompiledResult", "vueFinalizeCompiledMs", async () => {
28824
+ await finalizeTransformCompiledResult({
28825
+ ctx,
28826
+ pluginCtx,
28827
+ filename,
28828
+ source,
28829
+ autoRoutesSignature,
28830
+ result,
28831
+ compilationCache,
28832
+ styleIndependentSignature: filename.endsWith(".vue") ? currentStyleIndependentSignature ?? resolveVueSfcStyleIndependentSignature(source, filename) : void 0,
28833
+ setAppShell,
28834
+ configService,
28835
+ isPage,
28836
+ isApp,
28837
+ sourceMap,
28838
+ scopedSlotModules,
28839
+ emittedScopedSlotChunks,
28840
+ addWatchFile: addNormalizedWatchFile,
28841
+ emitScopedSlotChunks
28842
+ });
28843
+ });
28844
+ const returnedCode = await measureVueHmrStage("finalizeCode", "vueFinalizeCodeMs", async () => finalizeTransformEntryCode({
28845
+ result,
28846
+ filename,
28847
+ styleBlocks: result.meta?.styleBlocks ?? styleBlocksCache.get(filename),
28848
+ isPage,
28849
+ isApp,
28850
+ isDev: configService.isDev,
28851
+ sourceMap,
28852
+ hmrStyleToken: configService.isDev ? styleRefreshTokens.get(filename) : void 0
28853
+ }));
28854
+ reportTiming(filename, isPage);
28855
+ return returnedCode;
28856
+ }
28857
+ //#endregion
28858
+ //#region src/plugins/vue/transform/plugin/transformFile/jsonOnly.ts
28859
+ function isVueJsonOnlyDirtyReasonSummary(dirtyReasonSummary) {
28860
+ return Boolean(dirtyReasonSummary?.length && dirtyReasonSummary.every((item) => item.startsWith("entry-json-only:")));
28861
+ }
28862
+ async function tryRefreshJsonOnlyVueCompilation(options) {
28863
+ const { cachedResult, compileOptions, dirtyEntryId, dirtyReasonSummary, filename, isDev, scanDirty, source, autoRoutesSignature, cachedAutoRoutesSignature } = options;
28864
+ if (!isDev || scanDirty || !dirtyEntryId || !cachedResult || !filename.endsWith(".vue") || cachedAutoRoutesSignature !== autoRoutesSignature || !isVueJsonOnlyDirtyReasonSummary(dirtyReasonSummary)) return;
28865
+ const refreshed = await refreshVueFileJsonConfig(source, filename, cachedResult, compileOptions);
28866
+ return refreshed ? normalizeVueTransformResult(refreshed) : void 0;
28867
+ }
28868
+ //#endregion
28869
+ //#region src/plugins/vue/transform/plugin/transformFile/reuse.ts
28870
+ async function tryReuseVueCompilation(options) {
28871
+ const { ctx, pluginCtx, filename, source, cachedCompilation, previousStyleSignature, autoRoutesSignature, dirtyEntryId, dirtyVueEntryIds, isCssImporterDirty, canAttemptStyleOnlyReuse, sourceMap, isApp, styleBlocksCache, styleRefreshTokens, readAndParseSfc, createReadAndParseSfcOptions, measureStage, measureVueHmrStage, reportTiming } = options;
28872
+ const configService = ctx.configService;
28873
+ if (configService.isDev && cachedCompilation && !ctx.runtimeState.scan.isDirty && cachedCompilation.source === source && cachedCompilation.autoRoutesSignature === autoRoutesSignature) {
28874
+ cachedCompilation.refreshToken = 0;
28875
+ const cachedResult = normalizeVueTransformResult(cachedCompilation.result);
28876
+ let cachedStyleBlocks = cachedResult.meta?.styleBlocks ?? styleBlocksCache.get(filename);
28877
+ let canReturnCachedCompilation = true;
28878
+ if (dirtyEntryId && canAttemptStyleOnlyReuse && filename.endsWith(".vue")) {
28879
+ const refreshedStyleBlocks = await measureStage("loadStyleOnlySfcStyles", async () => await loadStyleBlocksForStyleOnlyRefresh({
28880
+ filename,
28881
+ source,
28882
+ styleBlocksCache,
28883
+ force: true,
28884
+ readAndParseSfc,
28885
+ createReadAndParseSfcOptions,
28886
+ pluginCtx,
28887
+ configService
28888
+ }));
28889
+ if (!refreshStyleOnlyVueTransformResult(cachedResult, filename, refreshedStyleBlocks)) {
28890
+ cachedCompilation.styleIndependentSignature = void 0;
28891
+ canReturnCachedCompilation = false;
28892
+ } else {
28893
+ cachedStyleBlocks = refreshedStyleBlocks;
28894
+ cachedCompilation.result = cachedResult;
28895
+ const currentStyleSignature = createSfcStyleBlocksSignature(cachedStyleBlocks);
28896
+ const hmrEventId = ctx.runtimeState.build?.hmr?.profile?.eventId;
28897
+ if (hmrEventId != null && (isCssImporterDirty || currentStyleSignature && currentStyleSignature !== previousStyleSignature)) styleRefreshTokens.set(filename, hmrEventId);
28898
+ else styleRefreshTokens.delete(filename);
28899
+ }
28900
+ }
28901
+ if (!canReturnCachedCompilation) cachedCompilation.refreshToken = 1;
28902
+ else {
28903
+ const returnedCode = await measureVueHmrStage("finalizeCode", "vueFinalizeCodeMs", async () => finalizeTransformEntryCode({
28904
+ result: cachedResult,
28905
+ filename,
28906
+ styleBlocks: cachedStyleBlocks,
28907
+ isPage: cachedCompilation.isPage,
28908
+ isApp,
28909
+ isDev: configService.isDev,
28910
+ sourceMap,
28911
+ hmrStyleToken: styleRefreshTokens.get(filename)
28912
+ }));
28913
+ if (dirtyEntryId) dirtyVueEntryIds?.delete(dirtyEntryId);
28914
+ reportTiming(filename, cachedCompilation.isPage);
28915
+ return { returnedCode };
28916
+ }
28917
+ }
28918
+ const currentStyleIndependentSignature = configService.isDev && dirtyEntryId && canAttemptStyleOnlyReuse && filename.endsWith(".vue") ? resolveVueSfcStyleIndependentSignature(source, filename) : void 0;
28919
+ if (Boolean(configService.isDev && cachedCompilation && dirtyEntryId && canAttemptStyleOnlyReuse && filename.endsWith(".vue") && !ctx.runtimeState.scan.isDirty && cachedCompilation.autoRoutesSignature === autoRoutesSignature && cachedCompilation.styleIndependentSignature && currentStyleIndependentSignature && cachedCompilation.styleIndependentSignature === currentStyleIndependentSignature && cachedCompilation.source !== source) && cachedCompilation) {
28920
+ const cachedResult = normalizeVueTransformResult(cachedCompilation.result);
28921
+ const styleBlocks = await measureStage("loadStyleOnlySfcStyles", async () => await loadStyleBlocksForStyleOnlyRefresh({
28922
+ filename,
28923
+ source,
28924
+ styleBlocksCache,
28925
+ force: true,
28926
+ readAndParseSfc,
28927
+ createReadAndParseSfcOptions,
28928
+ pluginCtx,
28929
+ configService
28930
+ }));
28931
+ if (!refreshStyleOnlyVueTransformResult(cachedResult, filename, styleBlocks)) cachedCompilation.styleIndependentSignature = void 0;
28932
+ else {
28933
+ cachedCompilation.source = source;
28934
+ cachedCompilation.result = cachedResult;
28935
+ cachedCompilation.styleIndependentSignature = currentStyleIndependentSignature;
28936
+ cachedCompilation.refreshToken = 0;
28937
+ const hmrEventId = ctx.runtimeState.build?.hmr?.profile?.eventId;
28938
+ if (hmrEventId != null && (isCssImporterDirty || styleBlocks?.length)) styleRefreshTokens.set(filename, hmrEventId);
28939
+ const returnedCode = await measureVueHmrStage("finalizeCode", "vueFinalizeCodeMs", async () => finalizeTransformEntryCode({
28940
+ result: cachedResult,
28941
+ filename,
28942
+ styleBlocks,
28943
+ isPage: cachedCompilation.isPage,
28944
+ isApp,
28945
+ isDev: configService.isDev,
28946
+ sourceMap,
28947
+ hmrStyleToken: styleRefreshTokens.get(filename)
28948
+ }));
28949
+ if (dirtyEntryId) dirtyVueEntryIds?.delete(dirtyEntryId);
28950
+ reportTiming(filename, cachedCompilation.isPage);
28951
+ return {
28952
+ currentStyleIndependentSignature,
28953
+ returnedCode
28954
+ };
28955
+ }
28956
+ }
28957
+ return { currentStyleIndependentSignature };
28958
+ }
28959
+ //#endregion
28798
28960
  //#region src/plugins/vue/transform/plugin/transformFile.ts
28799
28961
  async function transformVueLikeFile(options) {
28800
28962
  const { ctx, pluginCtx, code, id, compilationCache, setAppShell, pageMatcher, setPageMatcher, scanDirtySynced, setScanDirtySynced, reExportResolutionCache, compileOptionsCache, componentMetaCache, styleBlocksCache, styleRefreshTokens, scopedSlotModules, emittedScopedSlotChunks, classStyleRuntimeWarned, readAndParseSfc, createReadAndParseSfcOptions } = options;
@@ -28853,159 +29015,120 @@ async function transformVueLikeFile(options) {
28853
29015
  const dirtyEntryId = resolveDirtyVueEntryId(dirtyVueEntryIds, filename);
28854
29016
  const isCssImporterDirty = isVueCssImporterDirtyReasonSummary(ctx.runtimeState?.build?.hmr?.profile?.dirtyReasonSummary);
28855
29017
  const canAttemptStyleOnlyReuse = isVueStyleOnlyDirtyReasonSummary(ctx.runtimeState?.build?.hmr?.profile?.dirtyReasonSummary);
28856
- if (configService.isDev && cachedCompilation && !ctx.runtimeState.scan.isDirty && cachedCompilation.source === transformedSource && cachedCompilation.autoRoutesSignature === autoRoutesSignature) {
28857
- cachedCompilation.refreshToken = 0;
28858
- const cachedResult = normalizeVueTransformResult(cachedCompilation.result);
28859
- let cachedStyleBlocks = cachedResult.meta?.styleBlocks ?? styleBlocksCache.get(filename);
28860
- let canReturnCachedCompilation = true;
28861
- if (dirtyEntryId && canAttemptStyleOnlyReuse && filename.endsWith(".vue")) {
28862
- const refreshedStyleBlocks = await measureStage("loadStyleOnlySfcStyles", async () => await loadStyleBlocksForStyleOnlyRefresh({
28863
- filename,
28864
- source: transformedSource,
28865
- styleBlocksCache,
28866
- force: true,
28867
- readAndParseSfc,
28868
- createReadAndParseSfcOptions,
28869
- pluginCtx,
28870
- configService
28871
- }));
28872
- if (!refreshStyleOnlyVueTransformResult(cachedResult, filename, refreshedStyleBlocks)) {
28873
- cachedCompilation.styleIndependentSignature = void 0;
28874
- canReturnCachedCompilation = false;
28875
- } else {
28876
- cachedStyleBlocks = refreshedStyleBlocks;
28877
- cachedCompilation.result = cachedResult;
28878
- const currentStyleSignature = createSfcStyleBlocksSignature(cachedStyleBlocks);
28879
- const hmrEventId = ctx.runtimeState.build?.hmr?.profile?.eventId;
28880
- if (hmrEventId != null && (isCssImporterDirty || currentStyleSignature && currentStyleSignature !== previousStyleSignature)) styleRefreshTokens.set(filename, hmrEventId);
28881
- else styleRefreshTokens.delete(filename);
28882
- }
28883
- }
28884
- if (!canReturnCachedCompilation) cachedCompilation.refreshToken = 1;
28885
- else {
28886
- const returnedCode = await measureVueHmrStage("finalizeCode", "vueFinalizeCodeMs", async () => finalizeTransformEntryCode({
28887
- result: cachedResult,
28888
- filename,
28889
- styleBlocks: cachedStyleBlocks,
28890
- isPage: cachedCompilation.isPage,
28891
- isApp,
28892
- isDev: configService.isDev,
28893
- sourceMap,
28894
- hmrStyleToken: styleRefreshTokens.get(filename)
28895
- }));
28896
- if (dirtyEntryId) dirtyVueEntryIds?.delete(dirtyEntryId);
28897
- reportTiming(filename, cachedCompilation.isPage);
28898
- return {
28899
- code: returnedCode.code,
28900
- map: returnedCode.map
28901
- };
28902
- }
28903
- }
28904
- const currentStyleIndependentSignature = configService.isDev && dirtyEntryId && canAttemptStyleOnlyReuse && filename.endsWith(".vue") ? resolveVueSfcStyleIndependentSignature(transformedSource, filename) : void 0;
28905
- if (Boolean(configService.isDev && cachedCompilation && dirtyEntryId && canAttemptStyleOnlyReuse && filename.endsWith(".vue") && !ctx.runtimeState.scan.isDirty && cachedCompilation.autoRoutesSignature === autoRoutesSignature && cachedCompilation.styleIndependentSignature && currentStyleIndependentSignature && cachedCompilation.styleIndependentSignature === currentStyleIndependentSignature && cachedCompilation.source !== transformedSource) && cachedCompilation) {
28906
- const cachedResult = normalizeVueTransformResult(cachedCompilation.result);
28907
- const styleBlocks = await measureStage("loadStyleOnlySfcStyles", async () => await loadStyleBlocksForStyleOnlyRefresh({
28908
- filename,
28909
- source: transformedSource,
28910
- styleBlocksCache,
28911
- force: true,
28912
- readAndParseSfc,
28913
- createReadAndParseSfcOptions,
28914
- pluginCtx,
28915
- configService
28916
- }));
28917
- if (!refreshStyleOnlyVueTransformResult(cachedResult, filename, styleBlocks)) cachedCompilation.styleIndependentSignature = void 0;
28918
- else {
28919
- cachedCompilation.source = transformedSource;
28920
- cachedCompilation.result = cachedResult;
28921
- cachedCompilation.styleIndependentSignature = currentStyleIndependentSignature;
28922
- cachedCompilation.refreshToken = 0;
28923
- const hmrEventId = ctx.runtimeState.build?.hmr?.profile?.eventId;
28924
- if (hmrEventId != null && (isCssImporterDirty || styleBlocks?.length)) styleRefreshTokens.set(filename, hmrEventId);
28925
- const returnedCode = await measureVueHmrStage("finalizeCode", "vueFinalizeCodeMs", async () => finalizeTransformEntryCode({
28926
- result: cachedResult,
28927
- filename,
28928
- styleBlocks,
28929
- isPage: cachedCompilation.isPage,
28930
- isApp,
28931
- isDev: configService.isDev,
28932
- sourceMap,
28933
- hmrStyleToken: styleRefreshTokens.get(filename)
28934
- }));
28935
- if (dirtyEntryId) dirtyVueEntryIds?.delete(dirtyEntryId);
28936
- reportTiming(filename, cachedCompilation.isPage);
28937
- return {
28938
- code: returnedCode.code,
28939
- map: returnedCode.map
28940
- };
28941
- }
28942
- }
29018
+ const reuseResult = await tryReuseVueCompilation({
29019
+ ctx,
29020
+ pluginCtx,
29021
+ filename,
29022
+ source: transformedSource,
29023
+ cachedCompilation,
29024
+ previousStyleSignature,
29025
+ autoRoutesSignature,
29026
+ dirtyEntryId,
29027
+ dirtyVueEntryIds,
29028
+ isCssImporterDirty,
29029
+ canAttemptStyleOnlyReuse,
29030
+ sourceMap,
29031
+ isApp,
29032
+ styleBlocksCache,
29033
+ styleRefreshTokens,
29034
+ readAndParseSfc,
29035
+ createReadAndParseSfcOptions,
29036
+ measureStage,
29037
+ measureVueHmrStage,
29038
+ reportTiming
29039
+ });
29040
+ if (reuseResult.returnedCode) return {
29041
+ code: reuseResult.returnedCode.code,
29042
+ map: reuseResult.returnedCode.map
29043
+ };
29044
+ const { currentStyleIndependentSignature } = reuseResult;
28943
29045
  const compileOptions = createCompileVueFileOptions(ctx, pluginCtx, filename, isPage, isApp, configService, {
28944
29046
  reExportResolutionCache,
28945
29047
  classStyleRuntimeWarned,
28946
29048
  compileOptionsCache,
28947
29049
  componentMetaCache
28948
29050
  });
28949
- const result = normalizeVueTransformResult(await measureVueHmrStage("compile", "vueCompileMs", async () => await compileTransformEntryResult({
28950
- transformedSource,
28951
- filename,
28952
- compileOptions,
28953
- compileVueFile,
28954
- compileJsxFile
28955
- })));
28956
- let currentStyleBlocks = Array.isArray(result.meta?.styleBlocks) ? result.meta.styleBlocks : styleBlocksCache.get(filename);
28957
- if (!currentStyleBlocks) currentStyleBlocks = await measureStage("preloadSfcStyles", async () => await loadStyleBlocksForStyleOnlyRefresh({
28958
- filename,
28959
- source: transformedSource,
28960
- styleBlocksCache,
28961
- readAndParseSfc,
28962
- createReadAndParseSfcOptions,
28963
- pluginCtx,
28964
- configService
28965
- }));
28966
- if (currentStyleBlocks) styleBlocksCache.set(filename, currentStyleBlocks);
28967
- if (configService.isDev && dirtyEntryId) {
28968
- const currentStyleSignature = createSfcStyleBlocksSignature(currentStyleBlocks);
28969
- const hmrEventId = ctx.runtimeState.build?.hmr?.profile?.eventId;
28970
- if (hmrEventId != null && (isCssImporterDirty || currentStyleSignature && currentStyleSignature !== previousStyleSignature)) styleRefreshTokens.set(filename, hmrEventId);
28971
- else styleRefreshTokens.delete(filename);
28972
- dirtyVueEntryIds?.delete(dirtyEntryId);
28973
- }
28974
- const sfcStyleDependencies = syncVueSfcStyleDependencies(ctx, filename, currentStyleBlocks);
28975
- for (const dependency of sfcStyleDependencies) addNormalizedWatchFile(pluginCtx, dependency);
28976
- registerScopedSlotHostGenerics(ctx, result.scopedSlotComponents, parseUsingComponents(result.config));
28977
- await measureVueHmrStage("finalizeCompiledResult", "vueFinalizeCompiledMs", async () => {
28978
- await finalizeTransformCompiledResult({
29051
+ const jsonOnlyResult = await measureVueHmrStage("refreshJsonConfig", "vueCompileMs", async () => {
29052
+ return await tryRefreshJsonOnlyVueCompilation({
29053
+ cachedResult: cachedCompilation?.result,
29054
+ compileOptions,
29055
+ dirtyEntryId,
29056
+ dirtyReasonSummary: ctx.runtimeState?.build?.hmr?.profile?.dirtyReasonSummary,
29057
+ filename,
29058
+ isDev: configService.isDev,
29059
+ scanDirty: ctx.runtimeState.scan.isDirty,
29060
+ source: transformedSource,
29061
+ autoRoutesSignature,
29062
+ cachedAutoRoutesSignature: cachedCompilation?.autoRoutesSignature
29063
+ });
29064
+ });
29065
+ if (jsonOnlyResult) {
29066
+ const returnedCode = await finalizeVueTransform({
28979
29067
  ctx,
28980
29068
  pluginCtx,
28981
29069
  filename,
28982
29070
  source: transformedSource,
28983
29071
  autoRoutesSignature,
28984
- result,
29072
+ result: jsonOnlyResult,
28985
29073
  compilationCache,
28986
- styleIndependentSignature: filename.endsWith(".vue") ? currentStyleIndependentSignature ?? resolveVueSfcStyleIndependentSignature(transformedSource, filename) : void 0,
28987
- setAppShell,
28988
- configService,
29074
+ currentStyleIndependentSignature: cachedCompilation?.styleIndependentSignature,
29075
+ previousStyleSignature,
29076
+ dirtyEntryId,
29077
+ dirtyVueEntryIds,
29078
+ isCssImporterDirty,
28989
29079
  isPage,
28990
29080
  isApp,
28991
29081
  sourceMap,
29082
+ styleBlocksCache,
29083
+ styleRefreshTokens,
28992
29084
  scopedSlotModules,
28993
29085
  emittedScopedSlotChunks,
28994
- addWatchFile: addNormalizedWatchFile,
28995
- emitScopedSlotChunks
29086
+ setAppShell,
29087
+ readAndParseSfc,
29088
+ createReadAndParseSfcOptions,
29089
+ measureStage,
29090
+ measureVueHmrStage,
29091
+ reportTiming
28996
29092
  });
28997
- });
28998
- const returnedCode = await measureVueHmrStage("finalizeCode", "vueFinalizeCodeMs", async () => finalizeTransformEntryCode({
28999
- result,
29093
+ return {
29094
+ code: returnedCode.code,
29095
+ map: returnedCode.map
29096
+ };
29097
+ }
29098
+ const result = normalizeVueTransformResult(await measureVueHmrStage("compile", "vueCompileMs", async () => await compileTransformEntryResult({
29099
+ transformedSource,
29000
29100
  filename,
29001
- styleBlocks: result.meta?.styleBlocks ?? styleBlocksCache.get(filename),
29101
+ compileOptions,
29102
+ compileVueFile,
29103
+ compileJsxFile
29104
+ })));
29105
+ const returnedCode = await finalizeVueTransform({
29106
+ ctx,
29107
+ pluginCtx,
29108
+ filename,
29109
+ source: transformedSource,
29110
+ autoRoutesSignature,
29111
+ result,
29112
+ compilationCache,
29113
+ currentStyleIndependentSignature,
29114
+ previousStyleSignature,
29115
+ dirtyEntryId,
29116
+ dirtyVueEntryIds,
29117
+ isCssImporterDirty,
29002
29118
  isPage,
29003
29119
  isApp,
29004
- isDev: configService.isDev,
29005
29120
  sourceMap,
29006
- hmrStyleToken: configService.isDev ? styleRefreshTokens.get(filename) : void 0
29007
- }));
29008
- reportTiming(filename, isPage);
29121
+ styleBlocksCache,
29122
+ styleRefreshTokens,
29123
+ scopedSlotModules,
29124
+ emittedScopedSlotChunks,
29125
+ setAppShell,
29126
+ readAndParseSfc,
29127
+ createReadAndParseSfcOptions,
29128
+ measureStage,
29129
+ measureVueHmrStage,
29130
+ reportTiming
29131
+ });
29009
29132
  return {
29010
29133
  code: returnedCode.code,
29011
29134
  map: returnedCode.map
@@ -29067,71 +29190,64 @@ function createVueTransformPlugin(ctx) {
29067
29190
  readFile: fs.readFile
29068
29191
  });
29069
29192
  },
29070
- resolveId: {
29071
- filter: { id: SCOPED_SLOT_VIRTUAL_ID_RE },
29072
- handler(id) {
29073
- const startedAt = performance.now();
29074
- try {
29075
- return resolveScopedSlotVirtualId(id);
29076
- } finally {
29077
- const profile = ctx.runtimeState?.build?.hmr?.profile;
29078
- recordHmrProfileDuration(profile, "pluginResolveMs", performance.now() - startedAt);
29079
- recordHmrProfileOperation(profile, "resolveCount");
29080
- }
29193
+ resolveId(id) {
29194
+ if (!SCOPED_SLOT_VIRTUAL_ID_RE.test(id)) return null;
29195
+ const startedAt = performance.now();
29196
+ try {
29197
+ return resolveScopedSlotVirtualId(id);
29198
+ } finally {
29199
+ const profile = ctx.runtimeState?.build?.hmr?.profile;
29200
+ recordHmrProfileDuration(profile, "pluginResolveMs", performance.now() - startedAt);
29201
+ recordHmrProfileOperation(profile, "resolveCount");
29081
29202
  }
29082
29203
  },
29083
- load: {
29084
- filter: { id: VUE_LOAD_FILTER_RE },
29085
- async handler(id) {
29086
- return await loadTransformStyleBlock({
29087
- id,
29088
- pluginCtx: this,
29204
+ async load(id) {
29205
+ if (!VUE_LOAD_FILTER_RE.test(id)) return null;
29206
+ return await loadTransformStyleBlock({
29207
+ id,
29208
+ pluginCtx: this,
29209
+ ctx,
29210
+ configService: ctx.configService,
29211
+ styleBlocksCache,
29212
+ loadScopedSlotModule: (id) => {
29213
+ return loadScopedSlotModule(id, scopedSlotModules)?.code ?? null;
29214
+ },
29215
+ scopedSlotModules,
29216
+ parseWeappVueStyleRequest: (id) => parseWeappVueStyleRequest(id) ?? null,
29217
+ readAndParseSfc,
29218
+ createReadAndParseSfcOptions
29219
+ });
29220
+ },
29221
+ async transform(code, id) {
29222
+ if (!VUE_TRANSFORM_FILTER_RE.test(id) || !isVueLikeId(id)) return null;
29223
+ const startedAt = performance.now();
29224
+ try {
29225
+ return await transformVueLikeFile({
29089
29226
  ctx,
29090
- configService: ctx.configService,
29227
+ pluginCtx: this,
29228
+ code,
29229
+ id,
29230
+ compilationCache,
29231
+ setAppShell: (shell) => appShell = shell,
29232
+ pageMatcher,
29233
+ setPageMatcher: (matcher) => pageMatcher = matcher,
29234
+ scanDirtySynced,
29235
+ setScanDirtySynced: (synced) => scanDirtySynced = synced,
29236
+ reExportResolutionCache,
29237
+ compileOptionsCache,
29238
+ componentMetaCache,
29091
29239
  styleBlocksCache,
29092
- loadScopedSlotModule: (id) => {
29093
- return loadScopedSlotModule(id, scopedSlotModules)?.code ?? null;
29094
- },
29240
+ styleRefreshTokens,
29095
29241
  scopedSlotModules,
29096
- parseWeappVueStyleRequest: (id) => parseWeappVueStyleRequest(id) ?? null,
29242
+ emittedScopedSlotChunks,
29243
+ classStyleRuntimeWarned,
29097
29244
  readAndParseSfc,
29098
29245
  createReadAndParseSfcOptions
29099
29246
  });
29100
- }
29101
- },
29102
- transform: {
29103
- filter: { id: VUE_TRANSFORM_FILTER_RE },
29104
- async handler(code, id) {
29105
- if (!isVueLikeId(id)) return null;
29106
- const startedAt = performance.now();
29107
- try {
29108
- return await transformVueLikeFile({
29109
- ctx,
29110
- pluginCtx: this,
29111
- code,
29112
- id,
29113
- compilationCache,
29114
- setAppShell: (shell) => appShell = shell,
29115
- pageMatcher,
29116
- setPageMatcher: (matcher) => pageMatcher = matcher,
29117
- scanDirtySynced,
29118
- setScanDirtySynced: (synced) => scanDirtySynced = synced,
29119
- reExportResolutionCache,
29120
- compileOptionsCache,
29121
- componentMetaCache,
29122
- styleBlocksCache,
29123
- styleRefreshTokens,
29124
- scopedSlotModules,
29125
- emittedScopedSlotChunks,
29126
- classStyleRuntimeWarned,
29127
- readAndParseSfc,
29128
- createReadAndParseSfcOptions
29129
- });
29130
- } finally {
29131
- const durationMs = performance.now() - startedAt;
29132
- recordHmrProfileDuration(ctx.runtimeState?.build?.hmr?.profile, "transformMs", durationMs);
29133
- recordHmrProfileDuration(ctx.runtimeState?.build?.hmr?.profile, "vueTransformMs", durationMs);
29134
- }
29247
+ } finally {
29248
+ const durationMs = performance.now() - startedAt;
29249
+ recordHmrProfileDuration(ctx.runtimeState?.build?.hmr?.profile, "transformMs", durationMs);
29250
+ recordHmrProfileDuration(ctx.runtimeState?.build?.hmr?.profile, "vueTransformMs", durationMs);
29135
29251
  }
29136
29252
  },
29137
29253
  async generateBundle(_options, bundle) {
@@ -30440,7 +30556,7 @@ async function loadAppEntry(ctx, scanState) {
30440
30556
  const { path: appEntryPath } = appEntry;
30441
30557
  let configFromVue;
30442
30558
  if (!appConfigFile && vueAppPath) {
30443
- const { extractConfigFromVue } = await import("./file-vNYQ5su0.mjs");
30559
+ const { extractConfigFromVue } = await import("./file-Dbg8ttkV.mjs");
30444
30560
  configFromVue = await extractConfigFromVue(vueAppPath);
30445
30561
  if (configFromVue) appConfigFile = vueAppPath;
30446
30562
  }
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-DX_9zvvA.mjs");
87
+ const { getCompilerContext } = await import("./getInstance-DDUp2h9o.mjs");
88
88
  const compilerContext = getCompilerContext();
89
89
  const service = compilerContext.autoRoutesService;
90
90
  const reference = service?.getReference?.();
@@ -0,0 +1,2 @@
1
+ import { t as extractConfigFromVue } from "./file-CWu9BDPF.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { n as getCompilerContext } from "./createContext-giYv1R-U.mjs";
2
+ export { getCompilerContext };
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-DC-ADEdC.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-giYv1R-U.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.18.2",
4
+ "version": "6.18.4",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -110,38 +110,38 @@
110
110
  "package-manager-detector": "^1.7.0",
111
111
  "pathe": "^2.0.3",
112
112
  "picomatch": "^4.0.5",
113
- "postcss": "^8.5.17",
113
+ "postcss": "^8.5.19",
114
114
  "rolldown": "1.1.5",
115
- "rolldown-plugin-dts": "0.27.6",
115
+ "rolldown-plugin-dts": "0.27.9",
116
116
  "semver": "^7.8.5",
117
117
  "typescript": "^6.0.3",
118
- "vite": "8.1.4",
118
+ "vite": "8.1.5",
119
119
  "vite-tsconfig-paths": "^6.1.1",
120
- "vue": "^3.5.39",
120
+ "vue": "^3.5.40",
121
121
  "vue-tsc": "^3.3.7",
122
122
  "@weapp-core/constants": "0.1.13",
123
123
  "@weapp-core/init": "6.0.11",
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.18.2",
128
127
  "@weapp-vite/mcp": "1.4.8",
129
128
  "@weapp-vite/miniprogram-automator": "1.2.7",
130
- "@weapp-vite/volar": "2.1.1",
131
- "@weapp-vite/web": "1.3.35",
129
+ "@weapp-vite/ast": "6.18.4",
130
+ "@weapp-vite/web": "1.3.36",
132
131
  "@wevu/api": "0.2.11",
132
+ "@weapp-vite/volar": "2.1.2",
133
133
  "@wevu/web-apis": "1.2.27",
134
- "rolldown-require": "2.0.20",
134
+ "rolldown-require": "2.0.21",
135
135
  "vite-plugin-performance": "2.0.1",
136
136
  "weapp-ide-cli": "5.4.12",
137
- "wevu": "6.18.2"
137
+ "wevu": "6.18.4"
138
138
  },
139
139
  "publishConfig": {
140
140
  "access": "public",
141
141
  "registry": "https://registry.npmjs.org"
142
142
  },
143
143
  "devDependencies": {
144
- "oxc-parser": "^0.139.0",
144
+ "oxc-parser": "^0.140.0",
145
145
  "oxc-walker": "^1.0.0",
146
146
  "tailwindcss": "^4.3.2",
147
147
  "ts-morph": "^28.0.0"
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-DLA_2D0c.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { n as getCompilerContext } from "./createContext-DC-ADEdC.mjs";
2
- export { getCompilerContext };