weapp-tailwindcss 5.1.2 → 5.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bundlers/gulp/index.d.ts +3 -3
- package/dist/bundlers/rspack/index.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
- package/dist/bundlers/vite/css-memory.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +12 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -0
- package/dist/bundlers/vite/serve-js-transform.d.ts +11 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +4 -1
- package/dist/cli.js +8 -8
- package/dist/cli.mjs +8 -8
- package/dist/{context-C-r8ki7x.mjs → context-B07Vf584.mjs} +34 -34
- package/dist/{context-CH4HFZP2.js → context-D75pwtBW.js} +43 -43
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/postcss.js +2 -2
- package/dist/css-macro.js +3 -3
- package/dist/{defaults-CmFBmxsr.js → defaults-DQhgnnn-.js} +1 -1
- package/dist/defaults.js +1 -1
- package/dist/framework/index.d.ts +7 -2
- package/dist/framework.js +39 -8
- package/dist/framework.mjs +33 -6
- package/dist/{generator-B6pUjNdD.js → generator-CV_0irKO.js} +2 -2
- package/dist/{generator-BsPIaLtV.mjs → generator-DNs6ekoC.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-BBCeA7ky.js → gulp-B_u8NjQL.js} +9 -9
- package/dist/{gulp-CTdcASq8.mjs → gulp-aQMZ0M7c.mjs} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BRx-KnBh.mjs → hmr-timing-DLYQTCDb.mjs} +25 -22
- package/dist/{hmr-timing-Da1eI8S0.js → hmr-timing-DOoHun3i.js} +28 -25
- package/dist/index.js +9 -4
- package/dist/index.mjs +7 -6
- package/dist/postcss-html-transform.js +2 -2
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets/shared.d.ts +4 -0
- package/dist/presets.js +32 -16
- package/dist/presets.mjs +28 -14
- package/dist/reset.js +2 -2
- package/dist/rspack.d.ts +3 -0
- package/dist/rspack.js +68 -0
- package/dist/rspack.mjs +62 -0
- package/dist/{source-candidate-scan-signature-BO6JSskQ.js → source-candidate-scan-signature-DzwebZrf.js} +6 -6
- package/dist/{source-candidate-scan-signature-Dugfplms.mjs → source-candidate-scan-signature-pS87mdHZ.mjs} +3 -3
- package/dist/{tailwindcss-dbrbY4cd.js → tailwindcss-BSCvrs1p.js} +8 -8
- package/dist/{tailwindcss-B5mRo0-M.mjs → tailwindcss-BwV3_Ryc.mjs} +3 -3
- package/dist/{transform-DeqFRp1D.mjs → transform-Clj7R818.mjs} +19 -19
- package/dist/{transform-BLleu_bA.js → transform-fin-OTVD.js} +47 -47
- package/dist/{utils-BCa37Wqj.js → utils-D3h8j7Mk.js} +2 -2
- package/dist/{v4-engine-C3qSwQ-e.mjs → v4-engine-BklH3CpJ.mjs} +5 -5
- package/dist/{v4-engine-ON_oSLfO.js → v4-engine-CKbS27-o.js} +10 -10
- package/dist/{vite-CXmUiI9f.mjs → vite-5Wn0PIzJ.mjs} +237 -42
- package/dist/{vite-Da4uEG_u.js → vite-CkVMSDDp.js} +242 -47
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +55 -26
- package/dist/weapp-tw-runtime-classset-loader.js +2 -2
- package/dist/{webpack-CrFZmdo7.mjs → webpack-DEag6ueE.mjs} +66 -18
- package/dist/{webpack-Cwqnznng.js → webpack-hvSFaicc.js} +71 -23
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +8 -3
- /package/dist/{chunk-emK7D4bc.js → rolldown-runtime-emK7D4bc.js} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.mjs";
|
|
2
|
-
import { C as hasTailwindRootDirectives, D as normalizeTailwindSourceForGenerator, F as hasTailwindGeneratedCssMarkers, G as getTailwindV4IncrementalGenerateCacheStats, O as parseImportRequest, S as hasTailwindNonRootGenerationDirectives, T as normalizeTailwindConfigDirectives, _ as resolveTailwindcssOptions, a as filterTailwindV4CssSourceRoots, b as hasLocalCssImport, d as normalizeCssEntries, f as findNearestPackageRoot, k as removeTailwindSourceDirectives, o as hasConfiguredTailwindV4CssRoots, ot as filterUnsupportedMiniProgramTailwindV4Candidates, rt as resolveTailwindV4CssSourceBase, s as upsertTailwindV4CssSource, st as omitUndefined, u as isTailwindV4CssEntry, w as hasTailwindSourceDirectives, x as hasTailwindApplyDirective } from "./v4-engine-
|
|
3
|
-
import { a as resolveGeneratorRuntimeBranch, c as shouldUseNativeAppCssBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch } from "./generator-
|
|
2
|
+
import { C as hasTailwindRootDirectives, D as normalizeTailwindSourceForGenerator, F as hasTailwindGeneratedCssMarkers, G as getTailwindV4IncrementalGenerateCacheStats, O as parseImportRequest, S as hasTailwindNonRootGenerationDirectives, T as normalizeTailwindConfigDirectives, _ as resolveTailwindcssOptions, a as filterTailwindV4CssSourceRoots, b as hasLocalCssImport, d as normalizeCssEntries, f as findNearestPackageRoot, k as removeTailwindSourceDirectives, o as hasConfiguredTailwindV4CssRoots, ot as filterUnsupportedMiniProgramTailwindV4Candidates, rt as resolveTailwindV4CssSourceBase, s as upsertTailwindV4CssSource, st as omitUndefined, u as isTailwindV4CssEntry, w as hasTailwindSourceDirectives, x as hasTailwindApplyDirective } from "./v4-engine-BklH3CpJ.mjs";
|
|
3
|
+
import { a as resolveGeneratorRuntimeBranch, c as shouldUseNativeAppCssBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch } from "./generator-DNs6ekoC.mjs";
|
|
4
4
|
import { o as resolveUniUtsPlatform } from "./utils-DodxWHGz.mjs";
|
|
5
|
-
import { S as createDebug, _ as toCustomAttributesEntities, a as vitePluginName, l as shouldSkipJsTransform, m as replaceWxml, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, v as collectRuntimeClassSet, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-
|
|
6
|
-
import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-
|
|
7
|
-
import { A as hasMiniProgramCssSpecificityPlaceholders, F as createCssTokenSourceMap, L as processCachedTask, M as stripMiniProgramCssSpecificityPlaceholders, N as annotateCssSourceTrace, P as createCssSourceTraceCacheSignature, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, d as validateCandidatesByGenerator, g as mergeMarkedUserLayerComponentsCss, h as extractMarkedUserLayerComponentsCss, m as runWithConcurrency, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, t as createHmrTimingRecorder } from "./hmr-timing-
|
|
8
|
-
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, D as isHTMLRequest, E as isCSSRequest, M as normalizeOutputPathKey, O as normalizePath, P as toAbsoluteOutputPath, S as resolvePackageDir, T as formatPostcssSourceMap, _ as generateTailwindV4Css, a as createJsHashSalt, b as parseBundlerGeneratedCssMarkerBlocks, c as hasRuntimeAffectingSourceChanges, f as createBundleBuildState, g as createBundleModuleGraphOptions, h as applyLinkedResults, i as createCandidateSignature, j as stripRequestQuery, k as slash, l as summarizeStringDiff, m as createRuntimeAffectingSourceSignature, n as createScopedGeneratorCandidateSignature, o as createLinkedImpactSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, s as getSnapshotHash, t as createSourceCandidateScanSignature, u as buildBundleSnapshot, v as createBundlerGeneratedCssMarker, w as cleanUrl, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-
|
|
5
|
+
import { S as createDebug, _ as toCustomAttributesEntities, a as vitePluginName, l as shouldSkipJsTransform, m as replaceWxml, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, v as collectRuntimeClassSet, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-B07Vf584.mjs";
|
|
6
|
+
import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-BwV3_Ryc.mjs";
|
|
7
|
+
import { A as hasMiniProgramCssSpecificityPlaceholders, F as createCssTokenSourceMap, L as processCachedTask, M as stripMiniProgramCssSpecificityPlaceholders, N as annotateCssSourceTrace, P as createCssSourceTraceCacheSignature, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, d as validateCandidatesByGenerator, g as mergeMarkedUserLayerComponentsCss, h as extractMarkedUserLayerComponentsCss, m as runWithConcurrency, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, t as createHmrTimingRecorder } from "./hmr-timing-DLYQTCDb.mjs";
|
|
8
|
+
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, D as isHTMLRequest, E as isCSSRequest, M as normalizeOutputPathKey, O as normalizePath, P as toAbsoluteOutputPath, S as resolvePackageDir, T as formatPostcssSourceMap, _ as generateTailwindV4Css, a as createJsHashSalt, b as parseBundlerGeneratedCssMarkerBlocks, c as hasRuntimeAffectingSourceChanges, f as createBundleBuildState, g as createBundleModuleGraphOptions, h as applyLinkedResults, i as createCandidateSignature, j as stripRequestQuery, k as slash, l as summarizeStringDiff, m as createRuntimeAffectingSourceSignature, n as createScopedGeneratorCandidateSignature, o as createLinkedImpactSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, s as getSnapshotHash, t as createSourceCandidateScanSignature, u as buildBundleSnapshot, v as createBundlerGeneratedCssMarker, w as cleanUrl, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-pS87mdHZ.mjs";
|
|
9
9
|
import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
|
|
10
|
-
import fs, { existsSync, realpathSync } from "node:fs";
|
|
10
|
+
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import process$1 from "node:process";
|
|
13
13
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
@@ -250,7 +250,7 @@ const UVUE_TS_RE = /\.uvue\.ts$/;
|
|
|
250
250
|
const JS_RE = /\.js$/;
|
|
251
251
|
const APP_JS_RE = /(?:^|\/)App\.js$/;
|
|
252
252
|
const COMPONENT_JS_RE = /(?:^|\/)components\/.+\.js$/;
|
|
253
|
-
const HARMONY_BUNDLE_MARKER_FILES = new Set([
|
|
253
|
+
const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
|
|
254
254
|
"import/app-service.ets",
|
|
255
255
|
"import/dynamic.ets",
|
|
256
256
|
"uni_modules/oh-package.json5"
|
|
@@ -509,10 +509,10 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
509
509
|
//#region src/uni-app-x/vite.ts
|
|
510
510
|
let transformUVuePromise;
|
|
511
511
|
function loadTransformUVue() {
|
|
512
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
512
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-Clj7R818.mjs").then((mod) => mod.transformUVue));
|
|
513
513
|
return transformUVuePromise;
|
|
514
514
|
}
|
|
515
|
-
const preprocessorLangs = new Set([
|
|
515
|
+
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
516
516
|
"scss",
|
|
517
517
|
"sass",
|
|
518
518
|
"less",
|
|
@@ -683,7 +683,7 @@ function createUniAppXPlugins(options) {
|
|
|
683
683
|
if (isHarmonyTarget) {
|
|
684
684
|
const cssSources = [];
|
|
685
685
|
const applyStyleSources = [...harmonyApplyStyleSources, ...collectUniAppXHarmonyApplyStyleSources(bundle)];
|
|
686
|
-
const applyUtilities = new Set([...harmonyApplyUtilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
686
|
+
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApplyUtilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
687
687
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
688
688
|
const harmonyApplyCssFile = path.resolve(getResolvedConfig()?.root ?? process$1.cwd(), "uni-app-x-harmony-apply.css");
|
|
689
689
|
const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities), this);
|
|
@@ -749,9 +749,31 @@ function collectConfiguredTailwindV4CssSources(opts) {
|
|
|
749
749
|
const runtimeCssSources = opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? [];
|
|
750
750
|
return filterTailwindV4CssSourceRoots([...opts.tailwindcss?.v4?.cssSources ?? [], ...runtimeCssSources]) ?? [];
|
|
751
751
|
}
|
|
752
|
+
function collectExplicitTailwindV4CssEntries(opts) {
|
|
753
|
+
const entries = [
|
|
754
|
+
...opts.cssEntries ?? [],
|
|
755
|
+
...opts.tailwindcss?.v4?.cssEntries ?? [],
|
|
756
|
+
...opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries ?? []
|
|
757
|
+
];
|
|
758
|
+
return [...new Set(entries.filter((entry) => typeof entry === "string" && entry.length > 0))];
|
|
759
|
+
}
|
|
752
760
|
function collectConfiguredTailwindV4CssSourceEntries(opts, fallbackBase) {
|
|
753
761
|
const entries = [];
|
|
754
762
|
const seen = /* @__PURE__ */ new Set();
|
|
763
|
+
const explicitCssEntries = collectExplicitTailwindV4CssEntries(opts);
|
|
764
|
+
for (const cssEntry of explicitCssEntries.length > 1 ? explicitCssEntries : []) {
|
|
765
|
+
if (typeof cssEntry !== "string" || cssEntry.length === 0) continue;
|
|
766
|
+
const resolvedFile = path.isAbsolute(cssEntry) ? path.resolve(cssEntry) : path.resolve(fallbackBase, cssEntry);
|
|
767
|
+
if (!existsSync(resolvedFile)) continue;
|
|
768
|
+
const source = readFileSync(resolvedFile, "utf8");
|
|
769
|
+
const key = `${resolvedFile}\0${source}`;
|
|
770
|
+
if (seen.has(key)) continue;
|
|
771
|
+
seen.add(key);
|
|
772
|
+
entries.push({
|
|
773
|
+
file: resolvedFile,
|
|
774
|
+
source
|
|
775
|
+
});
|
|
776
|
+
}
|
|
755
777
|
for (const cssSource of collectConfiguredTailwindV4CssSources(opts)) {
|
|
756
778
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
|
|
757
779
|
const base = resolveTailwindV4CssSourceBase(cssSource, fallbackBase);
|
|
@@ -1936,7 +1958,7 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
|
|
|
1936
1958
|
const sourceEntries = [];
|
|
1937
1959
|
for (const entry of snapshot.entries) {
|
|
1938
1960
|
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
1939
|
-
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, new Set([root])));
|
|
1961
|
+
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
1940
1962
|
if (!matchedSubpackageRoot) continue;
|
|
1941
1963
|
for (const moduleId of collectChunkModuleIds$2(entry.output)) {
|
|
1942
1964
|
if (!path.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
@@ -2107,6 +2129,14 @@ function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, option
|
|
|
2107
2129
|
const targetFileKey = normalizeOutputPathKey(targetFile);
|
|
2108
2130
|
return normalizeOutputPathKey(sourceFile) !== targetFileKey && (opts.mainCssChunkMatcher(sourceFile, opts.appType) || typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) !== targetFileKey && opts.mainCssChunkMatcher(options.outputFile, opts.appType));
|
|
2109
2131
|
}
|
|
2132
|
+
function shouldReplayViteProcessedCssIntoMainCss(opts, file, sourceFile, outputFile, subpackageRoots) {
|
|
2133
|
+
if (subpackageRoots) {
|
|
2134
|
+
const sourceIsSubpackage = isSubpackageOutputFile(sourceFile ?? file, subpackageRoots);
|
|
2135
|
+
const outputIsSubpackage = isSubpackageOutputFile(outputFile, subpackageRoots);
|
|
2136
|
+
if (sourceIsSubpackage || outputIsSubpackage) return false;
|
|
2137
|
+
}
|
|
2138
|
+
return isRootStyleOutputFile(file) && opts.mainCssChunkMatcher(file, opts.appType) || isSourceRootPrefixedOutputFile(file, outputFile) && isRootStyleOutputFile(outputFile) && opts.mainCssChunkMatcher(outputFile, opts.appType);
|
|
2139
|
+
}
|
|
2110
2140
|
function isRootStyleOutputFile(file) {
|
|
2111
2141
|
const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2112
2142
|
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
@@ -2219,7 +2249,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2219
2249
|
options.markCssAssetProcessed?.(output, file);
|
|
2220
2250
|
options.recordCssAssetResult?.(file, nextCss);
|
|
2221
2251
|
const resolvedOutputFile = options.resolveViteProcessedCssOutputFile?.(file) ?? file;
|
|
2222
|
-
const shouldReplayIntoMainCss = options.opts != null && (
|
|
2252
|
+
const shouldReplayIntoMainCss = options.opts != null && shouldReplayViteProcessedCssIntoMainCss(options.opts, file, singleMarkerFile, resolvedOutputFile, options.subpackageRoots);
|
|
2223
2253
|
options.recordViteProcessedCssAssetResult?.(file, nextCss, {
|
|
2224
2254
|
injectIntoMain: shouldReplayIntoMainCss || void 0,
|
|
2225
2255
|
outputFile: resolvedOutputFile
|
|
@@ -2544,7 +2574,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
2544
2574
|
const generated = await generateTailwindV4Css({
|
|
2545
2575
|
opts,
|
|
2546
2576
|
runtimeState,
|
|
2547
|
-
runtime: new Set([...generatorRuntime, ...applyUtilities]),
|
|
2577
|
+
runtime: /* @__PURE__ */ new Set([...generatorRuntime, ...applyUtilities]),
|
|
2548
2578
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
2549
2579
|
file: outputFile,
|
|
2550
2580
|
outputFile,
|
|
@@ -2793,7 +2823,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
2793
2823
|
pruneLastCssResults(lastCssResultByFile, lastCssSourceHashByFile, activeViteCssCacheFiles);
|
|
2794
2824
|
pruneViteCssCaches?.({
|
|
2795
2825
|
activeFiles: activeViteCssCacheFiles,
|
|
2796
|
-
activeKnownSfcFiles: new Set([...snapshot.sourceHashByFile.keys(), ...snapshot.entries.map((entry) => entry.file)])
|
|
2826
|
+
activeKnownSfcFiles: /* @__PURE__ */ new Set([...snapshot.sourceHashByFile.keys(), ...snapshot.entries.map((entry) => entry.file)])
|
|
2797
2827
|
});
|
|
2798
2828
|
}
|
|
2799
2829
|
recordTimingDetail("state.update", stateUpdateStart);
|
|
@@ -2894,7 +2924,7 @@ function processHtmlBundleEntry(options) {
|
|
|
2894
2924
|
const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
|
|
2895
2925
|
const rawSource = resolveCurrentSourceCandidateSource(file) ?? originalEntrySource;
|
|
2896
2926
|
const currentRawDynamicCandidates = collectUnescapedDynamicCandidates(rawSource);
|
|
2897
|
-
const templateRuntime = currentRawDynamicCandidates.length > 0 ? new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2927
|
+
const templateRuntime = currentRawDynamicCandidates.length > 0 ? /* @__PURE__ */ new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2898
2928
|
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : createCandidateSignature(templateRuntime);
|
|
2899
2929
|
const htmlProcessHash = `${cache.computeHash(rawSource)}:${cache.computeHash(createRuntimeAffectingSourceSignature(rawSource, "html"))}:${templateRuntimeSignature}`;
|
|
2900
2930
|
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
@@ -2920,7 +2950,7 @@ function processHtmlBundleEntry(options) {
|
|
|
2920
2950
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
2921
2951
|
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
2922
2952
|
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
2923
|
-
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
2953
|
+
retryRuntimeSet = /* @__PURE__ */ new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
2924
2954
|
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet?.has(candidate) === true);
|
|
2925
2955
|
}
|
|
2926
2956
|
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
@@ -3135,6 +3165,15 @@ function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffe
|
|
|
3135
3165
|
function normalizeRememberedSourceIdentity(file) {
|
|
3136
3166
|
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3137
3167
|
}
|
|
3168
|
+
function selectBestRememberedCssSourceMatches(sources, outputFile, outputRoot, sourceRoot) {
|
|
3169
|
+
if (sources.length <= 1) return sources;
|
|
3170
|
+
const scoredMatches = sources.map((remembered) => ({
|
|
3171
|
+
remembered,
|
|
3172
|
+
score: Math.max(scoreMatchingStyleFileBase(outputFile, remembered.sourceFile, outputRoot, sourceRoot), scoreMatchingStyleFileBase(outputFile, remembered.outputFile, outputRoot, sourceRoot))
|
|
3173
|
+
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
3174
|
+
const bestScore = scoredMatches[0]?.score;
|
|
3175
|
+
return bestScore ? scoredMatches.filter((match) => match.score === bestScore).map((match) => match.remembered) : sources;
|
|
3176
|
+
}
|
|
3138
3177
|
function findRememberedCssSources(sources, outputFile, file, originalSource, outputRoot, sourceRoot) {
|
|
3139
3178
|
if (!sources) return [];
|
|
3140
3179
|
const rememberedSources = [...sources].map(([, remembered]) => remembered);
|
|
@@ -3142,7 +3181,7 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3142
3181
|
const markerFiles = new Set(parseBundlerGeneratedCssMarkerBlocks(source).filter((block) => block.bundler === "vite" && typeof block.file === "string" && block.file.length > 0).map((block) => normalizeOutputPathKey(block.file)));
|
|
3143
3182
|
if (markerFiles.size > 0) {
|
|
3144
3183
|
const markerMatched = rememberedSources.filter((remembered) => markerFiles.has(normalizeRememberedSourceIdentity(remembered.sourceFile)));
|
|
3145
|
-
if (markerMatched.length > 0) return markerMatched;
|
|
3184
|
+
if (markerMatched.length > 0) return selectBestRememberedCssSourceMatches(markerMatched, outputFile, outputRoot, sourceRoot);
|
|
3146
3185
|
}
|
|
3147
3186
|
const originalFiles = [
|
|
3148
3187
|
file,
|
|
@@ -3154,12 +3193,8 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3154
3193
|
const outputMatched = rememberedSources.filter((remembered) => normalizeOutputPathKey(remembered.outputFile) === normalizeOutputPathKey(outputFile));
|
|
3155
3194
|
if (outputMatched.length > 0) return outputMatched;
|
|
3156
3195
|
if (!hasBundlerGeneratedCssMarker(source) && !hasTailwindGenerationSource(source)) return [];
|
|
3157
|
-
const scoredMatches = rememberedSources
|
|
3158
|
-
|
|
3159
|
-
score: Math.max(scoreMatchingStyleFileBase(outputFile, remembered.sourceFile, outputRoot, sourceRoot), scoreMatchingStyleFileBase(outputFile, remembered.outputFile, outputRoot, sourceRoot))
|
|
3160
|
-
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
3161
|
-
const bestScore = scoredMatches[0]?.score;
|
|
3162
|
-
return bestScore ? scoredMatches.filter((match) => match.score === bestScore).map((match) => match.remembered) : [];
|
|
3196
|
+
const scoredMatches = selectBestRememberedCssSourceMatches(rememberedSources, outputFile, outputRoot, sourceRoot);
|
|
3197
|
+
return scoredMatches.length === rememberedSources.length ? [] : scoredMatches;
|
|
3163
3198
|
}
|
|
3164
3199
|
function mergeRememberedCssSources(sources, outputFile) {
|
|
3165
3200
|
if (sources.length <= 1) return sources[0];
|
|
@@ -3394,7 +3429,7 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3394
3429
|
const isMainPackageStyleOutputFile = (file) => options.subpackageRoots != null && !isSubpackageOutputFile(file, options.subpackageRoots);
|
|
3395
3430
|
const resolveSubpackageOutputSourceEntries = (outputFile) => {
|
|
3396
3431
|
if (!options.subpackageRoots) return;
|
|
3397
|
-
const matchedRoots = [...options.subpackageRoots].filter((root) => isSubpackageOutputFile(outputFile, new Set([root])));
|
|
3432
|
+
const matchedRoots = [...options.subpackageRoots].filter((root) => isSubpackageOutputFile(outputFile, /* @__PURE__ */ new Set([root])));
|
|
3398
3433
|
if (matchedRoots.length !== 1) return;
|
|
3399
3434
|
const root = matchedRoots[0];
|
|
3400
3435
|
if (!root) return;
|
|
@@ -3455,7 +3490,7 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3455
3490
|
excludeEntries: [...filterOptions?.excludeEntries ?? [], ...subpackageSourceExcludeEntries]
|
|
3456
3491
|
}) ?? /* @__PURE__ */ new Map();
|
|
3457
3492
|
};
|
|
3458
|
-
const shouldInjectCssIntoMainFromOutput = (outputFile,
|
|
3493
|
+
const shouldInjectCssIntoMainFromOutput = (outputFile, sourceFile, outputCssHandlerOptions) => outputCssHandlerOptions.isMainChunk === true && !outputFile.replace(/[?#].*$/, "").includes("/") || options.useIncrementalMode && isMainPackageStyleOutputFile(outputFile) && isMainPackageStyleOutputFile(sourceFile);
|
|
3459
3494
|
return {
|
|
3460
3495
|
createScopedSourceCandidateGetter,
|
|
3461
3496
|
createScopedSourceCandidateSourceGetter,
|
|
@@ -3538,7 +3573,7 @@ function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
|
3538
3573
|
}
|
|
3539
3574
|
function resolveSubpackageRootForFile(file, subpackageRoots) {
|
|
3540
3575
|
if (!file || !subpackageRoots) return;
|
|
3541
|
-
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, new Set([root])));
|
|
3576
|
+
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, /* @__PURE__ */ new Set([root])));
|
|
3542
3577
|
}
|
|
3543
3578
|
function isSameSubpackageScope(outputFile, sourceFile, subpackageRoots) {
|
|
3544
3579
|
return resolveSubpackageRootForFile(outputFile, subpackageRoots) === resolveSubpackageRootForFile(sourceFile, subpackageRoots);
|
|
@@ -3561,7 +3596,7 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3561
3596
|
const outputMatchesSubpackage = isSubpackageOutputFile(outputFile, subpackageRoots);
|
|
3562
3597
|
const sourceMatchesSubpackage = isSubpackageOutputFile(entry.file, subpackageRoots);
|
|
3563
3598
|
if (!outputMatchesSubpackage) return !sourceMatchesSubpackage;
|
|
3564
|
-
return sourceMatchesSubpackage && [...subpackageRoots].some((root) => isSubpackageOutputFile(outputFile, new Set([root])) && isSubpackageOutputFile(entry.file, new Set([root])));
|
|
3599
|
+
return sourceMatchesSubpackage && [...subpackageRoots].some((root) => isSubpackageOutputFile(outputFile, /* @__PURE__ */ new Set([root])) && isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
3565
3600
|
}) : generationSources;
|
|
3566
3601
|
const explicitSources = scopedSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3567
3602
|
const candidates = explicitSources.length === 1 ? explicitSources : scopedSources;
|
|
@@ -3569,6 +3604,44 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3569
3604
|
return selectByRawSourceFingerprint(candidates);
|
|
3570
3605
|
}
|
|
3571
3606
|
//#endregion
|
|
3607
|
+
//#region src/bundlers/vite/generate-bundle/temporary-css-assets.ts
|
|
3608
|
+
function isTemporaryCssAssetFile(file) {
|
|
3609
|
+
const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3610
|
+
return /\.css$/i.test(normalized) && !normalized.includes("/");
|
|
3611
|
+
}
|
|
3612
|
+
function normalizeCssSourceKey(file) {
|
|
3613
|
+
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3614
|
+
}
|
|
3615
|
+
function createTemporaryCssAssetSourceResolver(entries) {
|
|
3616
|
+
const seenEntryFiles = /* @__PURE__ */ new Set();
|
|
3617
|
+
const queuedEntries = entries.filter((entry) => {
|
|
3618
|
+
const entryFile = normalizeCssSourceKey(entry.file);
|
|
3619
|
+
const outputFile = normalizeCssSourceKey(entry.outputFile);
|
|
3620
|
+
if (!hasTailwindGenerationSource(entry.source) || outputFile === entryFile || !outputFile.includes("/") || seenEntryFiles.has(entryFile)) return false;
|
|
3621
|
+
seenEntryFiles.add(entryFile);
|
|
3622
|
+
return true;
|
|
3623
|
+
});
|
|
3624
|
+
const usedEntryFiles = /* @__PURE__ */ new Set();
|
|
3625
|
+
return {
|
|
3626
|
+
entries: queuedEntries,
|
|
3627
|
+
markUsed(sourceFile) {
|
|
3628
|
+
if (!sourceFile) return;
|
|
3629
|
+
usedEntryFiles.add(normalizeCssSourceKey(sourceFile));
|
|
3630
|
+
},
|
|
3631
|
+
resolve(outputFile) {
|
|
3632
|
+
if (!isTemporaryCssAssetFile(outputFile)) return;
|
|
3633
|
+
const entry = queuedEntries.find((item) => !usedEntryFiles.has(normalizeCssSourceKey(item.file)));
|
|
3634
|
+
if (!entry) return;
|
|
3635
|
+
usedEntryFiles.add(normalizeCssSourceKey(entry.file));
|
|
3636
|
+
return {
|
|
3637
|
+
outputFile: entry.outputFile,
|
|
3638
|
+
rawSource: entry.source,
|
|
3639
|
+
sourceFile: entry.file
|
|
3640
|
+
};
|
|
3641
|
+
}
|
|
3642
|
+
};
|
|
3643
|
+
}
|
|
3644
|
+
//#endregion
|
|
3572
3645
|
//#region src/bundlers/vite/generate-bundle/timing.ts
|
|
3573
3646
|
function createBundleTaskTimer(recordTimingDetail) {
|
|
3574
3647
|
return async (name, task) => {
|
|
@@ -3772,12 +3845,13 @@ function createGenerateBundleHook(context) {
|
|
|
3772
3845
|
});
|
|
3773
3846
|
return async function generateBundle(_opt, bundle) {
|
|
3774
3847
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
3775
|
-
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownSfcSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
3848
|
+
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
3776
3849
|
const getBundlerSfcSource = (sourceFile) => {
|
|
3777
3850
|
const code = this.getModuleInfo?.(sourceFile)?.code;
|
|
3778
3851
|
return typeof code === "string" && hasSfcStyleSources(code) ? code : void 0;
|
|
3779
3852
|
};
|
|
3780
3853
|
const getSfcSource = (sourceFile) => getBundlerSfcSource(sourceFile) ?? getKnownSfcSource?.(sourceFile);
|
|
3854
|
+
const getCssSource = (sourceFile) => getKnownCssSource?.(sourceFile) ?? getSourceCandidateSource?.(sourceFile);
|
|
3781
3855
|
const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
|
|
3782
3856
|
const resolvedConfig = getResolvedConfig();
|
|
3783
3857
|
const uniUtsPlatform = resolveUniUtsPlatform();
|
|
@@ -3913,7 +3987,7 @@ function createGenerateBundleHook(context) {
|
|
|
3913
3987
|
refreshBySource: forceV4RuntimeRefreshBySource
|
|
3914
3988
|
}) : await context.ensureRuntimeClassSet(envFlags.forceRuntimeRefreshByEnv);
|
|
3915
3989
|
const shouldFilterTailwindV4MiniProgramCandidates = shouldUseMiniProgramCssBranch(generatorBranch);
|
|
3916
|
-
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
3990
|
+
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...sourceCandidates]);
|
|
3917
3991
|
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
3918
3992
|
const filteredSourceCandidates = shouldFilterTailwindV4MiniProgramCandidates ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceCandidates) : sourceCandidates;
|
|
3919
3993
|
const transformRuntime = shouldFilterTailwindV4MiniProgramCandidates ? new Set(runtime) : new Set(filteredGeneratorCandidates);
|
|
@@ -3949,7 +4023,7 @@ function createGenerateBundleHook(context) {
|
|
|
3949
4023
|
const generatorCandidatesChanged = state.generatorCandidateSignature !== generatorCandidateSignature;
|
|
3950
4024
|
const cssExtensionByStem = collectCssExtensionByStem(bundleFiles, opts.cssMatcher);
|
|
3951
4025
|
const jsImportedCssFiles = collectJsImportedCssFiles(snapshot);
|
|
3952
|
-
const runtimeLinkedCssFiles = new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
4026
|
+
const runtimeLinkedCssFiles = /* @__PURE__ */ new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
3953
4027
|
rememberRuntimeLinkedCssSources({
|
|
3954
4028
|
bundleFiles,
|
|
3955
4029
|
debug,
|
|
@@ -3968,8 +4042,32 @@ function createGenerateBundleHook(context) {
|
|
|
3968
4042
|
snapshot,
|
|
3969
4043
|
sourceRoot
|
|
3970
4044
|
});
|
|
4045
|
+
const temporaryCssAssetSourceResolver = createTemporaryCssAssetSourceResolver([
|
|
4046
|
+
...[...runtimeLinkedCssFiles].filter((file) => !snapshot.sourceHashByFile.has(file)).map((file) => {
|
|
4047
|
+
const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
4048
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, jsImportedCssFiles.has(file) ? getSourceCandidateSources : void 0, getConfiguredTailwindV4CssSourceEntries().map((entry) => [entry.file, entry.source]), debug);
|
|
4049
|
+
return inferredSourceStyle && currentSubpackageRoots && isSubpackageOutputFile(outputFile, currentSubpackageRoots) ? {
|
|
4050
|
+
file: inferredSourceStyle.sourceFile,
|
|
4051
|
+
outputFile,
|
|
4052
|
+
source: inferredSourceStyle.rawSource
|
|
4053
|
+
} : void 0;
|
|
4054
|
+
}).filter((entry) => entry != null),
|
|
4055
|
+
...[...getRememberedCssSources?.() ?? []].map(([, remembered]) => ({
|
|
4056
|
+
file: remembered.sourceFile,
|
|
4057
|
+
outputFile: remembered.outputFile,
|
|
4058
|
+
source: remembered.rawSource
|
|
4059
|
+
})),
|
|
4060
|
+
...configuredTailwindV4CssSourceEntriesForScope.map((entry) => {
|
|
4061
|
+
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4062
|
+
return outputFile && currentSubpackageRoots && isSubpackageOutputFile(outputFile, currentSubpackageRoots) ? {
|
|
4063
|
+
file: entry.file,
|
|
4064
|
+
outputFile,
|
|
4065
|
+
source: entry.source
|
|
4066
|
+
} : void 0;
|
|
4067
|
+
}).filter((entry) => entry != null)
|
|
4068
|
+
]);
|
|
3971
4069
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
3972
|
-
const dynamicRetryCandidates = new Set([
|
|
4070
|
+
const dynamicRetryCandidates = /* @__PURE__ */ new Set([
|
|
3973
4071
|
...sourceCandidates,
|
|
3974
4072
|
...generatorRuntime,
|
|
3975
4073
|
...transformRuntime
|
|
@@ -4068,6 +4166,7 @@ function createGenerateBundleHook(context) {
|
|
|
4068
4166
|
}
|
|
4069
4167
|
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
4070
4168
|
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
4169
|
+
let resolvedFromTemporaryCssAsset = false;
|
|
4071
4170
|
const applyCssResult = (source) => {
|
|
4072
4171
|
applyCssResultToBundle({
|
|
4073
4172
|
appType: opts.appType,
|
|
@@ -4109,14 +4208,39 @@ function createGenerateBundleHook(context) {
|
|
|
4109
4208
|
const rememberedSourcesBelongToInferredSfc = rememberedCssSources.length > 0 && rememberedCssSources.every((remembered) => normalizeSfcSourceFileForCompare(remembered.sourceFile) === inferredSourceFile);
|
|
4110
4209
|
if (!hasUsableRememberedTailwindSource || rememberedSourcesBelongToInferredSfc) rememberedCssSources = [inferredSfcStyleSource];
|
|
4111
4210
|
}
|
|
4211
|
+
if (isTemporaryCssAssetFile(outputFile) && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))))) {
|
|
4212
|
+
rememberedCssSources = [];
|
|
4213
|
+
hasUsableRememberedTailwindSource = false;
|
|
4214
|
+
}
|
|
4112
4215
|
let outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4113
4216
|
if (currentSubpackageRoots && rememberedCssSources.length > 0 && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))) && !isSameSubpackageScope(outputFile, remembered.sourceFile, currentSubpackageRoots))) {
|
|
4114
4217
|
rememberedCssSources = [];
|
|
4115
4218
|
hasUsableRememberedTailwindSource = false;
|
|
4116
4219
|
}
|
|
4220
|
+
if (isTemporaryCssAssetFile(outputFile) && hasTailwindGenerationSource(rawSource)) {
|
|
4221
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile);
|
|
4222
|
+
if (resolvedTemporarySource) {
|
|
4223
|
+
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4224
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4225
|
+
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4226
|
+
outputCssHandlerOptions = {
|
|
4227
|
+
...outputCssHandlerOptions,
|
|
4228
|
+
isMainChunk: false
|
|
4229
|
+
};
|
|
4230
|
+
resolvedFromTemporaryCssAsset = true;
|
|
4231
|
+
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(resolvedTemporarySource.sourceFile));
|
|
4232
|
+
rememberedCssSources = [{
|
|
4233
|
+
outputFile,
|
|
4234
|
+
rawSource: resolvedTemporarySource.rawSource,
|
|
4235
|
+
sourceFile: resolvedTemporarySource.sourceFile
|
|
4236
|
+
}];
|
|
4237
|
+
hasUsableRememberedTailwindSource = true;
|
|
4238
|
+
debug("source style source inferred from temporary remembered tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4117
4241
|
if (!hasUsableRememberedTailwindSource) {
|
|
4118
4242
|
const configuredTailwindV4CssSourceEntries = getConfiguredTailwindV4CssSourceEntries();
|
|
4119
|
-
const inferredOriginalSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot,
|
|
4243
|
+
const inferredOriginalSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry) => [entry.file, entry.source]), debug) ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry) => [entry.file, entry.source]), debug));
|
|
4120
4244
|
if (inferredOriginalSourceStyle) {
|
|
4121
4245
|
outputFile = resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
4122
4246
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4125,6 +4249,25 @@ function createGenerateBundleHook(context) {
|
|
|
4125
4249
|
...inferredOriginalSourceStyle,
|
|
4126
4250
|
outputFile
|
|
4127
4251
|
}];
|
|
4252
|
+
} else if (isTemporaryCssAssetFile(outputFile) && configuredTailwindV4CssSourceEntries.length > 1) {
|
|
4253
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile);
|
|
4254
|
+
if (resolvedTemporarySource) {
|
|
4255
|
+
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4256
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4257
|
+
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4258
|
+
outputCssHandlerOptions = {
|
|
4259
|
+
...outputCssHandlerOptions,
|
|
4260
|
+
isMainChunk: false
|
|
4261
|
+
};
|
|
4262
|
+
resolvedFromTemporaryCssAsset = true;
|
|
4263
|
+
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(resolvedTemporarySource.sourceFile));
|
|
4264
|
+
rememberedCssSources = [{
|
|
4265
|
+
outputFile,
|
|
4266
|
+
rawSource: resolvedTemporarySource.rawSource,
|
|
4267
|
+
sourceFile: resolvedTemporarySource.sourceFile
|
|
4268
|
+
}];
|
|
4269
|
+
debug("source style source inferred from temporary configured tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
4270
|
+
}
|
|
4128
4271
|
} else if (hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
4129
4272
|
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry) => !usedConfiguredTailwindV4CssSourceFiles.has(normalizeOutputPathKey(entry.file)));
|
|
4130
4273
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, currentSubpackageRoots);
|
|
@@ -4176,10 +4319,13 @@ function createGenerateBundleHook(context) {
|
|
|
4176
4319
|
const hasSameOutputRememberedTailwindGenerationSource = hasRememberedTailwindGenerationSource && rememberedCssSource != null && normalizeOutputPathKey(rememberedCssSource.outputFile) === normalizeOutputPathKey(outputFile);
|
|
4177
4320
|
const hasStaleViteProcessedCssSource = vitePipelineCssAsset && hasDifferentRememberedCssSource && (hasCurrentTailwindGenerationDirective || hasRememberedApplyDirective || hasRememberedTailwindGenerationSource);
|
|
4178
4321
|
const generatorSourceFile = vitePipelineCssAsset ? rememberedCssSource?.sourceFile ?? assetSourceFile : assetSourceFile;
|
|
4179
|
-
if (vitePipelineCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(generatorSourceFile.replace(/[?#].*$/, ""))))
|
|
4322
|
+
if (vitePipelineCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(generatorSourceFile.replace(/[?#].*$/, "")))) {
|
|
4323
|
+
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(generatorSourceFile));
|
|
4324
|
+
temporaryCssAssetSourceResolver.markUsed(generatorSourceFile);
|
|
4325
|
+
}
|
|
4180
4326
|
const cssHandlerOptions = vitePipelineCssAsset ? {
|
|
4181
4327
|
...getCssHandlerOptions(generatorSourceFile),
|
|
4182
|
-
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
4328
|
+
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
4183
4329
|
} : getCssHandlerOptions(file);
|
|
4184
4330
|
const generatorCssHandlerOptions = {
|
|
4185
4331
|
...cssHandlerOptions,
|
|
@@ -4575,7 +4721,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4575
4721
|
const applyUtilities = collectUniAppXHarmonyApplyUtilities(bundle);
|
|
4576
4722
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
4577
4723
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
4578
|
-
const harmonyRuntime = new Set([...runtime, ...applyUtilities]);
|
|
4724
|
+
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
4579
4725
|
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css");
|
|
4580
4726
|
const generated = await generateTailwindV4Css({
|
|
4581
4727
|
opts,
|
|
@@ -4622,7 +4768,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4622
4768
|
await runtimeState.readyPromise;
|
|
4623
4769
|
await waitForSourceCandidateSyncs?.();
|
|
4624
4770
|
const runtime = getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet();
|
|
4625
|
-
const collectedGeneratorCandidates = new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
4771
|
+
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
4626
4772
|
const generatorRuntime = shouldUseMiniProgramCssBranch(generatorBranch) ? filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
4627
4773
|
await Promise.all(entries.map(async ([bundleFile, output]) => {
|
|
4628
4774
|
const file = output.fileName || bundleFile;
|
|
@@ -4795,6 +4941,11 @@ function createViteCssMemory(options) {
|
|
|
4795
4941
|
if (source != null) touchMapEntry(knownSfcSources, key, source);
|
|
4796
4942
|
return source;
|
|
4797
4943
|
};
|
|
4944
|
+
const getKnownCssSource = (file) => {
|
|
4945
|
+
const source = knownCssSources.get(normalizeCssSourceIdentity(file));
|
|
4946
|
+
if (source != null) touchMapEntry(knownCssSources, normalizeCssSourceIdentity(file), source);
|
|
4947
|
+
return source;
|
|
4948
|
+
};
|
|
4798
4949
|
const rememberCssSource = (entry, cssRuntimeSignature) => {
|
|
4799
4950
|
const outputKey = normalizeOutputPathKey(entry.outputFile);
|
|
4800
4951
|
const normalizedSourceFile = normalizeCssSourceIdentity(entry.sourceFile);
|
|
@@ -4913,6 +5064,7 @@ function createViteCssMemory(options) {
|
|
|
4913
5064
|
};
|
|
4914
5065
|
return {
|
|
4915
5066
|
getKnownSfcSource,
|
|
5067
|
+
getKnownCssSource,
|
|
4916
5068
|
getRememberedCssSignature: (file) => rememberedCssSignatureByFile.get(normalizeOutputPathKey(file)),
|
|
4917
5069
|
getRememberedCssSourceEntry: (file) => rememberedCssSources.get(normalizeOutputPathKey(file)),
|
|
4918
5070
|
getRememberedCssSources: () => rememberedCssSources,
|
|
@@ -5299,7 +5451,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
5299
5451
|
}
|
|
5300
5452
|
//#endregion
|
|
5301
5453
|
//#region src/bundlers/vite/serve-css-generation.ts
|
|
5302
|
-
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5454
|
+
const SPECIAL_QUERY_RE$1 = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5303
5455
|
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/;
|
|
5304
5456
|
const VITE_CSS_HMR_MODULE_RE = /\b__vite__updateStyle\s*\(/;
|
|
5305
5457
|
const VITE_CSS_CONST_RE = /\bconst\s+__vite__css\s*=\s*("(?:\\[\s\S]|[^"])*")/;
|
|
@@ -5330,10 +5482,10 @@ function replaceViteCssHmrModuleCss(code, css) {
|
|
|
5330
5482
|
return `${code.slice(0, extracted.start)}${encodeJsStringLiteral(css)}${code.slice(extracted.end)}`;
|
|
5331
5483
|
}
|
|
5332
5484
|
function isViteServeStyleRequest(id, command) {
|
|
5333
|
-
return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5485
|
+
return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5334
5486
|
}
|
|
5335
5487
|
function isViteServeCssRootRequest(id, command) {
|
|
5336
|
-
return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5488
|
+
return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5337
5489
|
}
|
|
5338
5490
|
function isViteCssHmrModule(code, id, command) {
|
|
5339
5491
|
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
@@ -5375,6 +5527,32 @@ function createViteServeCssGenerationPlugins(options) {
|
|
|
5375
5527
|
}];
|
|
5376
5528
|
}
|
|
5377
5529
|
//#endregion
|
|
5530
|
+
//#region src/bundlers/vite/serve-js-transform.ts
|
|
5531
|
+
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5532
|
+
function isViteServeJsRequest(id, command) {
|
|
5533
|
+
if (command !== "serve" || SPECIAL_QUERY_RE.test(id) || isCSSRequest(id) || isHTMLRequest(id)) return false;
|
|
5534
|
+
return /\.(?:[cm]?[jt]sx?|vue|svelte)(?:$|\?)/.test(id);
|
|
5535
|
+
}
|
|
5536
|
+
function createViteServeJsTransformPlugin(options) {
|
|
5537
|
+
return {
|
|
5538
|
+
name: `${vitePluginName}:js:serve`,
|
|
5539
|
+
apply: "serve",
|
|
5540
|
+
enforce: "post",
|
|
5541
|
+
async transform(code, id) {
|
|
5542
|
+
if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
|
|
5543
|
+
const handlerOptions = options.createHandlerOptions(id);
|
|
5544
|
+
if (shouldSkipJsTransform(code, handlerOptions)) return;
|
|
5545
|
+
const runtime = await options.transformRuntime();
|
|
5546
|
+
const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
|
|
5547
|
+
if (transformed === code) return;
|
|
5548
|
+
return {
|
|
5549
|
+
code: transformed,
|
|
5550
|
+
map: null
|
|
5551
|
+
};
|
|
5552
|
+
}
|
|
5553
|
+
};
|
|
5554
|
+
}
|
|
5555
|
+
//#endregion
|
|
5378
5556
|
//#region src/bundlers/vite/tailwind-basedir.ts
|
|
5379
5557
|
const PACKAGE_JSON_FILE = "package.json";
|
|
5380
5558
|
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
@@ -5469,6 +5647,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5469
5647
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) return;
|
|
5470
5648
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
5471
5649
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
5650
|
+
cssMemory.refreshRememberedCssSourceBySourceFile(sourceFile, sourceCss);
|
|
5472
5651
|
const transientSource = {
|
|
5473
5652
|
file: sourceFile,
|
|
5474
5653
|
base: sourceBase,
|
|
@@ -5595,7 +5774,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5595
5774
|
root
|
|
5596
5775
|
}];
|
|
5597
5776
|
const normalizedRoot = path.resolve(root);
|
|
5598
|
-
const seenRoots = new Set([normalizedRoot]);
|
|
5777
|
+
const seenRoots = /* @__PURE__ */ new Set([normalizedRoot]);
|
|
5599
5778
|
const basedir = opts.tailwindcssBasedir ? path.resolve(opts.tailwindcssBasedir) : void 0;
|
|
5600
5779
|
if (basedir && !seenRoots.has(basedir)) {
|
|
5601
5780
|
roots.push({ root: basedir });
|
|
@@ -5778,6 +5957,10 @@ function WeappTailwindcss(options = {}) {
|
|
|
5778
5957
|
...resolveUniAppXNativeCssHandlerOptions(opts)
|
|
5779
5958
|
})
|
|
5780
5959
|
});
|
|
5960
|
+
const serveJsHandlerOptions = createJsHandlerOptionsFactory({
|
|
5961
|
+
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
5962
|
+
moduleGraph: void 0
|
|
5963
|
+
});
|
|
5781
5964
|
const generateTailwindCssForVitePipeline = async (id, code, hookContext) => {
|
|
5782
5965
|
if (!shouldOwnTailwindGeneration) return;
|
|
5783
5966
|
await runtimeState.readyPromise;
|
|
@@ -5796,7 +5979,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
5796
5979
|
...transformCssHandlerOptions.getCssHandlerOptions(file),
|
|
5797
5980
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
5798
5981
|
};
|
|
5799
|
-
const transientCssSource = transientAutoCssSources.get(file)
|
|
5982
|
+
const transientCssSource = transientAutoCssSources.get(file) ?? (hasTailwindRootDirectives(code, { importFallback: generatorOptions.importFallback }) || hasTailwindSourceDirectives(code, { importFallback: generatorOptions.importFallback }) || hasTailwindApplyDirective(code) ? {
|
|
5983
|
+
base: path.dirname(path.resolve(file)),
|
|
5984
|
+
css: code,
|
|
5985
|
+
file: path.resolve(file)
|
|
5986
|
+
} : void 0);
|
|
5800
5987
|
const shouldDeferEmptyScopedCssSource = transientCssSource == null && !(opts.appType === "uni-app-x" && !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(code));
|
|
5801
5988
|
const generated = await generateTailwindV4Css({
|
|
5802
5989
|
opts,
|
|
@@ -5884,6 +6071,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5884
6071
|
getRememberedCssSources: cssMemory.getRememberedCssSources,
|
|
5885
6072
|
getRememberedCssSignature: cssMemory.getRememberedCssSignature,
|
|
5886
6073
|
setRememberedCssSignature: cssMemory.setRememberedCssSignature,
|
|
6074
|
+
getKnownCssSource: cssMemory.getKnownCssSource,
|
|
5887
6075
|
getKnownSfcSource: cssMemory.getKnownSfcSource,
|
|
5888
6076
|
recordGeneratorCandidates,
|
|
5889
6077
|
pruneViteCssCaches,
|
|
@@ -5991,6 +6179,13 @@ function WeappTailwindcss(options = {}) {
|
|
|
5991
6179
|
onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
|
|
5992
6180
|
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
5993
6181
|
}),
|
|
6182
|
+
createViteServeJsTransformPlugin({
|
|
6183
|
+
createHandlerOptions: serveJsHandlerOptions,
|
|
6184
|
+
getCommand: () => resolvedConfig?.command,
|
|
6185
|
+
jsHandler,
|
|
6186
|
+
shouldTransform: () => shouldOwnTailwindGeneration && !generatorBranch.isWeb,
|
|
6187
|
+
transformRuntime: ensureRuntimeClassSet
|
|
6188
|
+
}),
|
|
5994
6189
|
{
|
|
5995
6190
|
name: `${vitePluginName}:post`,
|
|
5996
6191
|
enforce: "post",
|