weapp-tailwindcss 5.1.1 → 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.en.md +2 -0
- package/README.md +2 -0
- 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/css-output-helpers.d.ts +1 -1
- 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-DlpKD7aN.mjs → context-B07Vf584.mjs} +34 -34
- package/dist/{context-B6hVF7dr.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/options.d.ts +3 -1
- package/dist/{generator-6oMJtTDO.js → generator-CV_0irKO.js} +4 -2
- package/dist/{generator-CjzBK7h-.mjs → generator-DNs6ekoC.mjs} +3 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-BtGq6LP9.js → gulp-B_u8NjQL.js} +9 -9
- package/dist/{gulp-DNU10Vtc.mjs → gulp-aQMZ0M7c.mjs} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-B0KuWDjV.mjs → hmr-timing-DLYQTCDb.mjs} +40 -31
- package/dist/{hmr-timing-CegXR9O4.js → hmr-timing-DOoHun3i.js} +42 -33
- 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-BKYb9jxa.js → source-candidate-scan-signature-DzwebZrf.js} +6 -6
- package/dist/{source-candidate-scan-signature-B5af2Ahe.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-fRBeuuK-.mjs → transform-Clj7R818.mjs} +19 -19
- package/dist/{transform-vLwZpiTE.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-CWRooooa.mjs → vite-5Wn0PIzJ.mjs} +244 -45
- package/dist/{vite-w-RkgaTY.js → vite-CkVMSDDp.js} +249 -50
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +71 -34
- package/dist/weapp-tw-runtime-classset-loader.js +2 -2
- package/dist/{webpack-8PaV1gG3.mjs → webpack-DEag6ueE.mjs} +66 -18
- package/dist/{webpack-CGgBOx9l.js → webpack-hvSFaicc.js} +71 -23
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +10 -5
- /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);
|
|
@@ -1164,8 +1186,12 @@ function resolveCssBundleOutputFile(options) {
|
|
|
1164
1186
|
if (outputFile === file && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(opts.appType)) outputFile = createRootMiniProgramOriginStyleOutputFile(file);
|
|
1165
1187
|
return outputFile;
|
|
1166
1188
|
}
|
|
1167
|
-
function shouldSkipRawSourceStyleAsset(outputFile, file, rawSource) {
|
|
1168
|
-
|
|
1189
|
+
function shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceFile = file, cssMatcher) {
|
|
1190
|
+
const source = rawSource.trim();
|
|
1191
|
+
if (source.length === 0) return false;
|
|
1192
|
+
if (canProcessViteSourceStyleAsCss(source, file)) return false;
|
|
1193
|
+
const isKnownStyleSource = isSourceStyleRequest(assetSourceFile) || cssMatcher?.(assetSourceFile) === true;
|
|
1194
|
+
return outputFile !== file || !isKnownStyleSource;
|
|
1169
1195
|
}
|
|
1170
1196
|
function resolveOutputFileFromMatchedCssSource(options) {
|
|
1171
1197
|
const { bundleFiles, defaultStyleOutputExtension, isWebGeneratorTarget, opts, rootDir, shouldPreserveAppCssExtension, sourceFile, sourceRoot } = options;
|
|
@@ -1932,7 +1958,7 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
|
|
|
1932
1958
|
const sourceEntries = [];
|
|
1933
1959
|
for (const entry of snapshot.entries) {
|
|
1934
1960
|
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
1935
|
-
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, new Set([root])));
|
|
1961
|
+
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
1936
1962
|
if (!matchedSubpackageRoot) continue;
|
|
1937
1963
|
for (const moduleId of collectChunkModuleIds$2(entry.output)) {
|
|
1938
1964
|
if (!path.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
@@ -2103,6 +2129,14 @@ function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, option
|
|
|
2103
2129
|
const targetFileKey = normalizeOutputPathKey(targetFile);
|
|
2104
2130
|
return normalizeOutputPathKey(sourceFile) !== targetFileKey && (opts.mainCssChunkMatcher(sourceFile, opts.appType) || typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) !== targetFileKey && opts.mainCssChunkMatcher(options.outputFile, opts.appType));
|
|
2105
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
|
+
}
|
|
2106
2140
|
function isRootStyleOutputFile(file) {
|
|
2107
2141
|
const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2108
2142
|
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
@@ -2215,7 +2249,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2215
2249
|
options.markCssAssetProcessed?.(output, file);
|
|
2216
2250
|
options.recordCssAssetResult?.(file, nextCss);
|
|
2217
2251
|
const resolvedOutputFile = options.resolveViteProcessedCssOutputFile?.(file) ?? file;
|
|
2218
|
-
const shouldReplayIntoMainCss = options.opts != null && (
|
|
2252
|
+
const shouldReplayIntoMainCss = options.opts != null && shouldReplayViteProcessedCssIntoMainCss(options.opts, file, singleMarkerFile, resolvedOutputFile, options.subpackageRoots);
|
|
2219
2253
|
options.recordViteProcessedCssAssetResult?.(file, nextCss, {
|
|
2220
2254
|
injectIntoMain: shouldReplayIntoMainCss || void 0,
|
|
2221
2255
|
outputFile: resolvedOutputFile
|
|
@@ -2540,7 +2574,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
2540
2574
|
const generated = await generateTailwindV4Css({
|
|
2541
2575
|
opts,
|
|
2542
2576
|
runtimeState,
|
|
2543
|
-
runtime: new Set([...generatorRuntime, ...applyUtilities]),
|
|
2577
|
+
runtime: /* @__PURE__ */ new Set([...generatorRuntime, ...applyUtilities]),
|
|
2544
2578
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
2545
2579
|
file: outputFile,
|
|
2546
2580
|
outputFile,
|
|
@@ -2789,7 +2823,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
2789
2823
|
pruneLastCssResults(lastCssResultByFile, lastCssSourceHashByFile, activeViteCssCacheFiles);
|
|
2790
2824
|
pruneViteCssCaches?.({
|
|
2791
2825
|
activeFiles: activeViteCssCacheFiles,
|
|
2792
|
-
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)])
|
|
2793
2827
|
});
|
|
2794
2828
|
}
|
|
2795
2829
|
recordTimingDetail("state.update", stateUpdateStart);
|
|
@@ -2890,7 +2924,7 @@ function processHtmlBundleEntry(options) {
|
|
|
2890
2924
|
const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
|
|
2891
2925
|
const rawSource = resolveCurrentSourceCandidateSource(file) ?? originalEntrySource;
|
|
2892
2926
|
const currentRawDynamicCandidates = collectUnescapedDynamicCandidates(rawSource);
|
|
2893
|
-
const templateRuntime = currentRawDynamicCandidates.length > 0 ? new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2927
|
+
const templateRuntime = currentRawDynamicCandidates.length > 0 ? /* @__PURE__ */ new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2894
2928
|
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : createCandidateSignature(templateRuntime);
|
|
2895
2929
|
const htmlProcessHash = `${cache.computeHash(rawSource)}:${cache.computeHash(createRuntimeAffectingSourceSignature(rawSource, "html"))}:${templateRuntimeSignature}`;
|
|
2896
2930
|
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
@@ -2916,7 +2950,7 @@ function processHtmlBundleEntry(options) {
|
|
|
2916
2950
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
2917
2951
|
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
2918
2952
|
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
2919
|
-
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
2953
|
+
retryRuntimeSet = /* @__PURE__ */ new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
2920
2954
|
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet?.has(candidate) === true);
|
|
2921
2955
|
}
|
|
2922
2956
|
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
@@ -3131,6 +3165,15 @@ function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffe
|
|
|
3131
3165
|
function normalizeRememberedSourceIdentity(file) {
|
|
3132
3166
|
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3133
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
|
+
}
|
|
3134
3177
|
function findRememberedCssSources(sources, outputFile, file, originalSource, outputRoot, sourceRoot) {
|
|
3135
3178
|
if (!sources) return [];
|
|
3136
3179
|
const rememberedSources = [...sources].map(([, remembered]) => remembered);
|
|
@@ -3138,7 +3181,7 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3138
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)));
|
|
3139
3182
|
if (markerFiles.size > 0) {
|
|
3140
3183
|
const markerMatched = rememberedSources.filter((remembered) => markerFiles.has(normalizeRememberedSourceIdentity(remembered.sourceFile)));
|
|
3141
|
-
if (markerMatched.length > 0) return markerMatched;
|
|
3184
|
+
if (markerMatched.length > 0) return selectBestRememberedCssSourceMatches(markerMatched, outputFile, outputRoot, sourceRoot);
|
|
3142
3185
|
}
|
|
3143
3186
|
const originalFiles = [
|
|
3144
3187
|
file,
|
|
@@ -3150,12 +3193,8 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3150
3193
|
const outputMatched = rememberedSources.filter((remembered) => normalizeOutputPathKey(remembered.outputFile) === normalizeOutputPathKey(outputFile));
|
|
3151
3194
|
if (outputMatched.length > 0) return outputMatched;
|
|
3152
3195
|
if (!hasBundlerGeneratedCssMarker(source) && !hasTailwindGenerationSource(source)) return [];
|
|
3153
|
-
const scoredMatches = rememberedSources
|
|
3154
|
-
|
|
3155
|
-
score: Math.max(scoreMatchingStyleFileBase(outputFile, remembered.sourceFile, outputRoot, sourceRoot), scoreMatchingStyleFileBase(outputFile, remembered.outputFile, outputRoot, sourceRoot))
|
|
3156
|
-
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
3157
|
-
const bestScore = scoredMatches[0]?.score;
|
|
3158
|
-
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;
|
|
3159
3198
|
}
|
|
3160
3199
|
function mergeRememberedCssSources(sources, outputFile) {
|
|
3161
3200
|
if (sources.length <= 1) return sources[0];
|
|
@@ -3390,7 +3429,7 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3390
3429
|
const isMainPackageStyleOutputFile = (file) => options.subpackageRoots != null && !isSubpackageOutputFile(file, options.subpackageRoots);
|
|
3391
3430
|
const resolveSubpackageOutputSourceEntries = (outputFile) => {
|
|
3392
3431
|
if (!options.subpackageRoots) return;
|
|
3393
|
-
const matchedRoots = [...options.subpackageRoots].filter((root) => isSubpackageOutputFile(outputFile, new Set([root])));
|
|
3432
|
+
const matchedRoots = [...options.subpackageRoots].filter((root) => isSubpackageOutputFile(outputFile, /* @__PURE__ */ new Set([root])));
|
|
3394
3433
|
if (matchedRoots.length !== 1) return;
|
|
3395
3434
|
const root = matchedRoots[0];
|
|
3396
3435
|
if (!root) return;
|
|
@@ -3451,7 +3490,7 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3451
3490
|
excludeEntries: [...filterOptions?.excludeEntries ?? [], ...subpackageSourceExcludeEntries]
|
|
3452
3491
|
}) ?? /* @__PURE__ */ new Map();
|
|
3453
3492
|
};
|
|
3454
|
-
const shouldInjectCssIntoMainFromOutput = (outputFile,
|
|
3493
|
+
const shouldInjectCssIntoMainFromOutput = (outputFile, sourceFile, outputCssHandlerOptions) => outputCssHandlerOptions.isMainChunk === true && !outputFile.replace(/[?#].*$/, "").includes("/") || options.useIncrementalMode && isMainPackageStyleOutputFile(outputFile) && isMainPackageStyleOutputFile(sourceFile);
|
|
3455
3494
|
return {
|
|
3456
3495
|
createScopedSourceCandidateGetter,
|
|
3457
3496
|
createScopedSourceCandidateSourceGetter,
|
|
@@ -3534,7 +3573,7 @@ function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
|
3534
3573
|
}
|
|
3535
3574
|
function resolveSubpackageRootForFile(file, subpackageRoots) {
|
|
3536
3575
|
if (!file || !subpackageRoots) return;
|
|
3537
|
-
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, new Set([root])));
|
|
3576
|
+
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, /* @__PURE__ */ new Set([root])));
|
|
3538
3577
|
}
|
|
3539
3578
|
function isSameSubpackageScope(outputFile, sourceFile, subpackageRoots) {
|
|
3540
3579
|
return resolveSubpackageRootForFile(outputFile, subpackageRoots) === resolveSubpackageRootForFile(sourceFile, subpackageRoots);
|
|
@@ -3557,7 +3596,7 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3557
3596
|
const outputMatchesSubpackage = isSubpackageOutputFile(outputFile, subpackageRoots);
|
|
3558
3597
|
const sourceMatchesSubpackage = isSubpackageOutputFile(entry.file, subpackageRoots);
|
|
3559
3598
|
if (!outputMatchesSubpackage) return !sourceMatchesSubpackage;
|
|
3560
|
-
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])));
|
|
3561
3600
|
}) : generationSources;
|
|
3562
3601
|
const explicitSources = scopedSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3563
3602
|
const candidates = explicitSources.length === 1 ? explicitSources : scopedSources;
|
|
@@ -3565,6 +3604,44 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3565
3604
|
return selectByRawSourceFingerprint(candidates);
|
|
3566
3605
|
}
|
|
3567
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
|
|
3568
3645
|
//#region src/bundlers/vite/generate-bundle/timing.ts
|
|
3569
3646
|
function createBundleTaskTimer(recordTimingDetail) {
|
|
3570
3647
|
return async (name, task) => {
|
|
@@ -3768,12 +3845,13 @@ function createGenerateBundleHook(context) {
|
|
|
3768
3845
|
});
|
|
3769
3846
|
return async function generateBundle(_opt, bundle) {
|
|
3770
3847
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
3771
|
-
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;
|
|
3772
3849
|
const getBundlerSfcSource = (sourceFile) => {
|
|
3773
3850
|
const code = this.getModuleInfo?.(sourceFile)?.code;
|
|
3774
3851
|
return typeof code === "string" && hasSfcStyleSources(code) ? code : void 0;
|
|
3775
3852
|
};
|
|
3776
3853
|
const getSfcSource = (sourceFile) => getBundlerSfcSource(sourceFile) ?? getKnownSfcSource?.(sourceFile);
|
|
3854
|
+
const getCssSource = (sourceFile) => getKnownCssSource?.(sourceFile) ?? getSourceCandidateSource?.(sourceFile);
|
|
3777
3855
|
const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
|
|
3778
3856
|
const resolvedConfig = getResolvedConfig();
|
|
3779
3857
|
const uniUtsPlatform = resolveUniUtsPlatform();
|
|
@@ -3909,7 +3987,7 @@ function createGenerateBundleHook(context) {
|
|
|
3909
3987
|
refreshBySource: forceV4RuntimeRefreshBySource
|
|
3910
3988
|
}) : await context.ensureRuntimeClassSet(envFlags.forceRuntimeRefreshByEnv);
|
|
3911
3989
|
const shouldFilterTailwindV4MiniProgramCandidates = shouldUseMiniProgramCssBranch(generatorBranch);
|
|
3912
|
-
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
3990
|
+
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...sourceCandidates]);
|
|
3913
3991
|
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
3914
3992
|
const filteredSourceCandidates = shouldFilterTailwindV4MiniProgramCandidates ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceCandidates) : sourceCandidates;
|
|
3915
3993
|
const transformRuntime = shouldFilterTailwindV4MiniProgramCandidates ? new Set(runtime) : new Set(filteredGeneratorCandidates);
|
|
@@ -3945,7 +4023,7 @@ function createGenerateBundleHook(context) {
|
|
|
3945
4023
|
const generatorCandidatesChanged = state.generatorCandidateSignature !== generatorCandidateSignature;
|
|
3946
4024
|
const cssExtensionByStem = collectCssExtensionByStem(bundleFiles, opts.cssMatcher);
|
|
3947
4025
|
const jsImportedCssFiles = collectJsImportedCssFiles(snapshot);
|
|
3948
|
-
const runtimeLinkedCssFiles = new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
4026
|
+
const runtimeLinkedCssFiles = /* @__PURE__ */ new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
3949
4027
|
rememberRuntimeLinkedCssSources({
|
|
3950
4028
|
bundleFiles,
|
|
3951
4029
|
debug,
|
|
@@ -3964,8 +4042,32 @@ function createGenerateBundleHook(context) {
|
|
|
3964
4042
|
snapshot,
|
|
3965
4043
|
sourceRoot
|
|
3966
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
|
+
]);
|
|
3967
4069
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
3968
|
-
const dynamicRetryCandidates = new Set([
|
|
4070
|
+
const dynamicRetryCandidates = /* @__PURE__ */ new Set([
|
|
3969
4071
|
...sourceCandidates,
|
|
3970
4072
|
...generatorRuntime,
|
|
3971
4073
|
...transformRuntime
|
|
@@ -4057,13 +4159,14 @@ function createGenerateBundleHook(context) {
|
|
|
4057
4159
|
resolveOutputFileFromMatchedCssSource: resolveMatchedCssSourceOutputFile
|
|
4058
4160
|
});
|
|
4059
4161
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4060
|
-
if (shouldSkipRawSourceStyleAsset(outputFile, file, rawSource)) {
|
|
4162
|
+
if (shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceFile, opts.cssMatcher)) {
|
|
4061
4163
|
delete bundle[file];
|
|
4062
4164
|
debug("css skip raw source style asset: %s -> %s", file, outputFile);
|
|
4063
4165
|
continue;
|
|
4064
4166
|
}
|
|
4065
4167
|
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
4066
4168
|
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
4169
|
+
let resolvedFromTemporaryCssAsset = false;
|
|
4067
4170
|
const applyCssResult = (source) => {
|
|
4068
4171
|
applyCssResultToBundle({
|
|
4069
4172
|
appType: opts.appType,
|
|
@@ -4105,14 +4208,39 @@ function createGenerateBundleHook(context) {
|
|
|
4105
4208
|
const rememberedSourcesBelongToInferredSfc = rememberedCssSources.length > 0 && rememberedCssSources.every((remembered) => normalizeSfcSourceFileForCompare(remembered.sourceFile) === inferredSourceFile);
|
|
4106
4209
|
if (!hasUsableRememberedTailwindSource || rememberedSourcesBelongToInferredSfc) rememberedCssSources = [inferredSfcStyleSource];
|
|
4107
4210
|
}
|
|
4211
|
+
if (isTemporaryCssAssetFile(outputFile) && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))))) {
|
|
4212
|
+
rememberedCssSources = [];
|
|
4213
|
+
hasUsableRememberedTailwindSource = false;
|
|
4214
|
+
}
|
|
4108
4215
|
let outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4109
4216
|
if (currentSubpackageRoots && rememberedCssSources.length > 0 && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))) && !isSameSubpackageScope(outputFile, remembered.sourceFile, currentSubpackageRoots))) {
|
|
4110
4217
|
rememberedCssSources = [];
|
|
4111
4218
|
hasUsableRememberedTailwindSource = false;
|
|
4112
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
|
+
}
|
|
4113
4241
|
if (!hasUsableRememberedTailwindSource) {
|
|
4114
4242
|
const configuredTailwindV4CssSourceEntries = getConfiguredTailwindV4CssSourceEntries();
|
|
4115
|
-
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));
|
|
4116
4244
|
if (inferredOriginalSourceStyle) {
|
|
4117
4245
|
outputFile = resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
4118
4246
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4121,6 +4249,25 @@ function createGenerateBundleHook(context) {
|
|
|
4121
4249
|
...inferredOriginalSourceStyle,
|
|
4122
4250
|
outputFile
|
|
4123
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
|
+
}
|
|
4124
4271
|
} else if (hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
4125
4272
|
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry) => !usedConfiguredTailwindV4CssSourceFiles.has(normalizeOutputPathKey(entry.file)));
|
|
4126
4273
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, currentSubpackageRoots);
|
|
@@ -4172,10 +4319,13 @@ function createGenerateBundleHook(context) {
|
|
|
4172
4319
|
const hasSameOutputRememberedTailwindGenerationSource = hasRememberedTailwindGenerationSource && rememberedCssSource != null && normalizeOutputPathKey(rememberedCssSource.outputFile) === normalizeOutputPathKey(outputFile);
|
|
4173
4320
|
const hasStaleViteProcessedCssSource = vitePipelineCssAsset && hasDifferentRememberedCssSource && (hasCurrentTailwindGenerationDirective || hasRememberedApplyDirective || hasRememberedTailwindGenerationSource);
|
|
4174
4321
|
const generatorSourceFile = vitePipelineCssAsset ? rememberedCssSource?.sourceFile ?? assetSourceFile : assetSourceFile;
|
|
4175
|
-
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
|
+
}
|
|
4176
4326
|
const cssHandlerOptions = vitePipelineCssAsset ? {
|
|
4177
4327
|
...getCssHandlerOptions(generatorSourceFile),
|
|
4178
|
-
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
4328
|
+
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
4179
4329
|
} : getCssHandlerOptions(file);
|
|
4180
4330
|
const generatorCssHandlerOptions = {
|
|
4181
4331
|
...cssHandlerOptions,
|
|
@@ -4571,7 +4721,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4571
4721
|
const applyUtilities = collectUniAppXHarmonyApplyUtilities(bundle);
|
|
4572
4722
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
4573
4723
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
4574
|
-
const harmonyRuntime = new Set([...runtime, ...applyUtilities]);
|
|
4724
|
+
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
4575
4725
|
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css");
|
|
4576
4726
|
const generated = await generateTailwindV4Css({
|
|
4577
4727
|
opts,
|
|
@@ -4618,7 +4768,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4618
4768
|
await runtimeState.readyPromise;
|
|
4619
4769
|
await waitForSourceCandidateSyncs?.();
|
|
4620
4770
|
const runtime = getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet();
|
|
4621
|
-
const collectedGeneratorCandidates = new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
4771
|
+
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
4622
4772
|
const generatorRuntime = shouldUseMiniProgramCssBranch(generatorBranch) ? filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
4623
4773
|
await Promise.all(entries.map(async ([bundleFile, output]) => {
|
|
4624
4774
|
const file = output.fileName || bundleFile;
|
|
@@ -4791,6 +4941,11 @@ function createViteCssMemory(options) {
|
|
|
4791
4941
|
if (source != null) touchMapEntry(knownSfcSources, key, source);
|
|
4792
4942
|
return source;
|
|
4793
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
|
+
};
|
|
4794
4949
|
const rememberCssSource = (entry, cssRuntimeSignature) => {
|
|
4795
4950
|
const outputKey = normalizeOutputPathKey(entry.outputFile);
|
|
4796
4951
|
const normalizedSourceFile = normalizeCssSourceIdentity(entry.sourceFile);
|
|
@@ -4909,6 +5064,7 @@ function createViteCssMemory(options) {
|
|
|
4909
5064
|
};
|
|
4910
5065
|
return {
|
|
4911
5066
|
getKnownSfcSource,
|
|
5067
|
+
getKnownCssSource,
|
|
4912
5068
|
getRememberedCssSignature: (file) => rememberedCssSignatureByFile.get(normalizeOutputPathKey(file)),
|
|
4913
5069
|
getRememberedCssSourceEntry: (file) => rememberedCssSources.get(normalizeOutputPathKey(file)),
|
|
4914
5070
|
getRememberedCssSources: () => rememberedCssSources,
|
|
@@ -5295,7 +5451,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
5295
5451
|
}
|
|
5296
5452
|
//#endregion
|
|
5297
5453
|
//#region src/bundlers/vite/serve-css-generation.ts
|
|
5298
|
-
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5454
|
+
const SPECIAL_QUERY_RE$1 = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5299
5455
|
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/;
|
|
5300
5456
|
const VITE_CSS_HMR_MODULE_RE = /\b__vite__updateStyle\s*\(/;
|
|
5301
5457
|
const VITE_CSS_CONST_RE = /\bconst\s+__vite__css\s*=\s*("(?:\\[\s\S]|[^"])*")/;
|
|
@@ -5326,10 +5482,10 @@ function replaceViteCssHmrModuleCss(code, css) {
|
|
|
5326
5482
|
return `${code.slice(0, extracted.start)}${encodeJsStringLiteral(css)}${code.slice(extracted.end)}`;
|
|
5327
5483
|
}
|
|
5328
5484
|
function isViteServeStyleRequest(id, command) {
|
|
5329
|
-
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);
|
|
5330
5486
|
}
|
|
5331
5487
|
function isViteServeCssRootRequest(id, command) {
|
|
5332
|
-
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);
|
|
5333
5489
|
}
|
|
5334
5490
|
function isViteCssHmrModule(code, id, command) {
|
|
5335
5491
|
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
@@ -5371,6 +5527,32 @@ function createViteServeCssGenerationPlugins(options) {
|
|
|
5371
5527
|
}];
|
|
5372
5528
|
}
|
|
5373
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
|
|
5374
5556
|
//#region src/bundlers/vite/tailwind-basedir.ts
|
|
5375
5557
|
const PACKAGE_JSON_FILE = "package.json";
|
|
5376
5558
|
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
@@ -5465,6 +5647,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5465
5647
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) return;
|
|
5466
5648
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
5467
5649
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
5650
|
+
cssMemory.refreshRememberedCssSourceBySourceFile(sourceFile, sourceCss);
|
|
5468
5651
|
const transientSource = {
|
|
5469
5652
|
file: sourceFile,
|
|
5470
5653
|
base: sourceBase,
|
|
@@ -5591,7 +5774,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5591
5774
|
root
|
|
5592
5775
|
}];
|
|
5593
5776
|
const normalizedRoot = path.resolve(root);
|
|
5594
|
-
const seenRoots = new Set([normalizedRoot]);
|
|
5777
|
+
const seenRoots = /* @__PURE__ */ new Set([normalizedRoot]);
|
|
5595
5778
|
const basedir = opts.tailwindcssBasedir ? path.resolve(opts.tailwindcssBasedir) : void 0;
|
|
5596
5779
|
if (basedir && !seenRoots.has(basedir)) {
|
|
5597
5780
|
roots.push({ root: basedir });
|
|
@@ -5774,6 +5957,10 @@ function WeappTailwindcss(options = {}) {
|
|
|
5774
5957
|
...resolveUniAppXNativeCssHandlerOptions(opts)
|
|
5775
5958
|
})
|
|
5776
5959
|
});
|
|
5960
|
+
const serveJsHandlerOptions = createJsHandlerOptionsFactory({
|
|
5961
|
+
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
5962
|
+
moduleGraph: void 0
|
|
5963
|
+
});
|
|
5777
5964
|
const generateTailwindCssForVitePipeline = async (id, code, hookContext) => {
|
|
5778
5965
|
if (!shouldOwnTailwindGeneration) return;
|
|
5779
5966
|
await runtimeState.readyPromise;
|
|
@@ -5792,7 +5979,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
5792
5979
|
...transformCssHandlerOptions.getCssHandlerOptions(file),
|
|
5793
5980
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
5794
5981
|
};
|
|
5795
|
-
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);
|
|
5796
5987
|
const shouldDeferEmptyScopedCssSource = transientCssSource == null && !(opts.appType === "uni-app-x" && !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(code));
|
|
5797
5988
|
const generated = await generateTailwindV4Css({
|
|
5798
5989
|
opts,
|
|
@@ -5880,6 +6071,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5880
6071
|
getRememberedCssSources: cssMemory.getRememberedCssSources,
|
|
5881
6072
|
getRememberedCssSignature: cssMemory.getRememberedCssSignature,
|
|
5882
6073
|
setRememberedCssSignature: cssMemory.setRememberedCssSignature,
|
|
6074
|
+
getKnownCssSource: cssMemory.getKnownCssSource,
|
|
5883
6075
|
getKnownSfcSource: cssMemory.getKnownSfcSource,
|
|
5884
6076
|
recordGeneratorCandidates,
|
|
5885
6077
|
pruneViteCssCaches,
|
|
@@ -5987,6 +6179,13 @@ function WeappTailwindcss(options = {}) {
|
|
|
5987
6179
|
onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
|
|
5988
6180
|
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
5989
6181
|
}),
|
|
6182
|
+
createViteServeJsTransformPlugin({
|
|
6183
|
+
createHandlerOptions: serveJsHandlerOptions,
|
|
6184
|
+
getCommand: () => resolvedConfig?.command,
|
|
6185
|
+
jsHandler,
|
|
6186
|
+
shouldTransform: () => shouldOwnTailwindGeneration && !generatorBranch.isWeb,
|
|
6187
|
+
transformRuntime: ensureRuntimeClassSet
|
|
6188
|
+
}),
|
|
5990
6189
|
{
|
|
5991
6190
|
name: `${vitePluginName}:post`,
|
|
5992
6191
|
enforce: "post",
|