Skip to content

Commit 415c76e

Browse files
committed
improvement 1: ignore known invalid candidates
This will reduce the amount of candidates to handle. They would eventually be skipped anyway, but now we don't even have to re-parse (and hit a cache) at all.
1 parent db54617 commit 415c76e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/tailwindcss/src/index.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,21 @@ export function compile(
177177
// Track all valid candidates, these are the incoming `rawCandidate` that
178178
// resulted in a generated AST Node. All the other `rawCandidates` are invalid
179179
// and should be ignored.
180-
let allValidCandidates = new Set(rawCandidates)
180+
let allValidCandidates = new Set<string>()
181+
for (let rawCandidate of rawCandidates) {
182+
if (!designSystem.isInvalidCandidate(rawCandidate)) {
183+
allValidCandidates.add(rawCandidate)
184+
}
185+
}
181186
let compiledCss = toCss(ast)
182187

183188
return {
184189
rebuild(newRawCandidates: string[]) {
185190
// Add all new candidates unless we know that they are invalid.
186191
for (let candidate of newRawCandidates) {
187-
allValidCandidates.add(candidate)
192+
if (!designSystem.isInvalidCandidate(candidate)) {
193+
allValidCandidates.add(candidate)
194+
}
188195
}
189196

190197
if (tailwindUtilitiesNode) {

0 commit comments

Comments
 (0)