weapp-tailwindcss 5.0.0-next.21 → 5.0.0-next.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bundle-state-BnV8o2Yn.js → bundle-state-BxWD-X7F.js} +1 -1
- package/dist/{bundle-state-CLnuf2CW.mjs → bundle-state-CCjtHdeS.mjs} +1 -1
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{defaults-B1igPF_e.mjs → defaults-C6sIKXgC.mjs} +1 -1
- package/dist/{defaults-IHhYxNeU.js → defaults-D3cFX6Cq.js} +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/generator-BP_VdS_x.mjs +58 -0
- package/dist/{generator-B4RNgMLx.js → generator-D6gEmxIp.js} +33 -5
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-DZsbM0-a.js → incremental-runtime-class-set-CdcqejGM.js} +20 -11
- package/dist/{incremental-runtime-class-set-C7Q7fC5u.mjs → incremental-runtime-class-set-DEf-VOwB.mjs} +20 -11
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-CFa6-qO9.js → postcss-D8kdiqHg.js} +2 -2
- package/dist/{postcss-Drpy7j-g.mjs → postcss-KBUSjpTr.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-D1O5AWzy.mjs → precheck-DT3ydSET.mjs} +3 -3
- package/dist/{precheck-8pQbjqpq.js → precheck-DrBpp5HA.js} +3 -3
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-CUTNdsiz.js → source-candidates-CHJBRaDA.js} +81 -10
- package/dist/{source-candidates-CnD4vyic.mjs → source-candidates-CvmmNj4x.mjs} +81 -10
- package/dist/{tailwindcss-whZE3HpL.js → tailwindcss-CxAd28dW.js} +1 -1
- package/dist/{tailwindcss-B_JAdOQf.mjs → tailwindcss-eov9DmH3.mjs} +1 -1
- package/dist/{v3-engine-CCwvhRrQ.js → v3-engine-CxCp7Ydh.js} +97 -13
- package/dist/{v3-engine-DyIcbpZm.mjs → v3-engine-CzD7OvXg.mjs} +97 -13
- package/dist/{vite-B8IiXgVD.mjs → vite-DyQrAtpx.mjs} +34 -14
- package/dist/{vite-BcnwgJMt.js → vite-xq8oINaq.js} +34 -14
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +141 -23
- package/dist/{webpack-DTkshAtp.mjs → webpack-CZIJ7caJ.mjs} +5 -5
- package/dist/{webpack-C4zI624R.js → webpack-bTvAcuj4.js} +5 -5
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +4 -4
- package/dist/generator-DvyhmC76.mjs +0 -32
|
@@ -1,9 +1,42 @@
|
|
|
1
|
-
import { L as resolveSourceScanPath, N as isFileMatchedByTailwindSourceEntries, k as FULL_SOURCE_SCAN_EXTENSION_RE, z as toPosixPath } from "./v3-engine-
|
|
1
|
+
import { L as resolveSourceScanPath, N as isFileMatchedByTailwindSourceEntries, k as FULL_SOURCE_SCAN_EXTENSION_RE, z as toPosixPath } from "./v3-engine-CzD7OvXg.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { extractSourceCandidates, resolveProjectSourceFiles } from "tailwindcss-patch";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
//#region src/bundlers/vite/source-candidates.ts
|
|
6
6
|
const CLEAN_URL_RE = /[?#].*$/;
|
|
7
|
+
const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
|
|
8
|
+
".git",
|
|
9
|
+
".hg",
|
|
10
|
+
".jj",
|
|
11
|
+
".next",
|
|
12
|
+
".parcel-cache",
|
|
13
|
+
".pnpm-store",
|
|
14
|
+
".svelte-kit",
|
|
15
|
+
".svn",
|
|
16
|
+
".turbo",
|
|
17
|
+
".venv",
|
|
18
|
+
".vercel",
|
|
19
|
+
".yarn",
|
|
20
|
+
"__pycache__",
|
|
21
|
+
"node_modules",
|
|
22
|
+
"venv"
|
|
23
|
+
];
|
|
24
|
+
const TAILWIND_V4_IGNORED_EXTENSIONS = [
|
|
25
|
+
"less",
|
|
26
|
+
"lock",
|
|
27
|
+
"sass",
|
|
28
|
+
"scss",
|
|
29
|
+
"styl",
|
|
30
|
+
"log"
|
|
31
|
+
];
|
|
32
|
+
const TAILWIND_V4_IGNORED_FILES = [
|
|
33
|
+
"package-lock.json",
|
|
34
|
+
"pnpm-lock.yaml",
|
|
35
|
+
"bun.lockb",
|
|
36
|
+
".gitignore",
|
|
37
|
+
".env",
|
|
38
|
+
".env.*"
|
|
39
|
+
];
|
|
7
40
|
const sourceCandidateContentCache = /* @__PURE__ */ new Map();
|
|
8
41
|
function cleanUrl(id) {
|
|
9
42
|
return resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
|
|
@@ -14,6 +47,50 @@ function resolveOutDirIgnorePattern(root, outDir) {
|
|
|
14
47
|
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return;
|
|
15
48
|
return `${toPosixPath(relative)}/**`;
|
|
16
49
|
}
|
|
50
|
+
function normalizeScanEntries(root, entries, outDirIgnore) {
|
|
51
|
+
const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
|
|
52
|
+
const scanEntries = entries?.length ? hasPositiveEntry ? entries : [{
|
|
53
|
+
base: root,
|
|
54
|
+
pattern: "**/*",
|
|
55
|
+
negated: false
|
|
56
|
+
}, ...entries] : void 0;
|
|
57
|
+
if (!outDirIgnore) return scanEntries;
|
|
58
|
+
return [...scanEntries ?? [{
|
|
59
|
+
base: root,
|
|
60
|
+
pattern: "**/*",
|
|
61
|
+
negated: false
|
|
62
|
+
}], {
|
|
63
|
+
base: root,
|
|
64
|
+
pattern: outDirIgnore,
|
|
65
|
+
negated: true
|
|
66
|
+
}];
|
|
67
|
+
}
|
|
68
|
+
function shouldApplyDefaultIgnoredSources(entries) {
|
|
69
|
+
return entries?.length === void 0 ? false : entries.length > 0 && entries.every((entry) => entry.negated);
|
|
70
|
+
}
|
|
71
|
+
function createDefaultIgnoredSources(root, outDirIgnore, entries) {
|
|
72
|
+
return [...shouldApplyDefaultIgnoredSources(entries) ? [
|
|
73
|
+
...TAILWIND_V4_IGNORED_CONTENT_DIRS.map((pattern) => ({
|
|
74
|
+
base: root,
|
|
75
|
+
pattern: `**/${pattern}/**`,
|
|
76
|
+
negated: true
|
|
77
|
+
})),
|
|
78
|
+
...TAILWIND_V4_IGNORED_EXTENSIONS.map((extension) => ({
|
|
79
|
+
base: root,
|
|
80
|
+
pattern: `**/*.${extension}`,
|
|
81
|
+
negated: true
|
|
82
|
+
})),
|
|
83
|
+
...TAILWIND_V4_IGNORED_FILES.map((pattern) => ({
|
|
84
|
+
base: root,
|
|
85
|
+
pattern: `**/${pattern}`,
|
|
86
|
+
negated: true
|
|
87
|
+
}))
|
|
88
|
+
] : [], ...outDirIgnore ? [{
|
|
89
|
+
base: root,
|
|
90
|
+
pattern: outDirIgnore,
|
|
91
|
+
negated: true
|
|
92
|
+
}] : []];
|
|
93
|
+
}
|
|
17
94
|
function resolveSourceCandidateExtension(id) {
|
|
18
95
|
const normalized = cleanUrl(id);
|
|
19
96
|
return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
|
|
@@ -79,18 +156,12 @@ function createSourceCandidateCollector() {
|
|
|
79
156
|
async function scanRoot({ entries, root, outDir }) {
|
|
80
157
|
const resolvedRoot = path.resolve(root);
|
|
81
158
|
const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, outDir);
|
|
82
|
-
const scanEntries =
|
|
83
|
-
|
|
84
|
-
pattern: "**/*",
|
|
85
|
-
negated: false
|
|
86
|
-
}], {
|
|
87
|
-
base: resolvedRoot,
|
|
88
|
-
pattern: outDirIgnore,
|
|
89
|
-
negated: true
|
|
90
|
-
}] : entries;
|
|
159
|
+
const scanEntries = normalizeScanEntries(resolvedRoot, entries, outDirIgnore);
|
|
160
|
+
const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, entries);
|
|
91
161
|
const files = await resolveProjectSourceFiles({
|
|
92
162
|
cwd: resolvedRoot,
|
|
93
163
|
...scanEntries === void 0 ? {} : { sources: scanEntries },
|
|
164
|
+
...ignoredSources.length > 0 ? { ignoredSources } : {},
|
|
94
165
|
filter: isSourceCandidateRequest
|
|
95
166
|
});
|
|
96
167
|
await Promise.all(files.map((file) => syncFile(file)));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-CxCp7Ydh.js");
|
|
3
3
|
require("./utils-4ODFyoqD.js");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_module = require("node:module");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as omitUndefined, H as readInstalledPackageMajorVersion, J as findWorkspaceRoot, K as findNearestPackageRoot, V as createTailwindcssPatcher, f as runtimeSignaturePatchersSymbol, q as findWorkspacePackageDir } from "./v3-engine-
|
|
1
|
+
import { G as omitUndefined, H as readInstalledPackageMajorVersion, J as findWorkspaceRoot, K as findNearestPackageRoot, V as createTailwindcssPatcher, f as runtimeSignaturePatchersSymbol, q as findWorkspacePackageDir } from "./v3-engine-CzD7OvXg.mjs";
|
|
2
2
|
import { n as defuOverrideArray } from "./utils-CGBVVNm6.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -444,8 +444,8 @@ function isFileMatchedByTailwindSourceEntries(file, entries) {
|
|
|
444
444
|
if (!entries?.length) return true;
|
|
445
445
|
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
446
446
|
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
447
|
-
if (positiveEntries.length === 0) return false;
|
|
448
447
|
const resolvedFile = resolveSourceScanPath(file);
|
|
448
|
+
if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
449
449
|
if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
|
|
450
450
|
return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
451
451
|
}
|
|
@@ -1488,6 +1488,37 @@ function createTailwindV4DefaultColorThemeCss() {
|
|
|
1488
1488
|
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1489
1489
|
const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
|
|
1490
1490
|
const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
|
|
1491
|
+
const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
|
|
1492
|
+
const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:([-+]?(?:\d+|\d*\.\d+)rpx)\\\]/g;
|
|
1493
|
+
const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
|
|
1494
|
+
"**/.git/**",
|
|
1495
|
+
"**/.hg/**",
|
|
1496
|
+
"**/.jj/**",
|
|
1497
|
+
"**/.next/**",
|
|
1498
|
+
"**/.parcel-cache/**",
|
|
1499
|
+
"**/.pnpm-store/**",
|
|
1500
|
+
"**/.svelte-kit/**",
|
|
1501
|
+
"**/.svn/**",
|
|
1502
|
+
"**/.turbo/**",
|
|
1503
|
+
"**/.venv/**",
|
|
1504
|
+
"**/.vercel/**",
|
|
1505
|
+
"**/.yarn/**",
|
|
1506
|
+
"**/__pycache__/**",
|
|
1507
|
+
"**/node_modules/**",
|
|
1508
|
+
"**/venv/**",
|
|
1509
|
+
"**/*.less",
|
|
1510
|
+
"**/*.lock",
|
|
1511
|
+
"**/*.sass",
|
|
1512
|
+
"**/*.scss",
|
|
1513
|
+
"**/*.styl",
|
|
1514
|
+
"**/*.log",
|
|
1515
|
+
"**/package-lock.json",
|
|
1516
|
+
"**/pnpm-lock.yaml",
|
|
1517
|
+
"**/bun.lockb",
|
|
1518
|
+
"**/.gitignore",
|
|
1519
|
+
"**/.env",
|
|
1520
|
+
"**/.env.*"
|
|
1521
|
+
];
|
|
1491
1522
|
function findLeadingImportInsertionIndex(css) {
|
|
1492
1523
|
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
1493
1524
|
let insertionIndex = 0;
|
|
@@ -1507,6 +1538,35 @@ function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
|
1507
1538
|
function collectCandidates$1(candidates) {
|
|
1508
1539
|
return new Set(candidates ?? []);
|
|
1509
1540
|
}
|
|
1541
|
+
function normalizeRpxTextCandidate(candidate) {
|
|
1542
|
+
return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
|
|
1543
|
+
}
|
|
1544
|
+
function normalizeRpxTextCandidates(candidates) {
|
|
1545
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
1546
|
+
const restoreCandidates = /* @__PURE__ */ new Map();
|
|
1547
|
+
for (const candidate of candidates) {
|
|
1548
|
+
const normalizedCandidate = normalizeRpxTextCandidate(candidate);
|
|
1549
|
+
normalized.add(normalizedCandidate);
|
|
1550
|
+
if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
|
|
1551
|
+
}
|
|
1552
|
+
return {
|
|
1553
|
+
candidates: normalized,
|
|
1554
|
+
restoreCandidates
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
function restoreRpxTextCandidates(candidates, restoreCandidates) {
|
|
1558
|
+
if (restoreCandidates.size === 0) return new Set(candidates);
|
|
1559
|
+
return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
|
|
1560
|
+
}
|
|
1561
|
+
function restoreRpxTextCssSelectors(css, restoreCandidates) {
|
|
1562
|
+
if (restoreCandidates.size === 0 || !css.includes("text-\\[length\\:")) return css;
|
|
1563
|
+
const restoredValues = new Set([...restoreCandidates.keys()].map((candidate) => {
|
|
1564
|
+
return BARE_RPX_TEXT_CANDIDATE_RE.exec(candidate.replace("[length:", "["))?.[2];
|
|
1565
|
+
}).filter((value) => Boolean(value)));
|
|
1566
|
+
return css.replace(RPX_TEXT_LENGTH_SELECTOR_RE, (match, value) => {
|
|
1567
|
+
return restoredValues.has(value) ? `text-\\[${value}\\]` : match;
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1510
1570
|
function createStableJson$1(value) {
|
|
1511
1571
|
if (value === void 0) return "undefined";
|
|
1512
1572
|
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
@@ -1663,6 +1723,20 @@ function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
|
1663
1723
|
function resolveSourceBase$1(base, sourcePath) {
|
|
1664
1724
|
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
1665
1725
|
}
|
|
1726
|
+
function createDefaultIgnoredScanSources(base) {
|
|
1727
|
+
return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
|
|
1728
|
+
base,
|
|
1729
|
+
pattern,
|
|
1730
|
+
negated: true
|
|
1731
|
+
}));
|
|
1732
|
+
}
|
|
1733
|
+
function normalizeCssDefinedScanSources(base, entries) {
|
|
1734
|
+
return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
|
|
1735
|
+
base,
|
|
1736
|
+
pattern: "**/*",
|
|
1737
|
+
negated: false
|
|
1738
|
+
}, ...entries] : entries;
|
|
1739
|
+
}
|
|
1666
1740
|
async function resolveCssDefinedScanSources(source) {
|
|
1667
1741
|
let importSourceBase;
|
|
1668
1742
|
let hasSourceNone = false;
|
|
@@ -1683,11 +1757,15 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1683
1757
|
});
|
|
1684
1758
|
const sourcePatterns = await resolveCssSourceEntries(root, source.base, "**/*");
|
|
1685
1759
|
if (!importSourceBase) {
|
|
1686
|
-
if (sourcePatterns.length > 0) return sourcePatterns;
|
|
1760
|
+
if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
|
|
1687
1761
|
if (hasSourceNone) return false;
|
|
1688
1762
|
return;
|
|
1689
1763
|
}
|
|
1690
|
-
return [
|
|
1764
|
+
return [
|
|
1765
|
+
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1766
|
+
...sourcePatterns,
|
|
1767
|
+
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1768
|
+
];
|
|
1691
1769
|
}
|
|
1692
1770
|
async function resolveScanSources(source, scanSources) {
|
|
1693
1771
|
if (scanSources !== true) return scanSources;
|
|
@@ -1727,16 +1805,18 @@ function createTailwindV4Engine(source) {
|
|
|
1727
1805
|
const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
|
|
1728
1806
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1729
1807
|
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources)) : void 0;
|
|
1730
|
-
const
|
|
1808
|
+
const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates$1(patchOptions.candidates), ...filesystemCandidates ?? []]), target));
|
|
1731
1809
|
const result = await engine.generate(omitUndefined({
|
|
1732
1810
|
scanSources: false,
|
|
1733
1811
|
...patchOptions,
|
|
1734
|
-
candidates:
|
|
1812
|
+
candidates: normalizedCandidates.candidates
|
|
1735
1813
|
}));
|
|
1736
|
-
const rawCss = result.css;
|
|
1814
|
+
const rawCss = restoreRpxTextCssSelectors(result.css, normalizedCandidates.restoreCandidates);
|
|
1737
1815
|
const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
|
|
1738
1816
|
return {
|
|
1739
1817
|
...result,
|
|
1818
|
+
classSet: restoreRpxTextCandidates(result.classSet, normalizedCandidates.restoreCandidates),
|
|
1819
|
+
rawCandidates: restoreRpxTextCandidates(result.rawCandidates, normalizedCandidates.restoreCandidates),
|
|
1740
1820
|
css,
|
|
1741
1821
|
rawCss,
|
|
1742
1822
|
target
|
|
@@ -1776,15 +1856,18 @@ function createTailwindV4Engine(source) {
|
|
|
1776
1856
|
target: cached.target
|
|
1777
1857
|
};
|
|
1778
1858
|
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1779
|
-
const
|
|
1859
|
+
const designSystem = await cached.designSystemPromise;
|
|
1860
|
+
const normalizedMissing = normalizeRpxTextCandidates(missingCandidates);
|
|
1861
|
+
const normalizedMissingCandidates = [...normalizedMissing.candidates];
|
|
1862
|
+
const cssByCandidate = designSystem.candidatesToCss(normalizedMissingCandidates);
|
|
1780
1863
|
const rawCssParts = [];
|
|
1781
1864
|
const classSet = /* @__PURE__ */ new Set();
|
|
1782
|
-
for (let index = 0; index <
|
|
1783
|
-
const candidate =
|
|
1865
|
+
for (let index = 0; index < normalizedMissingCandidates.length; index += 1) {
|
|
1866
|
+
const candidate = normalizedMissingCandidates[index];
|
|
1784
1867
|
const css = cssByCandidate[index];
|
|
1785
1868
|
if (candidate && typeof css === "string" && css.trim().length > 0) {
|
|
1786
|
-
rawCssParts.push(css);
|
|
1787
|
-
classSet.add(candidate);
|
|
1869
|
+
rawCssParts.push(restoreRpxTextCssSelectors(css, normalizedMissing.restoreCandidates));
|
|
1870
|
+
classSet.add(normalizedMissing.restoreCandidates.get(candidate) ?? candidate);
|
|
1788
1871
|
}
|
|
1789
1872
|
}
|
|
1790
1873
|
const rawCss = rawCssParts.join("\n");
|
|
@@ -2260,6 +2343,7 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
2260
2343
|
let hasTailwindCssImport = false;
|
|
2261
2344
|
const [sourceEntries, configEntries] = await Promise.all([resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
|
|
2262
2345
|
const entries = [...configEntries.entries, ...sourceEntries];
|
|
2346
|
+
const hasPositiveEntries = entries.some((entry) => !entry.negated);
|
|
2263
2347
|
const inlineCandidates = collectCssInlineSourceCandidates(root);
|
|
2264
2348
|
root.walkAtRules("import", (rule) => {
|
|
2265
2349
|
if (!isTailwindCssImport(rule.params)) return;
|
|
@@ -2284,7 +2368,7 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
2284
2368
|
inlineCandidates,
|
|
2285
2369
|
dependencies: configEntries.dependencies
|
|
2286
2370
|
};
|
|
2287
|
-
if (
|
|
2371
|
+
if (hasPositiveEntries) return {
|
|
2288
2372
|
entries,
|
|
2289
2373
|
explicit: true,
|
|
2290
2374
|
inlineCandidates,
|
|
@@ -2297,7 +2381,7 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
2297
2381
|
dependencies: configEntries.dependencies
|
|
2298
2382
|
};
|
|
2299
2383
|
return hasTailwindCssImport ? {
|
|
2300
|
-
entries
|
|
2384
|
+
entries,
|
|
2301
2385
|
explicit: false,
|
|
2302
2386
|
inlineCandidates,
|
|
2303
2387
|
dependencies: configEntries.dependencies
|
|
@@ -436,8 +436,8 @@ function isFileMatchedByTailwindSourceEntries(file, entries) {
|
|
|
436
436
|
if (!entries?.length) return true;
|
|
437
437
|
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
438
438
|
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
439
|
-
if (positiveEntries.length === 0) return false;
|
|
440
439
|
const resolvedFile = resolveSourceScanPath(file);
|
|
440
|
+
if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
441
441
|
if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
|
|
442
442
|
return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
443
443
|
}
|
|
@@ -1480,6 +1480,37 @@ function createTailwindV4DefaultColorThemeCss() {
|
|
|
1480
1480
|
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1481
1481
|
const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
|
|
1482
1482
|
const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
|
|
1483
|
+
const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
|
|
1484
|
+
const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:([-+]?(?:\d+|\d*\.\d+)rpx)\\\]/g;
|
|
1485
|
+
const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
|
|
1486
|
+
"**/.git/**",
|
|
1487
|
+
"**/.hg/**",
|
|
1488
|
+
"**/.jj/**",
|
|
1489
|
+
"**/.next/**",
|
|
1490
|
+
"**/.parcel-cache/**",
|
|
1491
|
+
"**/.pnpm-store/**",
|
|
1492
|
+
"**/.svelte-kit/**",
|
|
1493
|
+
"**/.svn/**",
|
|
1494
|
+
"**/.turbo/**",
|
|
1495
|
+
"**/.venv/**",
|
|
1496
|
+
"**/.vercel/**",
|
|
1497
|
+
"**/.yarn/**",
|
|
1498
|
+
"**/__pycache__/**",
|
|
1499
|
+
"**/node_modules/**",
|
|
1500
|
+
"**/venv/**",
|
|
1501
|
+
"**/*.less",
|
|
1502
|
+
"**/*.lock",
|
|
1503
|
+
"**/*.sass",
|
|
1504
|
+
"**/*.scss",
|
|
1505
|
+
"**/*.styl",
|
|
1506
|
+
"**/*.log",
|
|
1507
|
+
"**/package-lock.json",
|
|
1508
|
+
"**/pnpm-lock.yaml",
|
|
1509
|
+
"**/bun.lockb",
|
|
1510
|
+
"**/.gitignore",
|
|
1511
|
+
"**/.env",
|
|
1512
|
+
"**/.env.*"
|
|
1513
|
+
];
|
|
1483
1514
|
function findLeadingImportInsertionIndex(css) {
|
|
1484
1515
|
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
1485
1516
|
let insertionIndex = 0;
|
|
@@ -1499,6 +1530,35 @@ function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
|
1499
1530
|
function collectCandidates$1(candidates) {
|
|
1500
1531
|
return new Set(candidates ?? []);
|
|
1501
1532
|
}
|
|
1533
|
+
function normalizeRpxTextCandidate(candidate) {
|
|
1534
|
+
return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
|
|
1535
|
+
}
|
|
1536
|
+
function normalizeRpxTextCandidates(candidates) {
|
|
1537
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
1538
|
+
const restoreCandidates = /* @__PURE__ */ new Map();
|
|
1539
|
+
for (const candidate of candidates) {
|
|
1540
|
+
const normalizedCandidate = normalizeRpxTextCandidate(candidate);
|
|
1541
|
+
normalized.add(normalizedCandidate);
|
|
1542
|
+
if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
|
|
1543
|
+
}
|
|
1544
|
+
return {
|
|
1545
|
+
candidates: normalized,
|
|
1546
|
+
restoreCandidates
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
function restoreRpxTextCandidates(candidates, restoreCandidates) {
|
|
1550
|
+
if (restoreCandidates.size === 0) return new Set(candidates);
|
|
1551
|
+
return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
|
|
1552
|
+
}
|
|
1553
|
+
function restoreRpxTextCssSelectors(css, restoreCandidates) {
|
|
1554
|
+
if (restoreCandidates.size === 0 || !css.includes("text-\\[length\\:")) return css;
|
|
1555
|
+
const restoredValues = new Set([...restoreCandidates.keys()].map((candidate) => {
|
|
1556
|
+
return BARE_RPX_TEXT_CANDIDATE_RE.exec(candidate.replace("[length:", "["))?.[2];
|
|
1557
|
+
}).filter((value) => Boolean(value)));
|
|
1558
|
+
return css.replace(RPX_TEXT_LENGTH_SELECTOR_RE, (match, value) => {
|
|
1559
|
+
return restoredValues.has(value) ? `text-\\[${value}\\]` : match;
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1502
1562
|
function createStableJson$1(value) {
|
|
1503
1563
|
if (value === void 0) return "undefined";
|
|
1504
1564
|
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
@@ -1655,6 +1715,20 @@ function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
|
1655
1715
|
function resolveSourceBase$1(base, sourcePath) {
|
|
1656
1716
|
return path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
|
|
1657
1717
|
}
|
|
1718
|
+
function createDefaultIgnoredScanSources(base) {
|
|
1719
|
+
return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
|
|
1720
|
+
base,
|
|
1721
|
+
pattern,
|
|
1722
|
+
negated: true
|
|
1723
|
+
}));
|
|
1724
|
+
}
|
|
1725
|
+
function normalizeCssDefinedScanSources(base, entries) {
|
|
1726
|
+
return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
|
|
1727
|
+
base,
|
|
1728
|
+
pattern: "**/*",
|
|
1729
|
+
negated: false
|
|
1730
|
+
}, ...entries] : entries;
|
|
1731
|
+
}
|
|
1658
1732
|
async function resolveCssDefinedScanSources(source) {
|
|
1659
1733
|
let importSourceBase;
|
|
1660
1734
|
let hasSourceNone = false;
|
|
@@ -1675,11 +1749,15 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1675
1749
|
});
|
|
1676
1750
|
const sourcePatterns = await resolveCssSourceEntries(root, source.base, "**/*");
|
|
1677
1751
|
if (!importSourceBase) {
|
|
1678
|
-
if (sourcePatterns.length > 0) return sourcePatterns;
|
|
1752
|
+
if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
|
|
1679
1753
|
if (hasSourceNone) return false;
|
|
1680
1754
|
return;
|
|
1681
1755
|
}
|
|
1682
|
-
return [
|
|
1756
|
+
return [
|
|
1757
|
+
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1758
|
+
...sourcePatterns,
|
|
1759
|
+
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1760
|
+
];
|
|
1683
1761
|
}
|
|
1684
1762
|
async function resolveScanSources(source, scanSources) {
|
|
1685
1763
|
if (scanSources !== true) return scanSources;
|
|
@@ -1719,16 +1797,18 @@ function createTailwindV4Engine$1(source) {
|
|
|
1719
1797
|
const engine = createTailwindV4Engine(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
|
|
1720
1798
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1721
1799
|
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await extractRawCandidates(resolvedScanSources)) : void 0;
|
|
1722
|
-
const
|
|
1800
|
+
const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates$1(patchOptions.candidates), ...filesystemCandidates ?? []]), target));
|
|
1723
1801
|
const result = await engine.generate(omitUndefined({
|
|
1724
1802
|
scanSources: false,
|
|
1725
1803
|
...patchOptions,
|
|
1726
|
-
candidates:
|
|
1804
|
+
candidates: normalizedCandidates.candidates
|
|
1727
1805
|
}));
|
|
1728
|
-
const rawCss = result.css;
|
|
1806
|
+
const rawCss = restoreRpxTextCssSelectors(result.css, normalizedCandidates.restoreCandidates);
|
|
1729
1807
|
const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
|
|
1730
1808
|
return {
|
|
1731
1809
|
...result,
|
|
1810
|
+
classSet: restoreRpxTextCandidates(result.classSet, normalizedCandidates.restoreCandidates),
|
|
1811
|
+
rawCandidates: restoreRpxTextCandidates(result.rawCandidates, normalizedCandidates.restoreCandidates),
|
|
1732
1812
|
css,
|
|
1733
1813
|
rawCss,
|
|
1734
1814
|
target
|
|
@@ -1768,15 +1848,18 @@ function createTailwindV4Engine$1(source) {
|
|
|
1768
1848
|
target: cached.target
|
|
1769
1849
|
};
|
|
1770
1850
|
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1771
|
-
const
|
|
1851
|
+
const designSystem = await cached.designSystemPromise;
|
|
1852
|
+
const normalizedMissing = normalizeRpxTextCandidates(missingCandidates);
|
|
1853
|
+
const normalizedMissingCandidates = [...normalizedMissing.candidates];
|
|
1854
|
+
const cssByCandidate = designSystem.candidatesToCss(normalizedMissingCandidates);
|
|
1772
1855
|
const rawCssParts = [];
|
|
1773
1856
|
const classSet = /* @__PURE__ */ new Set();
|
|
1774
|
-
for (let index = 0; index <
|
|
1775
|
-
const candidate =
|
|
1857
|
+
for (let index = 0; index < normalizedMissingCandidates.length; index += 1) {
|
|
1858
|
+
const candidate = normalizedMissingCandidates[index];
|
|
1776
1859
|
const css = cssByCandidate[index];
|
|
1777
1860
|
if (candidate && typeof css === "string" && css.trim().length > 0) {
|
|
1778
|
-
rawCssParts.push(css);
|
|
1779
|
-
classSet.add(candidate);
|
|
1861
|
+
rawCssParts.push(restoreRpxTextCssSelectors(css, normalizedMissing.restoreCandidates));
|
|
1862
|
+
classSet.add(normalizedMissing.restoreCandidates.get(candidate) ?? candidate);
|
|
1780
1863
|
}
|
|
1781
1864
|
}
|
|
1782
1865
|
const rawCss = rawCssParts.join("\n");
|
|
@@ -2252,6 +2335,7 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
2252
2335
|
let hasTailwindCssImport = false;
|
|
2253
2336
|
const [sourceEntries, configEntries] = await Promise.all([resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
|
|
2254
2337
|
const entries = [...configEntries.entries, ...sourceEntries];
|
|
2338
|
+
const hasPositiveEntries = entries.some((entry) => !entry.negated);
|
|
2255
2339
|
const inlineCandidates = collectCssInlineSourceCandidates(root);
|
|
2256
2340
|
root.walkAtRules("import", (rule) => {
|
|
2257
2341
|
if (!isTailwindCssImport(rule.params)) return;
|
|
@@ -2276,7 +2360,7 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
2276
2360
|
inlineCandidates,
|
|
2277
2361
|
dependencies: configEntries.dependencies
|
|
2278
2362
|
};
|
|
2279
|
-
if (
|
|
2363
|
+
if (hasPositiveEntries) return {
|
|
2280
2364
|
entries,
|
|
2281
2365
|
explicit: true,
|
|
2282
2366
|
inlineCandidates,
|
|
@@ -2289,7 +2373,7 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
|
2289
2373
|
dependencies: configEntries.dependencies
|
|
2290
2374
|
};
|
|
2291
2375
|
return hasTailwindCssImport ? {
|
|
2292
|
-
entries
|
|
2376
|
+
entries,
|
|
2293
2377
|
explicit: false,
|
|
2294
2378
|
inlineCandidates,
|
|
2295
2379
|
dependencies: configEntries.dependencies
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { B as createDebug, E as filterUnsupportedMiniProgramTailwindV4Candidates, G as omitUndefined, K as findNearestPackageRoot, U as findTailwindConfig, W as resolveTailwindcssOptions, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, v as resolveViteTailwindV4CssDependencies } from "./v3-engine-
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-
|
|
3
|
-
import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-
|
|
4
|
-
import { a as analyzeSource, c as isClassContextLiteralPath, g as createTailwindRuntimeReadyPromise, h as collectRuntimeClassSet, i as createAttributeMatcher, l as replaceWxml, m as toCustomAttributesEntities, n as getCompilerContext, o as JsTokenUpdater, p as vitePluginName, r as generateCode, s as _defineProperty, t as shouldSkipJsTransform, u as babelParse, v as refreshTailwindRuntimeState } from "./precheck-
|
|
1
|
+
import { B as createDebug, E as filterUnsupportedMiniProgramTailwindV4Candidates, G as omitUndefined, K as findNearestPackageRoot, U as findTailwindConfig, W as resolveTailwindcssOptions, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, v as resolveViteTailwindV4CssDependencies } from "./v3-engine-CzD7OvXg.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-BP_VdS_x.mjs";
|
|
3
|
+
import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-DEf-VOwB.mjs";
|
|
4
|
+
import { a as analyzeSource, c as isClassContextLiteralPath, g as createTailwindRuntimeReadyPromise, h as collectRuntimeClassSet, i as createAttributeMatcher, l as replaceWxml, m as toCustomAttributesEntities, n as getCompilerContext, o as JsTokenUpdater, p as vitePluginName, r as generateCode, s as _defineProperty, t as shouldSkipJsTransform, u as babelParse, v as refreshTailwindRuntimeState } from "./precheck-DT3ydSET.mjs";
|
|
5
5
|
import { o as resolveUniUtsPlatform } from "./utils-CGBVVNm6.mjs";
|
|
6
|
-
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-
|
|
7
|
-
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-
|
|
8
|
-
import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-
|
|
6
|
+
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-eov9DmH3.mjs";
|
|
7
|
+
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-CvmmNj4x.mjs";
|
|
8
|
+
import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-CCjtHdeS.mjs";
|
|
9
9
|
import { t as logger$1 } from "./logger-CZUxvJJD.mjs";
|
|
10
10
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
11
11
|
import postcss from "postcss";
|
|
@@ -559,7 +559,7 @@ function createCssHandlerOptions(opts, majorVersion, file) {
|
|
|
559
559
|
}
|
|
560
560
|
function shouldGenerateCssByGenerator(opts, file, rawSource, processed) {
|
|
561
561
|
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
562
|
-
if (generatorOptions.target === "web") return false;
|
|
562
|
+
if (generatorOptions.target === "web" && opts.twPatcher.majorVersion !== 3) return false;
|
|
563
563
|
if (hasTailwindGeneratedCssMarkers(rawSource) || hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
564
564
|
if (opts.twPatcher.majorVersion === 3) return false;
|
|
565
565
|
return processed && shouldFinalizeProcessedCssAsset(opts, file);
|
|
@@ -635,7 +635,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
635
635
|
styleHandler: opts.styleHandler,
|
|
636
636
|
debug
|
|
637
637
|
}) : void 0;
|
|
638
|
-
const nextCss = generated?.css ?? (await opts.styleHandler(rawSource, cssHandlerOptions)).css;
|
|
638
|
+
const nextCss = generated?.css ?? (generatorOptions.target === "web" ? rawSource : (await opts.styleHandler(rawSource, cssHandlerOptions)).css);
|
|
639
639
|
if (generated) {
|
|
640
640
|
registerGeneratorDependencies$1(this, generated.dependencies);
|
|
641
641
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
@@ -991,6 +991,7 @@ function createGenerateBundleHook(context) {
|
|
|
991
991
|
const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
|
|
992
992
|
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
993
993
|
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
994
|
+
const shouldGenerateWebCssByGenerator = isWebGeneratorTarget && runtimeState.twPatcher.majorVersion === 3;
|
|
994
995
|
const { getCssHandlerOptions, getCssUserHandlerOptions } = cssHandlerOptions;
|
|
995
996
|
await runtimeState.readyPromise;
|
|
996
997
|
debug("start");
|
|
@@ -1032,7 +1033,7 @@ function createGenerateBundleHook(context) {
|
|
|
1032
1033
|
const snapshotStart = performance.now();
|
|
1033
1034
|
const snapshot = buildBundleSnapshot(bundle, opts, outDir, state, disableDirtyOptimization || !useIncrementalMode);
|
|
1034
1035
|
recordTimingDetail("snapshot", snapshotStart);
|
|
1035
|
-
const useBundleRuntimeClassSet = useIncrementalMode || runtimeState.twPatcher.majorVersion === 4;
|
|
1036
|
+
const useBundleRuntimeClassSet = !isWebGeneratorTarget && (useIncrementalMode || runtimeState.twPatcher.majorVersion === 4);
|
|
1036
1037
|
const forceRuntimeRefreshBySource = useIncrementalMode && hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
1037
1038
|
const processFiles = snapshot.processFiles;
|
|
1038
1039
|
logBundleProcessPlan({
|
|
@@ -1052,7 +1053,7 @@ function createGenerateBundleHook(context) {
|
|
|
1052
1053
|
const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
1053
1054
|
const useV3OxideSourceRuntime = runtimeState.twPatcher.majorVersion === 3 && sourceCandidates.size > 0 && hasCssAssetEntry && !forceRuntimeRefreshByEnv && !disableV3OxideSourceRuntime;
|
|
1054
1055
|
const runtimeStart = performance.now();
|
|
1055
|
-
const runtime = useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, {
|
|
1056
|
+
const runtime = isWebGeneratorTarget && !shouldGenerateWebCssByGenerator ? /* @__PURE__ */ new Set() : useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, {
|
|
1056
1057
|
allowBaselineOnlyInitialSync: true,
|
|
1057
1058
|
baseClassSet: sourceCandidates
|
|
1058
1059
|
}) : useBundleRuntimeClassSet ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, { allowBaselineOnlyInitialSync: buildCommand }) : await context.ensureRuntimeClassSet(forceRuntimeRefreshByEnv);
|
|
@@ -1113,6 +1114,10 @@ function createGenerateBundleHook(context) {
|
|
|
1113
1114
|
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
1114
1115
|
if (type === "html" && originalSource.type === "asset") {
|
|
1115
1116
|
metrics.html.total++;
|
|
1117
|
+
if (isWebGeneratorTarget) {
|
|
1118
|
+
debug("html skip web target: %s", file);
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1116
1121
|
if (!processFiles.html.has(file)) continue;
|
|
1117
1122
|
const rawSource = originalEntrySource;
|
|
1118
1123
|
tasks.push(timeTask("html", () => processCachedTask({
|
|
@@ -1177,7 +1182,7 @@ function createGenerateBundleHook(context) {
|
|
|
1177
1182
|
debug("css skip vite-processed asset: %s", outputFile);
|
|
1178
1183
|
continue;
|
|
1179
1184
|
}
|
|
1180
|
-
if (isWebGeneratorTarget) {
|
|
1185
|
+
if (isWebGeneratorTarget && !shouldGenerateWebCssByGenerator) {
|
|
1181
1186
|
applyCssResult(rawSource);
|
|
1182
1187
|
markCssAssetProcessed?.(originalSource, outputFile);
|
|
1183
1188
|
onUpdate(outputFile, rawSource, rawSource);
|
|
@@ -1254,6 +1259,12 @@ function createGenerateBundleHook(context) {
|
|
|
1254
1259
|
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, outputFile);
|
|
1255
1260
|
return generated.css;
|
|
1256
1261
|
}
|
|
1262
|
+
if (isWebGeneratorTarget) {
|
|
1263
|
+
metrics.css.elapsed += measureElapsed(start);
|
|
1264
|
+
metrics.css.transformed++;
|
|
1265
|
+
debug("css preserve web target: %s", outputFile);
|
|
1266
|
+
return rawSource;
|
|
1267
|
+
}
|
|
1257
1268
|
const { css } = await styleHandler(rawSource, getCssHandlerOptions(file));
|
|
1258
1269
|
if (debugCssDiff) debug("css diff %s: %s", file, summarizeStringDiff(rawSource, css));
|
|
1259
1270
|
metrics.css.elapsed += measureElapsed(start);
|
|
@@ -1272,6 +1283,10 @@ function createGenerateBundleHook(context) {
|
|
|
1272
1283
|
}
|
|
1273
1284
|
if (type !== "js") continue;
|
|
1274
1285
|
metrics.js.total++;
|
|
1286
|
+
if (isWebGeneratorTarget) {
|
|
1287
|
+
debug("js skip web target: %s", file);
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1275
1290
|
const shouldTransformJs = !useIncrementalMode || processFiles.js.has(file);
|
|
1276
1291
|
if (!shouldTransformJs) debug("js skip transform (clean), replay cache: %s", file);
|
|
1277
1292
|
if (originalSource.type === "chunk") {
|
|
@@ -1621,13 +1636,14 @@ function stripTailwindConfigDirectives(code) {
|
|
|
1621
1636
|
return code.replace(/^\s*@config\s+(?:"[^"]+"|'[^']+')[^;\n]*;\s*$/gm, "");
|
|
1622
1637
|
}
|
|
1623
1638
|
function createRewriteCssImportsPlugins(options) {
|
|
1624
|
-
if (!options.shouldRewrite) return [];
|
|
1639
|
+
if (!options.shouldRewrite && !options.shouldOwnTailwindGeneration) return [];
|
|
1625
1640
|
const { appType, getAppType, rootImport, shouldOwnTailwindGeneration, weappTailwindcssDirPosix } = options;
|
|
1626
1641
|
const resolveAppType = () => getAppType?.() ?? appType;
|
|
1627
1642
|
return [{
|
|
1628
1643
|
name: `${vitePluginName}:rewrite-css-imports`,
|
|
1629
1644
|
enforce: "pre",
|
|
1630
1645
|
resolveId(id, importer) {
|
|
1646
|
+
if (!options.shouldRewrite) return null;
|
|
1631
1647
|
const replacement = resolveTailwindcssImport(id, weappTailwindcssDirPosix, {
|
|
1632
1648
|
join: joinPosixPath,
|
|
1633
1649
|
appType: resolveAppType(),
|
|
@@ -1649,6 +1665,7 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
1649
1665
|
};
|
|
1650
1666
|
}
|
|
1651
1667
|
}
|
|
1668
|
+
if (!options.shouldRewrite) return null;
|
|
1652
1669
|
const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, {
|
|
1653
1670
|
join: joinPosixPath,
|
|
1654
1671
|
appType: resolveAppType(),
|
|
@@ -1858,7 +1875,9 @@ function WeappTailwindcss(options = {}) {
|
|
|
1858
1875
|
const tailwindcssMajorVersion = initialTwPatcher.majorVersion ?? 0;
|
|
1859
1876
|
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
1860
1877
|
const shouldRewriteCssImports = tailwindcssMajorVersion >= 4;
|
|
1861
|
-
const
|
|
1878
|
+
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
1879
|
+
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
1880
|
+
const shouldInferAppType = !hasExplicitAppType && generatorOptions.target !== "web";
|
|
1862
1881
|
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots({
|
|
1863
1882
|
...options,
|
|
1864
1883
|
cssEntries: opts.cssEntries ?? options.cssEntries
|
|
@@ -2213,6 +2232,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2213
2232
|
});
|
|
2214
2233
|
const isIosPlatform = resolveUniUtsPlatform().isAppIos;
|
|
2215
2234
|
const prepareTailwindGeneration = async () => {
|
|
2235
|
+
if (isWebGeneratorTarget && runtimeState.twPatcher.majorVersion !== 3) return;
|
|
2216
2236
|
if (shouldDiscoverAutoCssSources()) await discoverAndRegisterAutoCssSources();
|
|
2217
2237
|
await syncSourceCandidateScan();
|
|
2218
2238
|
};
|