@@ -11,7 +11,7 @@ import { clearRequireCache } from '@tailwindcss/node/require-cache'
11
11
import { Scanner } from '@tailwindcss/oxide'
12
12
import fs from 'node:fs'
13
13
import path , { relative } from 'node:path'
14
- import postcss , { type AcceptedPlugin , type PluginCreator } from 'postcss'
14
+ import type { AcceptedPlugin , PluginCreator , Postcss , Root } from 'postcss'
15
15
import { toCss , type AstNode } from '../../tailwindcss/src/ast'
16
16
import { cssAstToPostCssAst , postCssAstToCssAst } from './ast'
17
17
import fixRelativePathsPlugin from './postcss-fix-relative-paths'
@@ -23,13 +23,13 @@ interface CacheEntry {
23
23
compiler : null | ReturnType < typeof compileAst >
24
24
scanner : null | Scanner
25
25
tailwindCssAst : AstNode [ ]
26
- cachedPostCssAst : postcss . Root
27
- optimizedPostCssAst : postcss . Root
26
+ cachedPostCssAst : Root
27
+ optimizedPostCssAst : Root
28
28
fullRebuildPaths : string [ ]
29
29
}
30
30
const cache = new QuickLRU < string , CacheEntry > ( { maxSize : 50 } )
31
31
32
- function getContextFromCache ( inputFile : string , opts : PluginOptions ) : CacheEntry {
32
+ function getContextFromCache ( inputFile : string , opts : PluginOptions , postcss : Postcss ) : CacheEntry {
33
33
let key = `${ inputFile } :${ opts . base ?? '' } :${ JSON . stringify ( opts . optimize ) } `
34
34
if ( cache . has ( key ) ) return cache . get ( key ) !
35
35
let entry = {
@@ -69,7 +69,7 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
69
69
70
70
{
71
71
postcssPlugin : 'tailwindcss' ,
72
- async Once ( root , { result } ) {
72
+ async Once ( root , { result, postcss } ) {
73
73
using I = new Instrumentation ( )
74
74
75
75
let inputFile = result . opts . from ?? ''
@@ -100,7 +100,7 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
100
100
DEBUG && I . end ( 'Quick bail check' )
101
101
}
102
102
103
- let context = getContextFromCache ( inputFile , opts )
103
+ let context = getContextFromCache ( inputFile , opts , postcss )
104
104
let inputBasePath = path . dirname ( path . resolve ( inputFile ) )
105
105
106
106
// Whether this is the first build or not, if it is, then we can
@@ -296,7 +296,7 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
296
296
} else {
297
297
// Convert our AST to a PostCSS AST
298
298
DEBUG && I . start ( 'Transform Tailwind CSS AST into PostCSS AST' )
299
- context . cachedPostCssAst = cssAstToPostCssAst ( tailwindCssAst , root . source )
299
+ context . cachedPostCssAst = cssAstToPostCssAst ( tailwindCssAst , root . source , postcss )
300
300
DEBUG && I . end ( 'Transform Tailwind CSS AST into PostCSS AST' )
301
301
}
302
302
}
0 commit comments