weapp-tailwindcss 5.5.8 → 5.5.10
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/bundlers/vite/css-calc-stage.d.ts +8 -0
- package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/css-scope-graph.d.ts +5 -0
- package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +1 -1
- package/dist/bundlers/vite/css-finalizer/options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-cache-task.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-transform-result.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +3 -3
- package/dist/bundlers/vite/generate-bundle/scoped-generator-runtime-cache.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator-sources.d.ts +36 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +6 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/source-trace.d.ts +2 -0
- package/dist/bundlers/vite/runtime-class-set/cache.d.ts +14 -0
- package/dist/bundlers/vite/runtime-class-set/invalidation-plugin.d.ts +6 -0
- package/dist/bundlers/vite/runtime-class-set/lifecycle.d.ts +12 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +1 -2
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +1 -0
- package/dist/{compiler-DbwS3329.cjs → compiler-TvqqdOMD.cjs} +50 -38
- package/dist/{compiler-CThodfGH.js → compiler-v9sYta8W.js} +35 -30
- package/dist/core/compiler/generation-cache.d.ts +4 -2
- package/dist/core/compiler/root-store.d.ts +1 -1
- package/dist/core/compiler/source.d.ts +7 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{scoped-generator-DlQrVbuC.js → css-cleanup-B3xP5Qph.js} +26 -23
- package/dist/{generated-css-marker-B0RyziOH.cjs → generated-css-marker-nqjR6ntO.cjs} +102 -26
- package/dist/generation/pipeline/style-context.d.ts +3 -0
- package/dist/{generator-CxauQbx3.cjs → generator-B1sYQpWu.cjs} +165 -90
- package/dist/{generator-oKZ5mCJ5.js → generator-LqofzXgr.js} +155 -92
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DhddVxGA.js → gulp-BCV0gOMb.js} +4 -4
- package/dist/{gulp-CngHA9cU.cjs → gulp-DrX6QS3N.cjs} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-Dc4c1VRg.cjs → hmr-timing-B56wp7y-.cjs} +4 -4
- package/dist/{hmr-timing-xPpat-km.js → hmr-timing-Bb54exB0.js} +102 -26
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-EUud9R2K.cjs → pipeline-helpers-DJ3VZ01J.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/project-sources/candidates/view-memo.d.ts +7 -0
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{scoped-generator-lbTwL6mD.cjs → scoped-generator-DqNb8nJG.cjs} +31 -24
- package/dist/{source-candidate-scan-signature-BjVQYL-C.js → source-candidate-scan-signature-BWLf4tuO.js} +2 -2
- package/dist/{source-candidate-scan-signature-nG-rg809.cjs → source-candidate-scan-signature-_ohG0ePd.cjs} +2 -2
- package/dist/tailwindcss/v4/rpx-theme-warning.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/raw-generation.d.ts +30 -0
- package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +3 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +2 -0
- package/dist/{tailwindcss-kSd0ykiX.js → tailwindcss-XNfJSlhp.js} +2 -2
- package/dist/{tailwindcss-U3KIUegn.cjs → tailwindcss-uf04Iolj.cjs} +2 -2
- package/dist/{transform-DVg4q8hh.cjs → transform-CxVM0PfA.cjs} +3 -3
- package/dist/{transform-BAon9ykq.js → transform-D0NXKPmD.js} +3 -3
- package/dist/utils/stable-serialize.d.ts +1 -0
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-IX83wh_L.cjs → vite-C3Zh6iYK.cjs} +434 -209
- package/dist/{vite-D-RGkmOE.js → vite-D6_FxvdM.js} +434 -209
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/{web-DHfZ_KC9.cjs → web-BzeWG_XO.cjs} +442 -155
- package/dist/{web--kA4HUTm.js → web-K3qAX4sN.js} +431 -156
- package/dist/{webpack-Bhkd27Rs.js → webpack-BZBqKB4Y.js} +6 -6
- package/dist/{webpack-BetjemzT.cjs → webpack-Dbj2uykF.cjs} +8 -8
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +5 -4
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { _ as resolveTailwindV4CssSourceBase, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled, v as source_scan_exports } from "./tailwindcss-
|
|
1
|
+
import { _ as resolveTailwindV4CssSourceBase, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled, v as source_scan_exports } from "./tailwindcss-XNfJSlhp.js";
|
|
2
2
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
3
|
-
import {
|
|
3
|
+
import { R as getTailwindV4IncrementalGenerateCacheStats, T as omitUndefined, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, k as resolveTailwindcssOptions, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, s as shouldUseMiniProgramCssBranch, x as normalizeCssEntries, z as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-LqofzXgr.js";
|
|
4
4
|
import "./utils-MVwpU07P.js";
|
|
5
|
-
import { D as logTailwindcssTarget, E as toCustomAttributesEntities, G as createCompilationDependencyChanges, I as AssetEmissionPlan, N as createDebug, O as logRuntimeTailwindcssVersion, P as normalizeFrameworkStylePlatform, V as recordCompilationDependencyChanges, a as beginCompilerShadowRun, f as getCompilerContext, g as vitePluginName, i as disposeCompilerOwner, n as createRuntimeAffectingSourceSignature, y as shouldSkipJsTransform } from "./compiler-
|
|
6
|
-
import { B as isSourcePreprocessorRequest, C as extractMarkedUserLayerComponentsCss, E as splitUserCssLayerBlocks, K as isPureLocalCssImportWrapper, L as hasTailwindGeneratedCssMarkers, M as normalizeEmptyTailwindCustomVariants$1, Q as extractCandidatesFromSource, T as hasUserCssLayerBlocks, V as isSourceStyleRequest, Y as createSourceCandidateCollector, Z as isSourceCandidateRequest, a as hasBundlerGeneratedCssMarker, at as hasTailwindSourceDirectives, b as normalizeMiniProgramImportShell, c as annotateCssSourceTrace, ct as parseImportRequest, d as isCssSourceTraceEnabled, dt as finalizeCompilerShadowRun, f as generateTailwindV4Css, i as createBundlerGeneratedCssMarker, it as hasTailwindRootDirectives, l as createCssSourceTraceCacheSignature, lt as removeTailwindSourceDirectives, m as collectGeneratedRawSourceCandidatesFromCss, nt as hasTailwindApplyDirective, o as parseBundlerGeneratedCssMarkerBlocks, ot as normalizeTailwindConfigDirectives$1, p as validateCandidatesByGenerator, r as createBundlerGeneratedCssEndMarker, s as stripBundlerGeneratedCssMarkers, st as normalizeTailwindSourceForGenerator, t as createHmrTimingRecorder, u as createCssTokenSourceMap, v as runWithConcurrency, w as mergeMarkedUserLayerComponentsCss, x as scoreTailwindV4CssSourceFileMatch, y as normalizeMiniProgramGeneratorCssSource } from "./hmr-timing-
|
|
5
|
+
import { D as logTailwindcssTarget, E as toCustomAttributesEntities, G as createCompilationDependencyChanges, I as AssetEmissionPlan, N as createDebug, O as logRuntimeTailwindcssVersion, P as normalizeFrameworkStylePlatform, V as recordCompilationDependencyChanges, a as beginCompilerShadowRun, f as getCompilerContext, g as vitePluginName, i as disposeCompilerOwner, n as createRuntimeAffectingSourceSignature, y as shouldSkipJsTransform } from "./compiler-v9sYta8W.js";
|
|
6
|
+
import { B as isSourcePreprocessorRequest, C as extractMarkedUserLayerComponentsCss, E as splitUserCssLayerBlocks, K as isPureLocalCssImportWrapper, L as hasTailwindGeneratedCssMarkers, M as normalizeEmptyTailwindCustomVariants$1, Q as extractCandidatesFromSource, T as hasUserCssLayerBlocks, V as isSourceStyleRequest, Y as createSourceCandidateCollector, Z as isSourceCandidateRequest, a as hasBundlerGeneratedCssMarker, at as hasTailwindSourceDirectives, b as normalizeMiniProgramImportShell, c as annotateCssSourceTrace, ct as parseImportRequest, d as isCssSourceTraceEnabled, dt as finalizeCompilerShadowRun, f as generateTailwindV4Css, i as createBundlerGeneratedCssMarker, it as hasTailwindRootDirectives, l as createCssSourceTraceCacheSignature, lt as removeTailwindSourceDirectives, m as collectGeneratedRawSourceCandidatesFromCss, nt as hasTailwindApplyDirective, o as parseBundlerGeneratedCssMarkerBlocks, ot as normalizeTailwindConfigDirectives$1, p as validateCandidatesByGenerator, r as createBundlerGeneratedCssEndMarker, s as stripBundlerGeneratedCssMarkers, st as normalizeTailwindSourceForGenerator, t as createHmrTimingRecorder, u as createCssTokenSourceMap, v as runWithConcurrency, w as mergeMarkedUserLayerComponentsCss, x as scoreTailwindV4CssSourceFileMatch, y as normalizeMiniProgramGeneratorCssSource } from "./hmr-timing-Bb54exB0.js";
|
|
7
7
|
import { a as createRuntimeCompilationBuildState, c as updateRuntimeCompilationBuildState, n as processCachedTask, r as buildRuntimeCompilationSnapshot, t as finalizeMiniProgramCssStructure } from "./final-css-cleanup-BOzhuhGz.js";
|
|
8
|
-
import {
|
|
9
|
-
import { $ as
|
|
10
|
-
import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-
|
|
8
|
+
import { _ as createBuiltinViteStyleInjectorPlugins, a as createScopedGeneratorCandidateSignature, c as hasOwnSourceDirectives, d as createLinkedImpactSignature, f as getSnapshotHash, g as resolvePluginDisabledState, h as classifyRuntimeEntry, i as stripMiniProgramCssSpecificityPlaceholders, l as createCandidateSignature, m as summarizeStringDiff, n as hasMiniProgramCssSpecificityPlaceholders, o as createScopedGeneratorRuntime, p as hasRuntimeAffectingSourceChanges, s as createScopedGeneratorSourceTraceMap, u as createJsHashSalt, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./css-cleanup-B3xP5Qph.js";
|
|
9
|
+
import { $ as resolveSfcStyleSourceFromOutputFile, A as createGenericWebProductionBundleHooks, At as cleanUrl$1, B as sendFullReloadForUnresolvedHotUpdate, Bt as isMiniProgramStyleOutputFile, C as tryFinalizeGenericWebCss, Ct as canProcessViteSourceStyleAsCss, D as inferPlatformFromViteOutDir$1, Dt as resolveViteCssOutputFile, E as finalizeWebCss, Et as resolveReplayCssOutputFile, F as hasSelfAcceptingNonStyleHotModule, Ft as resolveViteCssPipelineRequestFile, G as shouldApplyViteWebCssCompat, Gt as getActiveViteSourceOutputRelationOwner, H as resolveViteModuleIdentity, Ht as createViteCssCalcStage, I as mergeHotModulesByIdentity, It as slash, J as hasSfcStyleSources, Jt as frameworkViteCapabilityProfile, K as collectChunkModuleIds$3, Kt as withViteSourceOutputRelationOwner, L as resolveHotSourceModules, Lt as createCssHandlerOptionsCache, M as shouldSkipGenericWebProductionSourceCandidates, Mt as isCSSRequest, N as finalizeCssCalc, Nt as isHTMLRequest, O as registerGeneratorDependencies$1, Ot as resolveViteCssPipelineOutputFile, P as finalizeWebCssCalc, Pt as normalizePath, Q as resolveSfcStyleRequestFromKnownSource, R as resolveHotSourceModulesByIds, Rt as resolveViteCssHandlerExtraOptions, S as createViteWebCssFinalizerOutputPlugin, St as SOURCE_STYLE_OUTPUT_EXT_RE, T as createCssHandlerOptions, Tt as resolveMiniProgramStyleOutputExtension, U as parseVueRequest, Ut as createViteCssAssetIdentityResolver, V as sendSupplementalCssHotUpdates, Vt as isRootStyleOutputFile, W as resolveViteWebCssCompatOptions, Wt as createViteSourceOutputRelationOwner, X as isSfcStyleSourceFile, Y as hasTailwindGenerationSource, Z as normalizeSfcSourceFileForCompare, _ as normalizeVitePersistentCacheKey, _t as removeDuplicateUnlinkedRootCssAssetsReferencedByHtml, a as readViteHmrSource, at as collectImportedStyleFiles, b as shouldCollectTransformedSourceCandidates, bt as posix, c as createViteHmrCssModuleVersionFilterPlugin, ct as createCssAssetPipelineContext, d as createFrameworkCssGenerationQueue, dt as hasNonCommentCss, et as resolveSourceStyleSourceFromOutputFile, f as createViteCssGenerationPlugins, ft as isMatchingGeneratedCssMarkerFile, g as isMissingInternalCssSource, gt as readAssetSource$2, h as hasVitePipelineTailwindGenerationDirective, ht as normalizeMarkerOutputFile, i as syncFrameworkSourceCandidatesForHotUpdate, it as clearAssetSource, j as createGenericWebProductionSourceCandidatesApply, jt as formatPostcssSourceMap, k as shouldGenerateCssByGenerator, kt as resolveViteCssPipelineOutputFileFromSourceFile, l as createViteHmrCssModuleVersionTracker, lt as dedupeViteCssResults, m as createRewriteCssImportsPlugins, mt as normalizeInjectableCssForTargetWithImports, n as createFrameworkTailwindRootCss, nt as isMatchingCssSourceFile, o as createFrameworkProcessedCssRegistry, ot as collectMatchingGeneratedCssMarkerFiles, p as createViteRuntimeClassSet, pt as normalizeInjectableCssForTarget, q as extractSfcStyleBlocks, qt as createGenericWebViteCapabilityProfile, r as createFrameworkSourceScanSession, rt as appendCss$1, s as createFrameworkPostPlugin, st as collectRootStyleBundleCssSources, t as createGenericWebVitePlugins, tt as hasMatchingStyleFileBase, u as createViteHmrCandidateState, ut as getAssetFile$1, v as summarizeStringCache, vt as removeTailwindEntryDirectivesFromCss, w as collectViteProcessedCssSources, wt as normalizeCssSourceForCompare, x as touchMapEntry, xt as CSS_SOURCE_OUTPUT_EXT_RE, y as createViteCssMemory, yt as resolveViteProcessedCssAssetSource, z as resolveHotTailwindCssModules, zt as isCssOutputFile } from "./web-K3qAX4sN.js";
|
|
10
|
+
import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-BWLf4tuO.js";
|
|
11
11
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
12
12
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import process from "node:process";
|
|
15
15
|
import { splitCandidateTokens } from "@weapp-tailwindcss/engine";
|
|
16
|
-
import { UNI_APP_X_BORDER_PREFLIGHT_CLASS, analyzeTailwindV4Source, collectCssApplyUtilities, collectCssReferenceDirectives, collectRootScopedComparableCssCoverage, compileCssMacroConditionalComments, containsCssAfterMinify, createCssRuleMatcher, createUniAppXBorderPreflight, createUniAppXHarmonyApplyCssExpander, createUniAppXHarmonyApplyGeneratorSource, cssToClassStyleValue, expandCssApplySourcesToStyleValue, filterExistingCssRules, hasCssLocationDependencies, hasVueScopedAttr, hoistUniAppXBorderPreflight, isCssImportOnly, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, normalizeUniAppXStyleProperty, normalizeUniAppXStyleValue, parseCssImportSpecifier, parseTailwindCssDirectiveRequest, postcss, quoteCssImportSpecifier, removeCommentOnlyAtRules, removeCssCoveredByRootStyleSources, removeCssRulesCoveredBySources, removeCssRulesCoveredBySources as removeCssRulesCoveredBySources$1, removeScopedTailwindPreflightCss, replaceViteGeneratedCssModule, restoreProcessedCssImports, restoreUniAppXImportantApplyMarker, retainUniAppXAuthorApplyCss, rewriteCssConfigRequests, rewriteUniAppXStyleReferences, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss/transform";
|
|
16
|
+
import { UNI_APP_X_BORDER_PREFLIGHT_CLASS, analyzeTailwindV4Source, collectCssApplyUtilities, collectCssReferenceDirectives, collectRootScopedComparableCssCoverage, compileCssMacroConditionalComments, containsCssAfterMinify, createCssRuleMatcher, createUniAppXBorderPreflight, createUniAppXHarmonyApplyCssExpander, createUniAppXHarmonyApplyGeneratorSource, cssToClassStyleValue, expandCssApplySourcesToStyleValue, filterExistingCssRules, hasCssLocationDependencies, hasVueScopedAttr, hoistUniAppXBorderPreflight, isCssImportOnly, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, normalizeUniAppXStyleProperty, normalizeUniAppXStyleValue, parseCssImportSpecifier, parseTailwindCssDirectiveRequest, postcss, quoteCssImportSpecifier, readDeferredCssSourceMarkers, removeCommentOnlyAtRules, removeCssCoveredByRootStyleSources, removeCssRulesCoveredBySources, removeCssRulesCoveredBySources as removeCssRulesCoveredBySources$1, removeScopedTailwindPreflightCss, replaceViteGeneratedCssModule, restoreProcessedCssImports, restoreUniAppXImportantApplyMarker, retainUniAppXAuthorApplyCss, rewriteCssConfigRequests, rewriteUniAppXStyleReferences, stripDeferredCssSourceMarkers, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss/transform";
|
|
17
17
|
import { LRUCache } from "lru-cache";
|
|
18
|
+
import { sourcePathApi } from "@weapp-tailwindcss/source-scan";
|
|
18
19
|
import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
|
|
19
20
|
import { Buffer } from "node:buffer";
|
|
20
21
|
import { readFile } from "node:fs/promises";
|
|
@@ -1597,7 +1598,7 @@ async function collectBundleMarkupCandidates(options) {
|
|
|
1597
1598
|
const valuesForEntries = (entries, filterOptions = {}) => {
|
|
1598
1599
|
const values = /* @__PURE__ */ new Set();
|
|
1599
1600
|
for (const { sourceFile: file, candidates } of candidatesByFile.values()) {
|
|
1600
|
-
if (entries !== void 0 && !(0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(file, entries)) continue;
|
|
1601
|
+
if (entries !== void 0 && (entries.length === 0 || !(0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(file, entries))) continue;
|
|
1601
1602
|
if (filterOptions.excludeEntries?.length && (0, source_scan_exports.isFileMatchedByTailwindSourceEntries)(file, filterOptions.excludeEntries)) continue;
|
|
1602
1603
|
for (const candidate of candidates) values.add(candidate);
|
|
1603
1604
|
}
|
|
@@ -1712,6 +1713,7 @@ function pruneLastCssResults(resultByFile, sourceHashByFile, activeFiles) {
|
|
|
1712
1713
|
//#region src/bundlers/vite/generate-bundle/css-cache-task.ts
|
|
1713
1714
|
function applyViteCssCacheResult(options, source) {
|
|
1714
1715
|
options.applyCssResult(source);
|
|
1716
|
+
options.recordCssResult?.(source);
|
|
1715
1717
|
rememberLastCssResult(options.lastCssResultByFile, options.lastCssSourceHashByFile, options.outputFile, source, options.cssRuntimeAffectingHash);
|
|
1716
1718
|
options.markCssAssetProcessed?.(options.originalSource, options.outputFile);
|
|
1717
1719
|
if (options.rememberedSourcesCount <= 1) options.rememberCssSource?.({
|
|
@@ -1826,6 +1828,47 @@ function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGenerator
|
|
|
1826
1828
|
return groups;
|
|
1827
1829
|
}
|
|
1828
1830
|
//#endregion
|
|
1831
|
+
//#region src/bundlers/vite/generate-bundle/source-trace.ts
|
|
1832
|
+
/** 来源标注沿用各入口的扫描目录,合并时保留同一候选的全部文件。 */
|
|
1833
|
+
async function createMergedCssSourceTraceMap(sources, resolve) {
|
|
1834
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1835
|
+
for (const map of await Promise.all(sources.map(resolve))) for (const [candidate, files] of map ?? []) {
|
|
1836
|
+
const existing = merged.get(candidate) ?? /* @__PURE__ */ new Set();
|
|
1837
|
+
for (const file of files) existing.add(file);
|
|
1838
|
+
merged.set(candidate, existing);
|
|
1839
|
+
}
|
|
1840
|
+
return merged;
|
|
1841
|
+
}
|
|
1842
|
+
//#endregion
|
|
1843
|
+
//#region src/bundlers/vite/generate-bundle/scoped-generator-sources.ts
|
|
1844
|
+
function hasScopedSourceDirectives(sources) {
|
|
1845
|
+
return sources.length > 1 && sources.some((source) => hasOwnSourceDirectives(source.rawSource, true));
|
|
1846
|
+
}
|
|
1847
|
+
function getSignatureSources(rememberedCssSources, generatorRawSource, generatorSourceFile) {
|
|
1848
|
+
return hasScopedSourceDirectives(rememberedCssSources) ? rememberedCssSources : [{
|
|
1849
|
+
rawSource: generatorRawSource,
|
|
1850
|
+
sourceFile: generatorSourceFile
|
|
1851
|
+
}];
|
|
1852
|
+
}
|
|
1853
|
+
async function createScopedGeneratorSourceData(options) {
|
|
1854
|
+
const { createScopedGeneratorRuntime, createScopedGeneratorSourceTraceMap, generatorCssHandlerOptions, generatorRawSource, generatorRuntime, generatorSourceFile, rememberedCssSources, scopedSourceCandidateSourceGetter, outputFile } = options;
|
|
1855
|
+
const signatureSources = getSignatureSources(rememberedCssSources, generatorRawSource, generatorSourceFile);
|
|
1856
|
+
const sourceTraceSources = scopedSourceCandidateSourceGetter ? signatureSources.length > 1 ? await createMergedCssSourceTraceMap(signatureSources, (source) => createScopedGeneratorSourceTraceMap(source.rawSource, source.sourceFile, { scopeToSource: true })) : await createScopedGeneratorSourceTraceMap(generatorRawSource, generatorSourceFile, { scopeToSource: hasScopedSourceDirectives(rememberedCssSources) }) : void 0;
|
|
1857
|
+
return {
|
|
1858
|
+
scopedGeneratorRuntime: hasScopedSourceDirectives(rememberedCssSources) ? new Set((await Promise.all(rememberedCssSources.map((source) => createScopedGeneratorRuntime(outputFile, generatorCssHandlerOptions, generatorRuntime, source.rawSource, source.sourceFile, true)))).flatMap((candidates) => [...candidates])) : await createScopedGeneratorRuntime(outputFile, generatorCssHandlerOptions, generatorRuntime, generatorRawSource, generatorSourceFile),
|
|
1859
|
+
signatureSources,
|
|
1860
|
+
sourceTraceSources
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
async function createScopedGeneratorCandidateSignatureForSources(options) {
|
|
1864
|
+
const { createScopedGeneratorCandidateSignature, generatorCssHandlerOptions, majorVersion, scopedSourceCandidateGetter, signatureSources, trackedGeneratorCandidateSignature } = options;
|
|
1865
|
+
return JSON.stringify(await Promise.all(signatureSources.map(async (source) => [source.sourceFile, await createScopedGeneratorCandidateSignature(source.rawSource, source.sourceFile, trackedGeneratorCandidateSignature, scopedSourceCandidateGetter, {
|
|
1866
|
+
includeFallbackSignature: generatorCssHandlerOptions.isMainChunk,
|
|
1867
|
+
majorVersion,
|
|
1868
|
+
scopeToSource: true
|
|
1869
|
+
})])));
|
|
1870
|
+
}
|
|
1871
|
+
//#endregion
|
|
1829
1872
|
//#region src/bundlers/vite/generate-bundle/css-composition-plan.ts
|
|
1830
1873
|
function resolveViteCssCompositionPlan(options) {
|
|
1831
1874
|
const rememberedSources = options.rememberedSources.filter((source) => !options.shouldSkipRememberedSource(source));
|
|
@@ -1870,6 +1913,7 @@ function resolveViteCssCompositionPlan(options) {
|
|
|
1870
1913
|
const isExplicitGeneratorCssEntry = options.explicitSourceFileKeys.has(generatorSourceFileKey);
|
|
1871
1914
|
const shouldUsePipelineSourceAsCssEntry = !isExplicitGeneratorCssEntry && vitePipelineCssAsset && options.cssMatcher(generatorSourceFile) && hasTailwindGenerationSource(generatorRawSource);
|
|
1872
1915
|
const generatorCssEntries = isExplicitGeneratorCssEntry || shouldUsePipelineSourceAsCssEntry ? [generatorSourceFile] : options.cssEntries;
|
|
1916
|
+
const hasScopedSources = hasScopedSourceDirectives(rememberedSources);
|
|
1873
1917
|
return {
|
|
1874
1918
|
cssHandlerOptions,
|
|
1875
1919
|
generatorCssHandlerOptions: {
|
|
@@ -1877,7 +1921,12 @@ function resolveViteCssCompositionPlan(options) {
|
|
|
1877
1921
|
sourceOptions: {
|
|
1878
1922
|
...cssHandlerOptions.sourceOptions,
|
|
1879
1923
|
sourceFile: generatorSourceFile,
|
|
1880
|
-
cssEntries: generatorCssEntries
|
|
1924
|
+
cssEntries: hasScopedSources ? rememberedSources.map((source) => source.sourceFile) : generatorCssEntries,
|
|
1925
|
+
...hasScopedSources ? { cssSources: rememberedSources.map((source) => ({
|
|
1926
|
+
file: source.sourceFile,
|
|
1927
|
+
base: sourcePathApi(source.sourceFile).dirname(source.sourceFile),
|
|
1928
|
+
css: source.rawSource
|
|
1929
|
+
})) } : {}
|
|
1881
1930
|
}
|
|
1882
1931
|
},
|
|
1883
1932
|
generatorRawSource,
|
|
@@ -2007,6 +2056,33 @@ function normalizeRelativeCssConfigDirectives(source, file, outputRoot, opts) {
|
|
|
2007
2056
|
});
|
|
2008
2057
|
}
|
|
2009
2058
|
//#endregion
|
|
2059
|
+
//#region src/bundlers/vite/generate-bundle/css-transform-result.ts
|
|
2060
|
+
function applyViteCssTransformTaskResult(options) {
|
|
2061
|
+
const { result } = options;
|
|
2062
|
+
registerGeneratorDependencies({ addWatchFile: options.addWatchFile }, result.dependencies);
|
|
2063
|
+
if (options.debugCssDiff && result.diffSource != null) options.debug("css diff %s: %s", options.generatorSourceFile, summarizeStringDiff(result.diffSource, result.css));
|
|
2064
|
+
if (result.shouldRecordCssAsset) options.recordCssAssetResult?.(options.outputFile, result.css);
|
|
2065
|
+
if (result.kind === "tailwind") {
|
|
2066
|
+
options.debug("css generated result: %s bytes=%d", options.file, result.css.length);
|
|
2067
|
+
for (const candidate of result.classSet ?? []) options.transformRuntime.add(candidate);
|
|
2068
|
+
recordViteCssContribution(options, result.css);
|
|
2069
|
+
options.debug("css handle via tailwind v%s engine(%s): %s", options.tailwindcssMajorVersion, result.generatorTarget, options.outputFile);
|
|
2070
|
+
} else if (result.kind === "web") options.debug("css preserve web target: %s", options.outputFile);
|
|
2071
|
+
else if (result.kind === "import-shell") options.debug("css preserve mini-program import shell: %s", options.outputFile);
|
|
2072
|
+
return result.css;
|
|
2073
|
+
}
|
|
2074
|
+
/** 新生成与缓存回放共同提交样式贡献,避免回滚后注入记录仍指向上一轮。 */
|
|
2075
|
+
function recordViteCssContribution(options, css) {
|
|
2076
|
+
if (options.shouldRecordVitePipelineCssByOutput) options.recordViteProcessedCssAssetResult?.(options.vitePipelineCssInjectionOutputFile, css, {
|
|
2077
|
+
injectIntoMain: options.outputIsMainChunk ? false : options.shouldInjectVitePipelineCssIntoMain,
|
|
2078
|
+
outputFile: options.vitePipelineCssInjectionOutputFile
|
|
2079
|
+
});
|
|
2080
|
+
if (options.vitePipelineCssAsset && options.shouldInjectVitePipelineCssIntoMain) options.recordViteProcessedCssAssetResult?.(options.file, css, {
|
|
2081
|
+
injectIntoMain: true,
|
|
2082
|
+
outputFile: options.vitePipelineCssInjectionOutputFile
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
//#endregion
|
|
2010
2086
|
//#region src/bundlers/vite/generate-bundle/transform-scheduling.ts
|
|
2011
2087
|
function scheduleViteCssTransform(options) {
|
|
2012
2088
|
const { addWatchFile, annotateCss, applyCssResult, applyViteCssCacheResult, applyViteCssTransformTaskResult, assetSourceFile, cache, cssCacheKey, cssHandlerOptions, cssHashKey, cssRuntimeAffectingHash, cssSharedCacheKey, cssTaskFactories, cssTaskHash, debug, envFlags, executeViteCssTransformTask, file, generatorCandidatesChanged, generatorCssHandlerOptions, generatorCssUserHandlerOptions, generatorPlatform, generatorRawSource, generatorSourceFile, generatorUserLayerRawSource, getLastCssResult, hasRuntimeAffectingChanges, isWebGeneratorTarget, lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, measureElapsed, metrics, normalizeGeneratorUserRawSource, normalizeMiniProgramGeneratorRawSource, onUpdate, opts, originalSource, outputCssHandlerOptions, outputFile, processViteCssCacheTask, rawSource, recordCssAssetResult, recordViteProcessedCssAssetResult, rememberedCssRuntimeSignature, rememberedCssSources, rememberCssSource, removeRootCoveredCssFromScopedAsset, runtimeState, scopedGeneratorRuntime, scopedSourceCandidateGetter, sharedCssResultCache, shouldInjectVitePipelineCssIntoMain, shouldRecordVitePipelineCssByOutput, snapshot, styleHandler, timeTask, transformRuntime, transformWebTargetCss, useIncrementalMode, usesConfiguredTailwindV4FallbackSource, vitePipelineCssAsset, vitePipelineCssInjectionOutputFile } = options;
|
|
@@ -2066,6 +2142,18 @@ function scheduleViteCssTransform(options) {
|
|
|
2066
2142
|
applyResult(source) {
|
|
2067
2143
|
applyViteCssCacheResult({
|
|
2068
2144
|
applyCssResult,
|
|
2145
|
+
recordCssResult: vitePipelineCssAsset ? (css) => {
|
|
2146
|
+
recordCssAssetResult?.(outputFile, css);
|
|
2147
|
+
recordViteCssContribution({
|
|
2148
|
+
file,
|
|
2149
|
+
outputIsMainChunk: outputCssHandlerOptions.isMainChunk === true,
|
|
2150
|
+
recordViteProcessedCssAssetResult,
|
|
2151
|
+
shouldRecordVitePipelineCssByOutput,
|
|
2152
|
+
shouldInjectVitePipelineCssIntoMain,
|
|
2153
|
+
vitePipelineCssAsset,
|
|
2154
|
+
vitePipelineCssInjectionOutputFile
|
|
2155
|
+
}, css);
|
|
2156
|
+
} : void 0,
|
|
2069
2157
|
cssRuntimeAffectingHash,
|
|
2070
2158
|
generatorRawSource,
|
|
2071
2159
|
generatorSourceFile,
|
|
@@ -2161,6 +2249,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2161
2249
|
normalizeConfiguredSourceFile: normalizeConfiguredTailwindV4CssEntryFileKey,
|
|
2162
2250
|
opts,
|
|
2163
2251
|
originalFileNames: originalSource.originalFileNames,
|
|
2252
|
+
ownedSourceFiles: readDeferredCssSourceMarkers(rawSource),
|
|
2164
2253
|
pipelineContext: cssPipelineContext2,
|
|
2165
2254
|
resolveOutputFileFromMatchedCssSource: resolveMatchedCssSourceOutputFile,
|
|
2166
2255
|
rootImportShellOutputFile,
|
|
@@ -2307,6 +2396,8 @@ async function processViteCssBundleEntry(options) {
|
|
|
2307
2396
|
viteProcessedCssAsset
|
|
2308
2397
|
});
|
|
2309
2398
|
outputFile = cssCompositionPlan.outputFile;
|
|
2399
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
2400
|
+
activeViteCssCacheFiles.add(`planned:${normalizeViteCssCacheKey(outputFile)}`);
|
|
2310
2401
|
outputCssHandlerOptions = cssCompositionPlan.outputCssHandlerOptions;
|
|
2311
2402
|
rememberedCssSources = cssCompositionPlan.rememberedSources;
|
|
2312
2403
|
const rememberedCssSource = cssCompositionPlan.rememberedSource;
|
|
@@ -2328,12 +2419,21 @@ async function processViteCssBundleEntry(options) {
|
|
|
2328
2419
|
temporaryCssAssetSourceResolver.markUsed(cssCompositionPlan.usedConfiguredSourceFile);
|
|
2329
2420
|
}
|
|
2330
2421
|
const { cssHandlerOptions: cssHandlerOptions2, generatorCssHandlerOptions, generatorRawSource, generatorSourceFile, generatorUserLayerRawSource, hasCurrentTailwindGenerationDirective, hasRememberedApplySource, hasSameOutputRememberedTailwindGenerationSource, hasStaleViteProcessedCssSource, usesConfiguredTailwindV4FallbackSource, vitePipelineCssAsset, webviewRootCssInjectionTarget } = cssCompositionPlan;
|
|
2331
|
-
const scopedSourceCandidateGetter = createScopedSourceCandidateGetter(outputFile, generatorCssHandlerOptions);
|
|
2332
|
-
const scopedSourceCandidateSourceGetter = createScopedSourceCandidateSourceGetter(outputFile, generatorCssHandlerOptions);
|
|
2333
|
-
const
|
|
2422
|
+
const scopedSourceCandidateGetter = createScopedSourceCandidateGetter(outputFile, generatorCssHandlerOptions, generatorSourceFile);
|
|
2423
|
+
const scopedSourceCandidateSourceGetter = createScopedSourceCandidateSourceGetter(outputFile, generatorCssHandlerOptions, generatorSourceFile);
|
|
2424
|
+
const { scopedGeneratorRuntime, signatureSources, sourceTraceSources } = await createScopedGeneratorSourceData({
|
|
2425
|
+
createScopedGeneratorRuntime,
|
|
2426
|
+
createScopedGeneratorSourceTraceMap: (source, file, options) => createScopedGeneratorSourceTraceMap(source, file, scopedSourceCandidateSourceGetter, options),
|
|
2427
|
+
generatorCssHandlerOptions,
|
|
2428
|
+
generatorRawSource,
|
|
2429
|
+
generatorRuntime,
|
|
2430
|
+
generatorSourceFile,
|
|
2431
|
+
rememberedCssSources,
|
|
2432
|
+
scopedSourceCandidateSourceGetter,
|
|
2433
|
+
outputFile
|
|
2434
|
+
});
|
|
2334
2435
|
const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
2335
2436
|
const sourceTraceSignature = createCssSourceTraceCacheSignature(sourceTraceTokenSources, opts);
|
|
2336
|
-
const scopedGeneratorRuntime = await createScopedGeneratorRuntime(outputFile, generatorCssHandlerOptions, generatorRuntime, generatorRawSource, generatorSourceFile);
|
|
2337
2437
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
2338
2438
|
opts,
|
|
2339
2439
|
tokenSources: sourceTraceTokenSources
|
|
@@ -2384,7 +2484,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2384
2484
|
rawSource: generatorRawSource,
|
|
2385
2485
|
sourceFile: generatorSourceFile
|
|
2386
2486
|
});
|
|
2387
|
-
if (shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile, nextCss, {
|
|
2487
|
+
if (vitePipelineCssAsset && shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile, nextCss, {
|
|
2388
2488
|
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectVitePipelineCssIntoMain,
|
|
2389
2489
|
outputFile: vitePipelineCssInjectionOutputFile
|
|
2390
2490
|
});
|
|
@@ -2397,7 +2497,14 @@ async function processViteCssBundleEntry(options) {
|
|
|
2397
2497
|
return;
|
|
2398
2498
|
}
|
|
2399
2499
|
const trackedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ? createCandidateSignature(scopedGeneratorRuntime) : "generator:stable";
|
|
2400
|
-
const scopedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ?
|
|
2500
|
+
const scopedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ? signatureSources.length > 1 ? await createScopedGeneratorCandidateSignatureForSources({
|
|
2501
|
+
createScopedGeneratorCandidateSignature,
|
|
2502
|
+
generatorCssHandlerOptions,
|
|
2503
|
+
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2504
|
+
scopedSourceCandidateGetter,
|
|
2505
|
+
signatureSources,
|
|
2506
|
+
trackedGeneratorCandidateSignature
|
|
2507
|
+
}) : await createScopedGeneratorCandidateSignature(generatorRawSource, generatorSourceFile, trackedGeneratorCandidateSignature, scopedSourceCandidateGetter, {
|
|
2401
2508
|
includeFallbackSignature: generatorCssHandlerOptions.isMainChunk,
|
|
2402
2509
|
majorVersion: runtimeState.tailwindRuntime.majorVersion
|
|
2403
2510
|
}) : trackedGeneratorCandidateSignature;
|
|
@@ -2407,7 +2514,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2407
2514
|
runtimeAffectingSignatureByFile: snapshot.runtimeAffectingSignatureByFile
|
|
2408
2515
|
}) : "";
|
|
2409
2516
|
const { cssCacheKey, cssHashKey, cssSharedCacheKey, cssTaskHash, rememberedCssRuntimeSignature } = resolveViteCssTransformCachePlan({
|
|
2410
|
-
cssBundleSourceHash:
|
|
2517
|
+
cssBundleSourceHash: cache.computeHash(rawSource),
|
|
2411
2518
|
cssIsMainChunk: cssHandlerOptions2.isMainChunk === true,
|
|
2412
2519
|
cssRuntimeAffectingHash,
|
|
2413
2520
|
cssShareScope,
|
|
@@ -2496,6 +2603,135 @@ async function processViteCssBundleEntry(options) {
|
|
|
2496
2603
|
});
|
|
2497
2604
|
}
|
|
2498
2605
|
//#endregion
|
|
2606
|
+
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
2607
|
+
function collectTailwindV4SourceFingerprint(source) {
|
|
2608
|
+
return analyzeTailwindV4Source(source, path.basename).getFingerprint();
|
|
2609
|
+
}
|
|
2610
|
+
function scoreSourceFingerprints(rawTokens, entryTokens) {
|
|
2611
|
+
let score = 0;
|
|
2612
|
+
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
2613
|
+
return score;
|
|
2614
|
+
}
|
|
2615
|
+
function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
2616
|
+
if (!rawSource) return 0;
|
|
2617
|
+
const rawTokens = collectTailwindV4SourceFingerprint(rawSource);
|
|
2618
|
+
if (rawTokens.size === 0) return 0;
|
|
2619
|
+
return scoreSourceFingerprints(rawTokens, collectTailwindV4SourceFingerprint(entrySource));
|
|
2620
|
+
}
|
|
2621
|
+
function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, options = {}) {
|
|
2622
|
+
const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
|
|
2623
|
+
if (generationSources.length <= 1) return generationSources[0];
|
|
2624
|
+
const analyses = /* @__PURE__ */ new Map();
|
|
2625
|
+
const analyze = (source) => {
|
|
2626
|
+
let analysis = analyses.get(source);
|
|
2627
|
+
if (!analysis) {
|
|
2628
|
+
analysis = analyzeTailwindV4Source(source, path.basename);
|
|
2629
|
+
analyses.set(source, analysis);
|
|
2630
|
+
}
|
|
2631
|
+
return analysis;
|
|
2632
|
+
};
|
|
2633
|
+
const canMatchByOutputPath = Boolean(options.cwd || options.outputRoot || options.projectRoot);
|
|
2634
|
+
const selectByOutputPath = (candidates, shouldUseScore = (score) => score > 0) => {
|
|
2635
|
+
if (!canMatchByOutputPath) return;
|
|
2636
|
+
const scoredSources = candidates.map((entry) => ({
|
|
2637
|
+
entry,
|
|
2638
|
+
score: scoreTailwindV4CssSourceFileMatch(outputFile, entry.file, {
|
|
2639
|
+
cwd: options.cwd,
|
|
2640
|
+
outputRoot: options.outputRoot,
|
|
2641
|
+
projectRoot: options.projectRoot
|
|
2642
|
+
})
|
|
2643
|
+
})).filter((item) => shouldUseScore(item.score)).sort((a, b) => b.score - a.score);
|
|
2644
|
+
const bestScore = scoredSources[0]?.score;
|
|
2645
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
2646
|
+
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
2647
|
+
};
|
|
2648
|
+
const selectByRawSourceFingerprint = (candidates) => {
|
|
2649
|
+
if (!rawSource) return;
|
|
2650
|
+
const rawTokens = analyze(rawSource).getFingerprint();
|
|
2651
|
+
if (rawTokens.size === 0) return;
|
|
2652
|
+
const scoredSources = candidates.map((entry) => ({
|
|
2653
|
+
entry,
|
|
2654
|
+
score: scoreSourceFingerprints(rawTokens, analyze(entry.source).getFingerprint())
|
|
2655
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2656
|
+
const bestScore = scoredSources[0]?.score;
|
|
2657
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
2658
|
+
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
2659
|
+
};
|
|
2660
|
+
const explicitSources = generationSources.filter((entry) => analyze(entry.source).hasExplicitDirectives);
|
|
2661
|
+
const candidates = explicitSources.length === 1 ? explicitSources : generationSources;
|
|
2662
|
+
const directoryIndexOutputPathMatched = selectByOutputPath(candidates, (score) => score >= 25e3 && score < 5e4);
|
|
2663
|
+
if (directoryIndexOutputPathMatched) return directoryIndexOutputPathMatched;
|
|
2664
|
+
const rawSourceMatched = selectByRawSourceFingerprint(generationSources);
|
|
2665
|
+
if (rawSourceMatched) return rawSourceMatched;
|
|
2666
|
+
const outputPathMatched = selectByOutputPath(candidates);
|
|
2667
|
+
if (outputPathMatched) return outputPathMatched;
|
|
2668
|
+
if (candidates.length === 1) return candidates[0];
|
|
2669
|
+
return selectByRawSourceFingerprint(candidates);
|
|
2670
|
+
}
|
|
2671
|
+
//#endregion
|
|
2672
|
+
//#region src/bundlers/vite/generate-bundle/temporary-css-assets.ts
|
|
2673
|
+
function shouldQueueTemporarySource(entry, options) {
|
|
2674
|
+
return normalizeOutputPathKey(entry.outputFile).includes("/") || options.explicitSourceFileKeys.has(options.normalizeConfiguredSourceFile(entry.file)) && options.shouldSelectConfiguredRootOutput(entry.outputFile);
|
|
2675
|
+
}
|
|
2676
|
+
function collectTemporaryCssSourceEntries(options) {
|
|
2677
|
+
const runtimeLinkedEntries = [...options.runtimeLinkedCssFiles].map((file) => options.resolveRuntimeLinkedSource(file)).filter((entry) => entry != null && options.currentSubpackageRoots != null && shouldQueueTemporarySource(entry, options));
|
|
2678
|
+
const rememberedEntries = options.rememberedEntries.filter((entry) => shouldQueueTemporarySource(entry, options));
|
|
2679
|
+
const configuredEntries = options.configuredEntries.filter((entry) => normalizeOutputPathKey(entry.outputFile).includes("/") || shouldQueueTemporarySource(entry, options));
|
|
2680
|
+
const scopedEntries = options.currentSubpackageRoots ? options.configuredScopeEntries.filter((entry) => options.isSubpackageOutputFile(entry.outputFile, options.currentSubpackageRoots)) : [];
|
|
2681
|
+
return [
|
|
2682
|
+
...runtimeLinkedEntries,
|
|
2683
|
+
...rememberedEntries,
|
|
2684
|
+
...configuredEntries,
|
|
2685
|
+
...scopedEntries
|
|
2686
|
+
];
|
|
2687
|
+
}
|
|
2688
|
+
function isTemporaryCssAssetFile(file) {
|
|
2689
|
+
const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2690
|
+
return /\.css$/i.test(normalized) && !normalized.includes("/");
|
|
2691
|
+
}
|
|
2692
|
+
function normalizeCssSourceKey(file) {
|
|
2693
|
+
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2694
|
+
}
|
|
2695
|
+
function createTemporaryCssAssetSourceResolver(entries) {
|
|
2696
|
+
const seenEntryFiles = /* @__PURE__ */ new Set();
|
|
2697
|
+
const queuedEntries = entries.filter((entry) => {
|
|
2698
|
+
const entryFile = normalizeCssSourceKey(entry.file);
|
|
2699
|
+
if (normalizeCssSourceKey(entry.outputFile) === entryFile || seenEntryFiles.has(entryFile)) return false;
|
|
2700
|
+
seenEntryFiles.add(entryFile);
|
|
2701
|
+
return true;
|
|
2702
|
+
});
|
|
2703
|
+
const usedEntryFiles = /* @__PURE__ */ new Set();
|
|
2704
|
+
return {
|
|
2705
|
+
entries: queuedEntries,
|
|
2706
|
+
markUsed(sourceFile) {
|
|
2707
|
+
if (!sourceFile) return;
|
|
2708
|
+
usedEntryFiles.add(normalizeCssSourceKey(sourceFile));
|
|
2709
|
+
},
|
|
2710
|
+
resolve(outputFile, rawSource) {
|
|
2711
|
+
if (!isTemporaryCssAssetFile(outputFile)) return;
|
|
2712
|
+
const outputFileKey = normalizeCssSourceKey(outputFile);
|
|
2713
|
+
const unusedEntries = queuedEntries.filter((item) => !usedEntryFiles.has(normalizeCssSourceKey(item.file)));
|
|
2714
|
+
const matchedOutputEntries = unusedEntries.filter((item) => normalizeCssSourceKey(item.outputFile) === outputFileKey);
|
|
2715
|
+
const usesMatchedOutputEntries = matchedOutputEntries.length > 0;
|
|
2716
|
+
const availableEntries = matchedOutputEntries.length > 0 ? matchedOutputEntries : unusedEntries.filter((item) => normalizeCssSourceKey(item.outputFile).includes("/"));
|
|
2717
|
+
const scoredEntries = rawSource ? availableEntries.map((entry) => ({
|
|
2718
|
+
entry,
|
|
2719
|
+
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
2720
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score) : [];
|
|
2721
|
+
const bestScore = scoredEntries[0]?.score;
|
|
2722
|
+
const bestEntries = bestScore ? scoredEntries.filter((item) => item.score === bestScore) : [];
|
|
2723
|
+
const entry = bestEntries.length === 1 ? bestEntries[0]?.entry : usesMatchedOutputEntries || rawSource == null ? availableEntries.find((item) => hasTailwindGenerationSource(item.source)) : void 0;
|
|
2724
|
+
if (!entry) return;
|
|
2725
|
+
usedEntryFiles.add(normalizeCssSourceKey(entry.file));
|
|
2726
|
+
return {
|
|
2727
|
+
outputFile: entry.outputFile,
|
|
2728
|
+
rawSource: entry.source,
|
|
2729
|
+
sourceFile: entry.file
|
|
2730
|
+
};
|
|
2731
|
+
}
|
|
2732
|
+
};
|
|
2733
|
+
}
|
|
2734
|
+
//#endregion
|
|
2499
2735
|
//#region src/bundlers/vite/generate-bundle/css-output-helpers.ts
|
|
2500
2736
|
function resolveCssBundleOutputFile(options) {
|
|
2501
2737
|
const { bundleFiles, defaultStyleOutputExtension, file, isWebGeneratorTarget, opts, pipelineContext, cssPipelineStrategy, shouldPreserveAppCssExtension } = options;
|
|
@@ -2522,15 +2758,16 @@ function resolveOutputFileFromMatchedCssSource(options) {
|
|
|
2522
2758
|
return opts.cssMatcher(outputFile) ? outputFile : void 0;
|
|
2523
2759
|
}
|
|
2524
2760
|
function createMatchedCssSourceOutputResolver(options) {
|
|
2525
|
-
const { assetSourceFile, file, originalFileNames, resolveOutputFileFromMatchedCssSource } = options;
|
|
2761
|
+
const { assetSourceFile, file, originalFileNames, ownedSourceFiles, resolveOutputFileFromMatchedCssSource } = options;
|
|
2526
2762
|
return (sourceFile) => {
|
|
2527
2763
|
if (!sourceFile) return;
|
|
2528
2764
|
const cleanAssetSourceFile = assetSourceFile.replace(/[?#].*$/, "");
|
|
2529
2765
|
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
2530
2766
|
const sourceHasQuery = cleanSourceFile !== sourceFile;
|
|
2531
2767
|
const resolvedSourceOutputFile = resolveOutputFileFromMatchedCssSource(sourceFile);
|
|
2532
|
-
|
|
2533
|
-
|
|
2768
|
+
const ownsDeferredSource = isTemporaryCssAssetFile(file) && ownedSourceFiles?.some((originalFile) => normalizeOutputPathKey(originalFile.replace(/[?#].*$/, "")) === normalizeOutputPathKey(cleanSourceFile)) === true;
|
|
2769
|
+
if (normalizeOutputPathKey(cleanAssetSourceFile) === normalizeOutputPathKey(cleanSourceFile) || ownsDeferredSource || originalFileNames?.some((originalFile) => normalizeOutputPathKey(originalFile.replace(/[?#].*$/, "")) === normalizeOutputPathKey(cleanSourceFile))) {
|
|
2770
|
+
if (!sourceHasQuery && !ownsDeferredSource && normalizeOutputPathKey(cleanAssetSourceFile) === normalizeOutputPathKey(cleanSourceFile) && typeof resolvedSourceOutputFile === "string" && normalizeOutputPathKey(resolvedSourceOutputFile) !== normalizeOutputPathKey(file)) return resolvedSourceOutputFile;
|
|
2534
2771
|
return file;
|
|
2535
2772
|
}
|
|
2536
2773
|
return resolvedSourceOutputFile;
|
|
@@ -2547,6 +2784,7 @@ function resolveCssAssetOutputPlan(options) {
|
|
|
2547
2784
|
assetSourceFile: options.assetSourceFile,
|
|
2548
2785
|
file: options.file,
|
|
2549
2786
|
originalFileNames: options.originalFileNames,
|
|
2787
|
+
ownedSourceFiles: options.ownedSourceFiles,
|
|
2550
2788
|
resolveOutputFileFromMatchedCssSource: options.resolveOutputFileFromMatchedCssSource
|
|
2551
2789
|
});
|
|
2552
2790
|
const configuredOriginalSourceEntry = outputFile.replace(/[?#].*$/, "").endsWith(".css") ? options.configuredEntries.find((entry) => options.originalFileNames?.some((originalFile) => options.normalizeConfiguredSourceFile(originalFile) === options.normalizeConfiguredSourceFile(entry.file)) === true) : void 0;
|
|
@@ -2678,72 +2916,6 @@ async function resolveRememberedCssSourcePlan(options) {
|
|
|
2678
2916
|
};
|
|
2679
2917
|
}
|
|
2680
2918
|
//#endregion
|
|
2681
|
-
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
2682
|
-
function collectTailwindV4SourceFingerprint(source) {
|
|
2683
|
-
return analyzeTailwindV4Source(source, path.basename).getFingerprint();
|
|
2684
|
-
}
|
|
2685
|
-
function scoreSourceFingerprints(rawTokens, entryTokens) {
|
|
2686
|
-
let score = 0;
|
|
2687
|
-
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
2688
|
-
return score;
|
|
2689
|
-
}
|
|
2690
|
-
function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
2691
|
-
if (!rawSource) return 0;
|
|
2692
|
-
const rawTokens = collectTailwindV4SourceFingerprint(rawSource);
|
|
2693
|
-
if (rawTokens.size === 0) return 0;
|
|
2694
|
-
return scoreSourceFingerprints(rawTokens, collectTailwindV4SourceFingerprint(entrySource));
|
|
2695
|
-
}
|
|
2696
|
-
function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, options = {}) {
|
|
2697
|
-
const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
|
|
2698
|
-
if (generationSources.length <= 1) return generationSources[0];
|
|
2699
|
-
const analyses = /* @__PURE__ */ new Map();
|
|
2700
|
-
const analyze = (source) => {
|
|
2701
|
-
let analysis = analyses.get(source);
|
|
2702
|
-
if (!analysis) {
|
|
2703
|
-
analysis = analyzeTailwindV4Source(source, path.basename);
|
|
2704
|
-
analyses.set(source, analysis);
|
|
2705
|
-
}
|
|
2706
|
-
return analysis;
|
|
2707
|
-
};
|
|
2708
|
-
const canMatchByOutputPath = Boolean(options.cwd || options.outputRoot || options.projectRoot);
|
|
2709
|
-
const selectByOutputPath = (candidates, shouldUseScore = (score) => score > 0) => {
|
|
2710
|
-
if (!canMatchByOutputPath) return;
|
|
2711
|
-
const scoredSources = candidates.map((entry) => ({
|
|
2712
|
-
entry,
|
|
2713
|
-
score: scoreTailwindV4CssSourceFileMatch(outputFile, entry.file, {
|
|
2714
|
-
cwd: options.cwd,
|
|
2715
|
-
outputRoot: options.outputRoot,
|
|
2716
|
-
projectRoot: options.projectRoot
|
|
2717
|
-
})
|
|
2718
|
-
})).filter((item) => shouldUseScore(item.score)).sort((a, b) => b.score - a.score);
|
|
2719
|
-
const bestScore = scoredSources[0]?.score;
|
|
2720
|
-
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
2721
|
-
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
2722
|
-
};
|
|
2723
|
-
const selectByRawSourceFingerprint = (candidates) => {
|
|
2724
|
-
if (!rawSource) return;
|
|
2725
|
-
const rawTokens = analyze(rawSource).getFingerprint();
|
|
2726
|
-
if (rawTokens.size === 0) return;
|
|
2727
|
-
const scoredSources = candidates.map((entry) => ({
|
|
2728
|
-
entry,
|
|
2729
|
-
score: scoreSourceFingerprints(rawTokens, analyze(entry.source).getFingerprint())
|
|
2730
|
-
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2731
|
-
const bestScore = scoredSources[0]?.score;
|
|
2732
|
-
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
2733
|
-
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
2734
|
-
};
|
|
2735
|
-
const explicitSources = generationSources.filter((entry) => analyze(entry.source).hasExplicitDirectives);
|
|
2736
|
-
const candidates = explicitSources.length === 1 ? explicitSources : generationSources;
|
|
2737
|
-
const directoryIndexOutputPathMatched = selectByOutputPath(candidates, (score) => score >= 25e3 && score < 5e4);
|
|
2738
|
-
if (directoryIndexOutputPathMatched) return directoryIndexOutputPathMatched;
|
|
2739
|
-
const rawSourceMatched = selectByRawSourceFingerprint(generationSources);
|
|
2740
|
-
if (rawSourceMatched) return rawSourceMatched;
|
|
2741
|
-
const outputPathMatched = selectByOutputPath(candidates);
|
|
2742
|
-
if (outputPathMatched) return outputPathMatched;
|
|
2743
|
-
if (candidates.length === 1) return candidates[0];
|
|
2744
|
-
return selectByRawSourceFingerprint(candidates);
|
|
2745
|
-
}
|
|
2746
|
-
//#endregion
|
|
2747
2919
|
//#region src/bundlers/vite/generate-bundle/css-source-plan.ts
|
|
2748
2920
|
function hasTailwindPluginDirective(source) {
|
|
2749
2921
|
return /@plugin\b/.test(source);
|
|
@@ -2770,6 +2942,30 @@ function finalizeSourcePlan(plan, options) {
|
|
|
2770
2942
|
};
|
|
2771
2943
|
}
|
|
2772
2944
|
async function resolveViteCssSourcePlan(options) {
|
|
2945
|
+
const markedSources = options.rawSource.includes("weapp-tailwindcss deferred-source:") ? readDeferredCssSourceMarkers(options.rawSource).map((file) => {
|
|
2946
|
+
const source = options.getSourceStyleSource?.(file);
|
|
2947
|
+
if (source === void 0) throw new Error(`Missing transformed CSS source for deferred generation: ${file}`);
|
|
2948
|
+
return {
|
|
2949
|
+
sourceFile: file,
|
|
2950
|
+
rawSource: source,
|
|
2951
|
+
outputFile: options.temporaryOutput || !options.isCurrentRootMiniProgramStyleOutput ? options.outputFile : options.resolveMatchedOutputFile(file) ?? options.outputFile
|
|
2952
|
+
};
|
|
2953
|
+
}) : [];
|
|
2954
|
+
if (markedSources.length > 0) {
|
|
2955
|
+
options.debug("deferred css source markers: %O", markedSources.map((source) => ({
|
|
2956
|
+
sourceFile: source.sourceFile,
|
|
2957
|
+
outputFile: source.outputFile
|
|
2958
|
+
})));
|
|
2959
|
+
return {
|
|
2960
|
+
forceNonMainChunk: false,
|
|
2961
|
+
hasUsableTailwindSource: true,
|
|
2962
|
+
outputFile: markedSources[0]?.outputFile ?? options.outputFile,
|
|
2963
|
+
resolution: "remembered",
|
|
2964
|
+
resolvedFromTemporarySource: false,
|
|
2965
|
+
sources: markedSources,
|
|
2966
|
+
usedConfiguredSourceFiles: markedSources.map((source) => options.normalizeConfiguredSourceFile(source.sourceFile))
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2773
2969
|
const rememberedPlan = await resolveRememberedCssSourcePlan(options);
|
|
2774
2970
|
if (rememberedPlan.hasUsableTailwindSource) return finalizeSourcePlan({
|
|
2775
2971
|
...rememberedPlan,
|
|
@@ -2908,29 +3104,6 @@ function resolveViteCssLinkedImpactSignature(options) {
|
|
|
2908
3104
|
return [...[...options.changedHtmlFiles].sort().map((file) => options.runtimeAffectingSignatureByFile.get(file) ?? ""), ...[...options.changedJsFiles].sort().map((file) => options.runtimeAffectingSignatureByFile.get(file) ?? "")].join(":");
|
|
2909
3105
|
}
|
|
2910
3106
|
//#endregion
|
|
2911
|
-
//#region src/bundlers/vite/generate-bundle/css-transform-result.ts
|
|
2912
|
-
function applyViteCssTransformTaskResult(options) {
|
|
2913
|
-
const { result } = options;
|
|
2914
|
-
registerGeneratorDependencies({ addWatchFile: options.addWatchFile }, result.dependencies);
|
|
2915
|
-
if (options.debugCssDiff && result.diffSource != null) options.debug("css diff %s: %s", options.generatorSourceFile, summarizeStringDiff(result.diffSource, result.css));
|
|
2916
|
-
if (result.shouldRecordCssAsset) options.recordCssAssetResult?.(options.outputFile, result.css);
|
|
2917
|
-
if (result.kind === "tailwind") {
|
|
2918
|
-
options.debug("css generated result: %s bytes=%d", options.file, result.css.length);
|
|
2919
|
-
for (const candidate of result.classSet ?? []) options.transformRuntime.add(candidate);
|
|
2920
|
-
if (options.shouldRecordVitePipelineCssByOutput) options.recordViteProcessedCssAssetResult?.(options.vitePipelineCssInjectionOutputFile, result.css, {
|
|
2921
|
-
injectIntoMain: options.outputIsMainChunk ? false : options.shouldInjectVitePipelineCssIntoMain,
|
|
2922
|
-
outputFile: options.vitePipelineCssInjectionOutputFile
|
|
2923
|
-
});
|
|
2924
|
-
if (options.vitePipelineCssAsset && options.shouldInjectVitePipelineCssIntoMain) options.recordViteProcessedCssAssetResult?.(options.file, result.css, {
|
|
2925
|
-
injectIntoMain: true,
|
|
2926
|
-
outputFile: options.vitePipelineCssInjectionOutputFile
|
|
2927
|
-
});
|
|
2928
|
-
options.debug("css handle via tailwind v%s engine(%s): %s", options.tailwindcssMajorVersion, result.generatorTarget, options.outputFile);
|
|
2929
|
-
} else if (result.kind === "web") options.debug("css preserve web target: %s", options.outputFile);
|
|
2930
|
-
else if (result.kind === "import-shell") options.debug("css preserve mini-program import shell: %s", options.outputFile);
|
|
2931
|
-
return result.css;
|
|
2932
|
-
}
|
|
2933
|
-
//#endregion
|
|
2934
3107
|
//#region src/bundlers/vite/generate-bundle/web-css-module.ts
|
|
2935
3108
|
function replaceWebCssModule(source, sourceFile, generated) {
|
|
2936
3109
|
const sourceKey = normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, ""));
|
|
@@ -2971,7 +3144,7 @@ async function executeViteCssTransformTask(options) {
|
|
|
2971
3144
|
const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(options.isWebGeneratorTarget ? replaceWebCssModule(options.rawSource, options.generatorSourceFile, generated.css) ?? generated.css : generated.css)));
|
|
2972
3145
|
return {
|
|
2973
3146
|
classSet: generated.classSet,
|
|
2974
|
-
css,
|
|
3147
|
+
css: stripDeferredCssSourceMarkers(css),
|
|
2975
3148
|
dependencies: generated.dependencies,
|
|
2976
3149
|
diffSource: options.generatorRawSource,
|
|
2977
3150
|
generatorTarget: generated.target,
|
|
@@ -3910,12 +4083,12 @@ function createUniAppXNativeHmrReloader(options) {
|
|
|
3910
4083
|
return runtimeClassSet;
|
|
3911
4084
|
}
|
|
3912
4085
|
async function refreshBaseline() {
|
|
3913
|
-
return remember(await options.ensureRuntimeClassSet(
|
|
4086
|
+
return remember(await options.ensureRuntimeClassSet());
|
|
3914
4087
|
}
|
|
3915
4088
|
async function handleHotUpdate(ctx) {
|
|
3916
4089
|
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
3917
4090
|
await options.syncSourceCandidates?.(ctx);
|
|
3918
|
-
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(
|
|
4091
|
+
const currentRuntimeClassSet = await options.ensureRuntimeClassSet();
|
|
3919
4092
|
const hasRuntimeClassChange = previousRuntimeClassSet !== void 0 && (currentRuntimeClassSet.size !== previousRuntimeClassSet.size || [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate)));
|
|
3920
4093
|
remember(currentRuntimeClassSet);
|
|
3921
4094
|
const cssModules = ctx.server?.moduleGraph ? await resolveHotTailwindCssModules(ctx, /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles])) : [];
|
|
@@ -4168,7 +4341,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
4168
4341
|
//#region src/uni-app-x/vite.ts
|
|
4169
4342
|
let transformUVuePromise;
|
|
4170
4343
|
function loadTransformUVue() {
|
|
4171
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
4344
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-D0NXKPmD.js").then((mod) => mod.transformUVue));
|
|
4172
4345
|
return transformUVuePromise;
|
|
4173
4346
|
}
|
|
4174
4347
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -4335,10 +4508,8 @@ function createUniAppXPlugins(options) {
|
|
|
4335
4508
|
harmonyApply.rememberSource(code, id, true);
|
|
4336
4509
|
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
4337
4510
|
const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
|
|
4338
|
-
const
|
|
4339
|
-
const
|
|
4340
|
-
const moduleGraphCandidates = enableComponentLocalStyle || enablePageLocalStyle ? await registerModuleGraphCandidates?.(id, code) : void 0;
|
|
4341
|
-
const runtimeSet = await ensureRuntimeClassSet(shouldForceRefresh);
|
|
4511
|
+
const moduleGraphCandidates = await registerModuleGraphCandidates?.(id, code);
|
|
4512
|
+
const runtimeSet = await ensureRuntimeClassSet();
|
|
4342
4513
|
const currentRuntimeSet = moduleGraphCandidates?.size ? /* @__PURE__ */ new Set([...runtimeSet, ...moduleGraphCandidates]) : runtimeSet;
|
|
4343
4514
|
nativeHmrReloader.remember(currentRuntimeSet);
|
|
4344
4515
|
const transformUVue = await loadTransformUVue();
|
|
@@ -4372,9 +4543,10 @@ function createUniAppXPlugins(options) {
|
|
|
4372
4543
|
const file = cleanUrl$1(id);
|
|
4373
4544
|
const pending = transformSfc(code, id, context);
|
|
4374
4545
|
pendingSfcTransforms.set(file, pending);
|
|
4375
|
-
|
|
4546
|
+
const cleanup = () => {
|
|
4376
4547
|
if (pendingSfcTransforms.get(file) === pending) pendingSfcTransforms.delete(file);
|
|
4377
|
-
}
|
|
4548
|
+
};
|
|
4549
|
+
pending.then(cleanup, cleanup);
|
|
4378
4550
|
return pending;
|
|
4379
4551
|
}
|
|
4380
4552
|
const nvuePlugin = {
|
|
@@ -4403,13 +4575,6 @@ function createUniAppXPlugins(options) {
|
|
|
4403
4575
|
return webLocalStyle.handleHotUpdate(ctx) ?? nativeHmrReloader.handleHotUpdate(ctx);
|
|
4404
4576
|
}
|
|
4405
4577
|
},
|
|
4406
|
-
async watchChange(id) {
|
|
4407
|
-
if (!isEnabled()) return;
|
|
4408
|
-
const resolvedConfig = getResolvedConfig();
|
|
4409
|
-
if (resolvedConfig?.command !== "build" || !resolvedConfig.build?.watch) return;
|
|
4410
|
-
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
4411
|
-
await ensureRuntimeClassSet(true);
|
|
4412
|
-
},
|
|
4413
4578
|
buildEnd() {
|
|
4414
4579
|
if (isWebGeneratorTarget()) webCssEntryDiagnostics?.flush();
|
|
4415
4580
|
},
|
|
@@ -4619,6 +4784,14 @@ function logBundleProcessPlan(options) {
|
|
|
4619
4784
|
}
|
|
4620
4785
|
//#endregion
|
|
4621
4786
|
//#region src/bundlers/vite/generate-bundle/remembered-css-replay.ts
|
|
4787
|
+
function dedupeRememberedCssReplayGroup(group) {
|
|
4788
|
+
const bySourceAndOutput = /* @__PURE__ */ new Map();
|
|
4789
|
+
for (const item of group) {
|
|
4790
|
+
const sourceKey = `${normalizeOutputPathKey(item.remembered.sourceFile)}\0${normalizeOutputPathKey(item.remembered.outputFile)}`;
|
|
4791
|
+
bySourceAndOutput.set(sourceKey, item);
|
|
4792
|
+
}
|
|
4793
|
+
return [...bySourceAndOutput.values()];
|
|
4794
|
+
}
|
|
4622
4795
|
function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
4623
4796
|
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
4624
4797
|
return (SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) || isSourcePreprocessorRequest(sourceFile)) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
@@ -4651,7 +4824,7 @@ async function processRememberedCssReplay(options) {
|
|
|
4651
4824
|
const outputFile = resolveRememberedCssReplayOutputFile(rememberedOutputFile, frameworkRootImportShellTargetByFile);
|
|
4652
4825
|
if (outputFile !== rememberedOutputFile) debug("css replay use framework root import shell target: %s -> %s", rememberedOutputFile, outputFile);
|
|
4653
4826
|
if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
|
|
4654
|
-
const replayableRememberedGroup = rememberedGroup.filter(({ remembered }) => {
|
|
4827
|
+
const replayableRememberedGroup = (rememberedGroup.length > 1 ? dedupeRememberedCssReplayGroup(rememberedGroup) : rememberedGroup).filter(({ remembered }) => {
|
|
4655
4828
|
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
4656
4829
|
if (shouldSkip) debug("css replay skip raw source style: %s -> %s", remembered.sourceFile, outputFile);
|
|
4657
4830
|
return !shouldSkip;
|
|
@@ -4660,7 +4833,7 @@ async function processRememberedCssReplay(options) {
|
|
|
4660
4833
|
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
4661
4834
|
if (!rememberedCssSource) continue;
|
|
4662
4835
|
const { sourceFile } = rememberedCssSource;
|
|
4663
|
-
if (normalizedBundleFiles.has(normalizeOutputPathKey(rememberedOutputFile)) || normalizedBundleFiles.has(normalizeOutputPathKey(sourceFile)) || bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
4836
|
+
if (activeViteCssCacheFiles.has(`planned:${normalizeViteCssCacheKey?.(outputFile) ?? normalizeOutputPathKey(outputFile)}`) || normalizedBundleFiles.has(normalizeOutputPathKey(rememberedOutputFile)) || normalizedBundleFiles.has(normalizeOutputPathKey(sourceFile)) || bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
4664
4837
|
const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : normalizeMiniProgramImportShell(rememberedCssSource.rawSource, {
|
|
4665
4838
|
cssOnly: true,
|
|
4666
4839
|
outputFile,
|
|
@@ -4670,17 +4843,38 @@ async function processRememberedCssReplay(options) {
|
|
|
4670
4843
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4671
4844
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
4672
4845
|
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
4846
|
+
const ownedSources = replayableRememberedGroup.map((item) => item.remembered);
|
|
4847
|
+
const hasScopedSources = hasScopedSourceDirectives(ownedSources);
|
|
4673
4848
|
const cssHandlerOptions = {
|
|
4674
4849
|
...getCssHandlerOptions(sourceFile),
|
|
4675
|
-
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
4850
|
+
isMainChunk: outputCssHandlerOptions.isMainChunk,
|
|
4851
|
+
...hasScopedSources ? { sourceOptions: {
|
|
4852
|
+
...getCssHandlerOptions(sourceFile).sourceOptions,
|
|
4853
|
+
cssEntries: ownedSources.map((source) => source.sourceFile),
|
|
4854
|
+
cssSources: ownedSources.map((source) => ({
|
|
4855
|
+
file: source.sourceFile,
|
|
4856
|
+
base: sourcePathApi(source.sourceFile).dirname(source.sourceFile),
|
|
4857
|
+
css: source.rawSource
|
|
4858
|
+
}))
|
|
4859
|
+
} } : {}
|
|
4676
4860
|
};
|
|
4677
|
-
const scopedSourceCandidateGetter = createScopedSourceCandidateGetter(outputFile, cssHandlerOptions);
|
|
4678
|
-
const scopedSourceCandidateSourceGetter = createScopedSourceCandidateSourceGetter(outputFile, cssHandlerOptions);
|
|
4679
|
-
const
|
|
4680
|
-
|
|
4861
|
+
const scopedSourceCandidateGetter = createScopedSourceCandidateGetter(outputFile, cssHandlerOptions, sourceFile);
|
|
4862
|
+
const scopedSourceCandidateSourceGetter = createScopedSourceCandidateSourceGetter(outputFile, cssHandlerOptions, sourceFile);
|
|
4863
|
+
const signatureSources = hasScopedSources ? ownedSources : [{
|
|
4864
|
+
rawSource: generatorRawSource,
|
|
4865
|
+
sourceFile
|
|
4866
|
+
}];
|
|
4867
|
+
const scopedGeneratorRuntime = hasScopedSources ? new Set((await Promise.all(signatureSources.map((source) => createScopedGeneratorRuntime(outputFile, cssHandlerOptions, generatorRuntime, source.rawSource, source.sourceFile, true)))).flatMap((candidates) => [...candidates])) : await createScopedGeneratorRuntime(outputFile, cssHandlerOptions, generatorRuntime, generatorRawSource, sourceFile);
|
|
4868
|
+
const candidateSignatures = hasScopedSources ? await Promise.all(signatureSources.map(async (source) => [source.sourceFile, await createScopedGeneratorCandidateSignature(source.rawSource, source.sourceFile, createCandidateSignature(scopedGeneratorRuntime), scopedSourceCandidateGetter, {
|
|
4869
|
+
includeFallbackSignature: cssHandlerOptions.isMainChunk,
|
|
4870
|
+
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
4871
|
+
scopeToSource: true
|
|
4872
|
+
})])) : void 0;
|
|
4873
|
+
const scopedGeneratorCandidateSignature = hasScopedSources ? JSON.stringify(candidateSignatures) : await createScopedGeneratorCandidateSignature(generatorRawSource, sourceFile, createCandidateSignature(scopedGeneratorRuntime), scopedSourceCandidateGetter, {
|
|
4681
4874
|
includeFallbackSignature: cssHandlerOptions.isMainChunk,
|
|
4682
4875
|
majorVersion: runtimeState.tailwindRuntime.majorVersion
|
|
4683
|
-
})
|
|
4876
|
+
});
|
|
4877
|
+
const cssRuntimeSignature = createCssRuntimeSignature(createCandidateSignature(scopedGeneratorRuntime), scopedGeneratorCandidateSignature);
|
|
4684
4878
|
const cssRuntimeAffectingHash = cache.computeHash(createRuntimeAffectingSourceSignature(rawSource, "css"));
|
|
4685
4879
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
|
|
4686
4880
|
const rawSourceHash = cache.computeHash(rawSource);
|
|
@@ -4693,7 +4887,7 @@ async function processRememberedCssReplay(options) {
|
|
|
4693
4887
|
activeViteCssCacheFiles.add(generatedReplayKey);
|
|
4694
4888
|
const cachedGeneratedReplayCss = allRememberedSignaturesFresh && shouldMergeReplayIntoFrameworkRootTarget ? lastCssResultByFile.get(generatedReplayKey) : void 0;
|
|
4695
4889
|
if (allRememberedSignaturesFresh && !shouldMergeReplayIntoFrameworkRootTarget) continue;
|
|
4696
|
-
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
4890
|
+
const sourceTraceSources = scopedSourceCandidateSourceGetter ? hasScopedSources ? await createMergedCssSourceTraceMap(signatureSources, (source) => createScopedGeneratorSourceTraceMap(source.rawSource, source.sourceFile, scopedSourceCandidateSourceGetter, { scopeToSource: true })) : await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
4697
4891
|
const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
4698
4892
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
4699
4893
|
opts,
|
|
@@ -5004,6 +5198,26 @@ function rememberRuntimeLinkedCssSources(options) {
|
|
|
5004
5198
|
}
|
|
5005
5199
|
}
|
|
5006
5200
|
//#endregion
|
|
5201
|
+
//#region src/bundlers/vite/generate-bundle/scoped-generator-runtime-cache.ts
|
|
5202
|
+
/** 缓存仅属于单轮 generateBundle,不跨候选或配置更新复用。 */
|
|
5203
|
+
function memoizeScopedGeneratorRuntime(resolve) {
|
|
5204
|
+
const byRuntime = /* @__PURE__ */ new WeakMap();
|
|
5205
|
+
return (outputFile, options, runtime, rawSource, sourceFile, scopeToSource) => {
|
|
5206
|
+
if (rawSource === void 0 || sourceFile === void 0) return resolve(outputFile, options, runtime, rawSource, sourceFile, scopeToSource);
|
|
5207
|
+
let cache = byRuntime.get(runtime);
|
|
5208
|
+
if (!cache) {
|
|
5209
|
+
cache = /* @__PURE__ */ new Map();
|
|
5210
|
+
byRuntime.set(runtime, cache);
|
|
5211
|
+
}
|
|
5212
|
+
const key = `${outputFile}\0${sourceFile}\0${options.isMainChunk === true ? "main" : "scoped"}\0${scopeToSource === true ? "source" : "runtime"}\0${rawSource}`;
|
|
5213
|
+
const cached = cache.get(key);
|
|
5214
|
+
if (cached) return cached;
|
|
5215
|
+
const pending = resolve(outputFile, options, runtime, rawSource, sourceFile, scopeToSource);
|
|
5216
|
+
cache.set(key, pending);
|
|
5217
|
+
return pending;
|
|
5218
|
+
};
|
|
5219
|
+
}
|
|
5220
|
+
//#endregion
|
|
5007
5221
|
//#region src/bundlers/vite/generate-bundle/source-candidate-scope.ts
|
|
5008
5222
|
function intersectCandidateSets(left, right) {
|
|
5009
5223
|
if (left.size === 0 || right.size === 0) return /* @__PURE__ */ new Set();
|
|
@@ -5080,9 +5294,14 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
5080
5294
|
}];
|
|
5081
5295
|
};
|
|
5082
5296
|
const shouldExcludeSubpackageSourceCandidates = (outputFile, cssHandlerOptions) => cssHandlerOptions.isMainChunk === true && subpackageSourceExcludeEntries.length > 0 && isMainPackageStyleOutputFile(outputFile);
|
|
5083
|
-
const
|
|
5297
|
+
const resolveScopedOutputFile = (outputFile, sourceFile) => {
|
|
5298
|
+
if (!options.subpackageRoots || isSubpackageOutputFile(outputFile, options.subpackageRoots)) return outputFile;
|
|
5299
|
+
return sourceFile && isSubpackageOutputFile(sourceFile, options.subpackageRoots) ? sourceFile : outputFile;
|
|
5300
|
+
};
|
|
5301
|
+
const createScopedSourceCandidateGetter = (outputFile, cssHandlerOptions, sourceFile) => {
|
|
5084
5302
|
if (!options.getSourceCandidatesForEntries) return;
|
|
5085
|
-
const
|
|
5303
|
+
const scopedOutputFile = resolveScopedOutputFile(outputFile, sourceFile);
|
|
5304
|
+
const subpackageEntries = resolveSubpackageOutputSourceEntries(scopedOutputFile);
|
|
5086
5305
|
if (subpackageEntries) return (entries, filterOptions) => {
|
|
5087
5306
|
if (entries !== void 0) {
|
|
5088
5307
|
const scopedCandidates = options.getSourceCandidatesForEntries?.(entries, filterOptions) ?? /* @__PURE__ */ new Set();
|
|
@@ -5100,9 +5319,10 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
5100
5319
|
excludeEntries: [...filterOptions?.excludeEntries ?? [], ...subpackageSourceExcludeEntries]
|
|
5101
5320
|
}) ?? /* @__PURE__ */ new Set();
|
|
5102
5321
|
};
|
|
5103
|
-
const createScopedSourceCandidateSourceGetter = (outputFile, cssHandlerOptions) => {
|
|
5322
|
+
const createScopedSourceCandidateSourceGetter = (outputFile, cssHandlerOptions, sourceFile) => {
|
|
5104
5323
|
if (!options.getSourceCandidateSourcesForEntries) return;
|
|
5105
|
-
const
|
|
5324
|
+
const scopedOutputFile = resolveScopedOutputFile(outputFile, sourceFile);
|
|
5325
|
+
const subpackageEntries = resolveSubpackageOutputSourceEntries(scopedOutputFile);
|
|
5106
5326
|
if (subpackageEntries) return (entries, filterOptions) => {
|
|
5107
5327
|
if (entries !== void 0) {
|
|
5108
5328
|
const scopedSources = options.getSourceCandidateSourcesForEntries?.(entries, filterOptions) ?? /* @__PURE__ */ new Map();
|
|
@@ -5210,69 +5430,6 @@ function resolveCurrentSourceCandidateSource(options) {
|
|
|
5210
5430
|
return bestSource?.source;
|
|
5211
5431
|
}
|
|
5212
5432
|
//#endregion
|
|
5213
|
-
//#region src/bundlers/vite/generate-bundle/temporary-css-assets.ts
|
|
5214
|
-
function shouldQueueTemporarySource(entry, options) {
|
|
5215
|
-
return normalizeOutputPathKey(entry.outputFile).includes("/") || options.explicitSourceFileKeys.has(options.normalizeConfiguredSourceFile(entry.file)) && options.shouldSelectConfiguredRootOutput(entry.outputFile);
|
|
5216
|
-
}
|
|
5217
|
-
function collectTemporaryCssSourceEntries(options) {
|
|
5218
|
-
const runtimeLinkedEntries = [...options.runtimeLinkedCssFiles].map((file) => options.resolveRuntimeLinkedSource(file)).filter((entry) => entry != null && options.currentSubpackageRoots != null && shouldQueueTemporarySource(entry, options));
|
|
5219
|
-
const rememberedEntries = options.rememberedEntries.filter((entry) => shouldQueueTemporarySource(entry, options));
|
|
5220
|
-
const configuredEntries = options.configuredEntries.filter((entry) => normalizeOutputPathKey(entry.outputFile).includes("/") || shouldQueueTemporarySource(entry, options));
|
|
5221
|
-
const scopedEntries = options.currentSubpackageRoots ? options.configuredScopeEntries.filter((entry) => options.isSubpackageOutputFile(entry.outputFile, options.currentSubpackageRoots)) : [];
|
|
5222
|
-
return [
|
|
5223
|
-
...runtimeLinkedEntries,
|
|
5224
|
-
...rememberedEntries,
|
|
5225
|
-
...configuredEntries,
|
|
5226
|
-
...scopedEntries
|
|
5227
|
-
];
|
|
5228
|
-
}
|
|
5229
|
-
function isTemporaryCssAssetFile(file) {
|
|
5230
|
-
const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
5231
|
-
return /\.css$/i.test(normalized) && !normalized.includes("/");
|
|
5232
|
-
}
|
|
5233
|
-
function normalizeCssSourceKey(file) {
|
|
5234
|
-
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
5235
|
-
}
|
|
5236
|
-
function createTemporaryCssAssetSourceResolver(entries) {
|
|
5237
|
-
const seenEntryFiles = /* @__PURE__ */ new Set();
|
|
5238
|
-
const queuedEntries = entries.filter((entry) => {
|
|
5239
|
-
const entryFile = normalizeCssSourceKey(entry.file);
|
|
5240
|
-
if (normalizeCssSourceKey(entry.outputFile) === entryFile || seenEntryFiles.has(entryFile)) return false;
|
|
5241
|
-
seenEntryFiles.add(entryFile);
|
|
5242
|
-
return true;
|
|
5243
|
-
});
|
|
5244
|
-
const usedEntryFiles = /* @__PURE__ */ new Set();
|
|
5245
|
-
return {
|
|
5246
|
-
entries: queuedEntries,
|
|
5247
|
-
markUsed(sourceFile) {
|
|
5248
|
-
if (!sourceFile) return;
|
|
5249
|
-
usedEntryFiles.add(normalizeCssSourceKey(sourceFile));
|
|
5250
|
-
},
|
|
5251
|
-
resolve(outputFile, rawSource) {
|
|
5252
|
-
if (!isTemporaryCssAssetFile(outputFile)) return;
|
|
5253
|
-
const outputFileKey = normalizeCssSourceKey(outputFile);
|
|
5254
|
-
const unusedEntries = queuedEntries.filter((item) => !usedEntryFiles.has(normalizeCssSourceKey(item.file)));
|
|
5255
|
-
const matchedOutputEntries = unusedEntries.filter((item) => normalizeCssSourceKey(item.outputFile) === outputFileKey);
|
|
5256
|
-
const usesMatchedOutputEntries = matchedOutputEntries.length > 0;
|
|
5257
|
-
const availableEntries = matchedOutputEntries.length > 0 ? matchedOutputEntries : unusedEntries.filter((item) => normalizeCssSourceKey(item.outputFile).includes("/"));
|
|
5258
|
-
const scoredEntries = rawSource ? availableEntries.map((entry) => ({
|
|
5259
|
-
entry,
|
|
5260
|
-
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
5261
|
-
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score) : [];
|
|
5262
|
-
const bestScore = scoredEntries[0]?.score;
|
|
5263
|
-
const bestEntries = bestScore ? scoredEntries.filter((item) => item.score === bestScore) : [];
|
|
5264
|
-
const entry = bestEntries.length === 1 ? bestEntries[0]?.entry : usesMatchedOutputEntries || rawSource == null ? availableEntries.find((item) => hasTailwindGenerationSource(item.source)) : void 0;
|
|
5265
|
-
if (!entry) return;
|
|
5266
|
-
usedEntryFiles.add(normalizeCssSourceKey(entry.file));
|
|
5267
|
-
return {
|
|
5268
|
-
outputFile: entry.outputFile,
|
|
5269
|
-
rawSource: entry.source,
|
|
5270
|
-
sourceFile: entry.file
|
|
5271
|
-
};
|
|
5272
|
-
}
|
|
5273
|
-
};
|
|
5274
|
-
}
|
|
5275
|
-
//#endregion
|
|
5276
5433
|
//#region src/bundlers/vite/generate-bundle/timing.ts
|
|
5277
5434
|
function createBundleTaskTimer(recordTimingDetail) {
|
|
5278
5435
|
return async (name, task) => {
|
|
@@ -5533,17 +5690,18 @@ function createGenerateBundleHook$1(context) {
|
|
|
5533
5690
|
tailwindcssBasedir: opts.tailwindcssBasedir,
|
|
5534
5691
|
useIncrementalMode
|
|
5535
5692
|
});
|
|
5536
|
-
const createScopedGeneratorRuntime$1 = (outputFile, cssHandlerOptions2, runtime2, rawSource, sourceFile) => createScopedGeneratorRuntime({
|
|
5693
|
+
const createScopedGeneratorRuntime$1 = memoizeScopedGeneratorRuntime((outputFile, cssHandlerOptions2, runtime2, rawSource, sourceFile, scopeToSource) => createScopedGeneratorRuntime({
|
|
5537
5694
|
cssHandlerOptions: cssHandlerOptions2,
|
|
5538
5695
|
fallbackRuntime: runtime2,
|
|
5539
5696
|
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5540
5697
|
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
5541
5698
|
outputFile,
|
|
5542
5699
|
rawSource,
|
|
5700
|
+
scopeToSource,
|
|
5543
5701
|
shouldExcludeSubpackageSourceCandidates,
|
|
5544
5702
|
sourceFile,
|
|
5545
|
-
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile, cssHandlerOptions2)
|
|
5546
|
-
});
|
|
5703
|
+
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile, cssHandlerOptions2, sourceFile)
|
|
5704
|
+
}));
|
|
5547
5705
|
const jsEntries = snapshot.jsEntries;
|
|
5548
5706
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
5549
5707
|
const transformFilterSignature = createTransformFilterSignature(opts.transform);
|
|
@@ -6106,7 +6264,7 @@ function linkEntryChunkStyles(bundle, options) {
|
|
|
6106
6264
|
//#endregion
|
|
6107
6265
|
//#region src/bundlers/vite/css-finalizer/final-assets.ts
|
|
6108
6266
|
/** 按生成目标统一收尾已组装的 CSS 资产,供空资产和常规分支复用。 */
|
|
6109
|
-
function finalizeCssAssets(bundle, context, isWebGeneratorTarget, files) {
|
|
6267
|
+
async function finalizeCssAssets(bundle, context, isWebGeneratorTarget, files) {
|
|
6110
6268
|
if (isWebGeneratorTarget) return finalizeWebCssCalc(bundle, context);
|
|
6111
6269
|
finalizeMiniProgramCssAssetStructures(bundle, {
|
|
6112
6270
|
cssMatcher: context.opts.cssMatcher,
|
|
@@ -6116,6 +6274,7 @@ function finalizeCssAssets(bundle, context, isWebGeneratorTarget, files) {
|
|
|
6116
6274
|
onUpdate: context.opts.onUpdate,
|
|
6117
6275
|
recordCssAssetResult: context.recordCssAssetResult
|
|
6118
6276
|
});
|
|
6277
|
+
await finalizeCssCalc(bundle, context, true);
|
|
6119
6278
|
}
|
|
6120
6279
|
//#endregion
|
|
6121
6280
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
@@ -6457,6 +6616,42 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6457
6616
|
};
|
|
6458
6617
|
}
|
|
6459
6618
|
//#endregion
|
|
6619
|
+
//#region src/bundlers/vite/runtime-class-set/invalidation-plugin.ts
|
|
6620
|
+
/** 在框架的前置 SFC HMR 转换之前标记变更,刷新由下一次集合读取合并执行。 */
|
|
6621
|
+
function createRuntimeClassSetInvalidationPlugin(options) {
|
|
6622
|
+
const invalidate = (id) => {
|
|
6623
|
+
if (options.isEnabled() && options.isRelevant(id)) options.invalidate();
|
|
6624
|
+
};
|
|
6625
|
+
return {
|
|
6626
|
+
name: "weapp-tailwindcss:runtime-invalidation",
|
|
6627
|
+
enforce: "pre",
|
|
6628
|
+
watchChange: invalidate,
|
|
6629
|
+
handleHotUpdate: {
|
|
6630
|
+
order: "pre",
|
|
6631
|
+
handler(ctx) {
|
|
6632
|
+
invalidate(ctx.file);
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
};
|
|
6636
|
+
}
|
|
6637
|
+
//#endregion
|
|
6638
|
+
//#region src/bundlers/vite/runtime-class-set/lifecycle.ts
|
|
6639
|
+
/** 将失效通知放在框架前置钩子之前,释放钩子放在框架插件之后。 */
|
|
6640
|
+
function installRuntimeClassSetLifecycle(options) {
|
|
6641
|
+
if (options.uniAppX) options.plugins.unshift(createRuntimeClassSetInvalidationPlugin(options));
|
|
6642
|
+
options.plugins.push({
|
|
6643
|
+
name: "weapp-tailwindcss:runtime-dispose",
|
|
6644
|
+
closeWatcher: options.dispose,
|
|
6645
|
+
closeBundle() {
|
|
6646
|
+
const config = options.getResolvedConfig();
|
|
6647
|
+
if (!config?.build?.watch && config?.command !== "serve") options.dispose();
|
|
6648
|
+
},
|
|
6649
|
+
configureServer(server) {
|
|
6650
|
+
server.httpServer?.once("close", options.dispose);
|
|
6651
|
+
}
|
|
6652
|
+
});
|
|
6653
|
+
}
|
|
6654
|
+
//#endregion
|
|
6460
6655
|
//#region src/bundlers/vite/serve-js-transform.ts
|
|
6461
6656
|
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
6462
6657
|
function isViteServeJsRequest(id, command) {
|
|
@@ -6721,6 +6916,7 @@ function resolveFrameworkStylePlatform(opts, outDir) {
|
|
|
6721
6916
|
//#endregion
|
|
6722
6917
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
6723
6918
|
function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
6919
|
+
let previousBuildConsumedTailwindCss = false;
|
|
6724
6920
|
const shouldSkipSourceCandidateState = () => options.shouldSkipSourceCandidateState?.() === true;
|
|
6725
6921
|
const hasDifferentHotModules = (left, right) => left.length !== right.length || left.some((mod, index) => mod !== right[index]);
|
|
6726
6922
|
const hasTemplateHotSourceModule = (modules) => modules.some((mod) => {
|
|
@@ -6925,9 +7121,26 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
6925
7121
|
async buildStart() {
|
|
6926
7122
|
if (shouldSkipSourceCandidateState()) return;
|
|
6927
7123
|
await options.hmrTimingRecorder.measure("sourceCandidates.buildStart", options.prepareTailwindGeneration, { emit: false });
|
|
7124
|
+
if (previousBuildConsumedTailwindCss) for (const file of options.sourceScanSession.getWatchFiles?.() ?? []) this.addWatchFile(file);
|
|
7125
|
+
},
|
|
7126
|
+
async moduleParsed(module) {
|
|
7127
|
+
if (shouldSkipSourceCandidateState()) return;
|
|
7128
|
+
if (options.tailwindRootCssModuleIds?.has(module.id)) {
|
|
7129
|
+
await options.prepareTailwindGeneration();
|
|
7130
|
+
for (const file of options.sourceScanSession.getWatchFiles?.() ?? []) this.addWatchFile(file);
|
|
7131
|
+
}
|
|
7132
|
+
},
|
|
7133
|
+
async shouldTransformCachedModule(module) {
|
|
7134
|
+
if (!shouldSkipSourceCandidateState() && options.tailwindRootCssModuleIds?.has(module.id)) {
|
|
7135
|
+
await options.prepareTailwindGeneration();
|
|
7136
|
+
for (const file of options.sourceScanSession.getWatchFiles?.() ?? []) this.addWatchFile(file);
|
|
7137
|
+
}
|
|
7138
|
+
return null;
|
|
6928
7139
|
},
|
|
6929
7140
|
async generateBundle(...args) {
|
|
6930
7141
|
if (shouldSkipSourceCandidateState()) return;
|
|
7142
|
+
const roots = options.tailwindRootCssModuleIds;
|
|
7143
|
+
previousBuildConsumedTailwindCss = Boolean(roots && [...roots].some((id) => this.getModuleInfo?.(id) != null));
|
|
6931
7144
|
return options.preGenerateBundleHook?.apply(this, args);
|
|
6932
7145
|
}
|
|
6933
7146
|
};
|
|
@@ -6949,7 +7162,10 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
6949
7162
|
...options,
|
|
6950
7163
|
__internalDeferMissingCssEntriesWarning: true
|
|
6951
7164
|
};
|
|
6952
|
-
|
|
7165
|
+
let resolvedConfig;
|
|
7166
|
+
const originalOpts = isInternalUserDefinedOptions(options) ? options : getCompilerContext(deferredOptions);
|
|
7167
|
+
const cssCalcStage = createViteCssCalcStage(originalOpts, () => resolvedConfig?.command === "build", () => resolveFrameworkStylePlatform(originalOpts, resolvedConfig?.build?.outDir));
|
|
7168
|
+
const opts = cssCalcStage.options;
|
|
6953
7169
|
const syncCssEntriesFromAnchor = createFrameworkCssEntrySync(opts, rawCssEntries);
|
|
6954
7170
|
syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
|
|
6955
7171
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler, styleInjector } = opts;
|
|
@@ -6962,7 +7178,6 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
6962
7178
|
const tailwindcssMajorVersion = initialTailwindRuntime.majorVersion ?? 0;
|
|
6963
7179
|
if (!disabledOptions.plugin && tailwindcssMajorVersion !== 4) throw new Error("weapp-tailwindcss/vite 新生成管线仅支持 Tailwind CSS v4,请升级 tailwindcss 或停留在旧版 weapp-tailwindcss。");
|
|
6964
7180
|
const shouldRewriteCssImports = opts.rewriteCssImports === true;
|
|
6965
|
-
let resolvedConfig;
|
|
6966
7181
|
const { observer: webCssEntryDiagnostics, plugin: webCssEntryObserverPlugin } = createConfiguredCssEntryDiagnostics({
|
|
6967
7182
|
getEntries: () => opts.cssEntries,
|
|
6968
7183
|
getRoot: () => resolvedConfig?.root,
|
|
@@ -7114,7 +7329,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7114
7329
|
debug,
|
|
7115
7330
|
getSourceCandidateSource: (file) => sourceCandidateCollector.source(file)
|
|
7116
7331
|
});
|
|
7117
|
-
const { runtimeState, refreshRuntimeState, ensureRuntimeClassSet, ensureBundleRuntimeClassSet } = createViteRuntimeClassSet({
|
|
7332
|
+
const { runtimeState, refreshRuntimeState, invalidateRuntimeClassSet, ensureRuntimeClassSet, ensureBundleRuntimeClassSet } = createViteRuntimeClassSet({
|
|
7118
7333
|
opts,
|
|
7119
7334
|
initialTailwindRuntime,
|
|
7120
7335
|
refreshTailwindcssRuntime: refreshTailwindRuntime,
|
|
@@ -7507,6 +7722,7 @@ ${tracedCss}${currentGeneratorBranch.isWeb ? `\n${createBundlerGeneratedCssEndMa
|
|
|
7507
7722
|
});
|
|
7508
7723
|
const cssFinalizerContext = {
|
|
7509
7724
|
opts,
|
|
7725
|
+
getFinalCssCalcOptions: cssCalcStage.getFinalOptions,
|
|
7510
7726
|
runtimeState,
|
|
7511
7727
|
ensureRuntimeClassSet,
|
|
7512
7728
|
cssPipelineStrategy: frameworkCssPipelineStrategy,
|
|
@@ -7682,6 +7898,15 @@ ${tracedCss}${currentGeneratorBranch.isWeb ? `\n${createBundlerGeneratedCssEndMa
|
|
|
7682
7898
|
}],
|
|
7683
7899
|
postPlugin
|
|
7684
7900
|
];
|
|
7901
|
+
installRuntimeClassSetLifecycle({
|
|
7902
|
+
plugins,
|
|
7903
|
+
uniAppX: frameworkBranch.frameworkName === "uni-app-x",
|
|
7904
|
+
invalidate: invalidateRuntimeClassSet,
|
|
7905
|
+
isEnabled: shouldEnableFrameworkExtraPlugins,
|
|
7906
|
+
isRelevant: (id) => sourceScanSession.isDependency(id) || isSourceCandidateRequest(id),
|
|
7907
|
+
dispose: runtimeState.dispose,
|
|
7908
|
+
getResolvedConfig
|
|
7909
|
+
});
|
|
7685
7910
|
plugins.push(cssFinalizerOutputPlugin);
|
|
7686
7911
|
plugins.push(createViteHmrCssModuleVersionFilterPlugin(hmrCssModuleVersions));
|
|
7687
7912
|
if (capability.styleInjector) plugins.push(...capability.cssOnly && typeof options.__internalViteWebStyleInjectorFactory === "function" ? options.__internalViteWebStyleInjectorFactory(styleInjector) : createBuiltinViteStyleInjectorPlugins(styleInjector, () => frameworkBranch.styleInjectorDelegate));
|