@@ -20,7 +20,7 @@ const DEBUG = env.DEBUG
20
20
21
21
interface CacheEntry {
22
22
mtimes : Map < string , number >
23
- compiler : null | Awaited < ReturnType < typeof compileAst > >
23
+ compiler : null | ReturnType < typeof compileAst >
24
24
scanner : null | Scanner
25
25
tailwindCssAst : AstNode [ ]
26
26
cachedPostCssAst : postcss . Root
@@ -138,9 +138,9 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
138
138
139
139
// Setup the compiler if it doesn't exist yet. This way we can
140
140
// guarantee a `build()` function is available.
141
- context . compiler ??= await createCompiler ( )
141
+ context . compiler ??= createCompiler ( )
142
142
143
- if ( context . compiler . features === Features . None ) {
143
+ if ( ( await context . compiler ) . features === Features . None ) {
144
144
return
145
145
}
146
146
@@ -188,25 +188,26 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
188
188
// initial build. If it wasn't, we need to create a new one.
189
189
! isInitialBuild
190
190
) {
191
- context . compiler = await createCompiler ( )
191
+ context . compiler = createCompiler ( )
192
192
}
193
193
194
194
if ( context . scanner === null || rebuildStrategy === 'full' ) {
195
195
DEBUG && I . start ( 'Setup scanner' )
196
+ let compiler = await context . compiler
196
197
let sources = ( ( ) => {
197
198
// Disable auto source detection
198
- if ( context . compiler . root === 'none' ) {
199
+ if ( compiler . root === 'none' ) {
199
200
return [ ]
200
201
}
201
202
202
203
// No root specified, use the base directory
203
- if ( context . compiler . root === null ) {
204
+ if ( compiler . root === null ) {
204
205
return [ { base, pattern : '**/*' , negated : false } ]
205
206
}
206
207
207
208
// Use the specified root
208
- return [ { ...context . compiler . root , negated : false } ]
209
- } ) ( ) . concat ( context . compiler . sources )
209
+ return [ { ...( compiler ? .root ! ?? { } ) , negated : false } ]
210
+ } ) ( ) . concat ( compiler . sources )
210
211
211
212
// Look for candidates used to generate the CSS
212
213
context . scanner = new Scanner ( { sources } )
@@ -215,10 +216,10 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
215
216
216
217
DEBUG && I . start ( 'Scan for candidates' )
217
218
let candidates =
218
- context . compiler . features & Features . Utilities ? context . scanner . scan ( ) : [ ]
219
+ ( await context . compiler ) . features & Features . Utilities ? context . scanner . scan ( ) : [ ]
219
220
DEBUG && I . end ( 'Scan for candidates' )
220
221
221
- if ( context . compiler . features & Features . Utilities ) {
222
+ if ( ( await context . compiler ) . features & Features . Utilities ) {
222
223
DEBUG && I . start ( 'Register dependency messages' )
223
224
// Add all found files as direct dependencies
224
225
for ( let file of context . scanner . files ) {
@@ -267,7 +268,7 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
267
268
}
268
269
269
270
DEBUG && I . start ( 'Build utilities' )
270
- let tailwindCssAst = context . compiler . build ( candidates )
271
+ let tailwindCssAst = ( await context . compiler ) . build ( candidates )
271
272
DEBUG && I . end ( 'Build utilities' )
272
273
273
274
if ( context . tailwindCssAst !== tailwindCssAst ) {
0 commit comments