Skip to content

Commit 866512c

Browse files
committed
Use candidatesToAst when supported
1 parent a158e96 commit 866512c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/tailwindcss-language-server/src/util/v4/design-system.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,20 @@ export async function loadDesignSystem(
230230
let cache = design.storage[COMPILE_CACHE] as Record<string, AstNode[]>
231231
let uncached = classes.filter((name) => cache[name] === undefined)
232232

233-
let css = design.candidatesToCss(uncached)
233+
let css = design.candidatesToAst
234+
? design.candidatesToAst(uncached)
235+
: design.candidatesToCss(uncached)
234236

235237
let errors: any[] = []
236238

237239
for (let [idx, cls] of uncached.entries()) {
238240
let str = css[idx]
239241

242+
if (Array.isArray(str)) {
243+
cache[cls] = str
244+
continue
245+
}
246+
240247
if (str === null) {
241248
cache[cls] = []
242249
continue

packages/tailwindcss-language-service/src/util/v4/design-system.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import postcss from 'postcss'
22
import type { NamedVariant } from './candidate'
3-
import type { Rule } from '../../css'
3+
import type { AstNode, Rule } from '../../css'
44

55
export interface Theme {
66
// Prefix didn't exist for earlier Tailwind versions
@@ -54,6 +54,9 @@ export interface DesignSystem {
5454
// Added in v4.1.16
5555
// We can patch it into any design system if it doesn't exist though
5656
storage?: Record<symbol, any>
57+
58+
// Added in v4.1.18
59+
candidatesToAst?(classes: string[]): AstNode[][]
5760
}
5861

5962
export interface DesignSystem {

0 commit comments

Comments
 (0)