@@ -68,6 +68,7 @@ import { doCodeActions } from 'tailwindcss-language-service/src/codeActions/code
68
68
import { getDocumentColors } from 'tailwindcss-language-service/src/documentColorProvider'
69
69
import { fromRatio , names as namedColors } from '@ctrl/tinycolor'
70
70
import { debounce } from 'debounce'
71
+ import { getModuleDependencies } from './util/getModuleDependencies'
71
72
// import postcssLoadConfig from 'postcss-load-config'
72
73
73
74
const CONFIG_FILE_GLOB = 'tailwind.config.{js,cjs}'
@@ -123,6 +124,12 @@ function deletePropertyPath(obj: any, path: string | string[]): void {
123
124
delete obj [ path . pop ( ) ]
124
125
}
125
126
127
+ function getConfigId ( configPath : string , configDependencies : string [ ] ) : string {
128
+ return JSON . stringify (
129
+ [ configPath , ...configDependencies ] . map ( ( file ) => [ file , fs . statSync ( file ) . mtimeMs ] )
130
+ )
131
+ }
132
+
126
133
interface ProjectService {
127
134
state : State
128
135
tryInit : ( ) => Promise < void >
@@ -335,7 +342,8 @@ async function createProjectService(
335
342
setPnpApi ( pnpApi )
336
343
}
337
344
338
- const configModified = fs . statSync ( configPath ) . mtimeMs
345
+ const configDependencies = getModuleDependencies ( configPath )
346
+ const configId = getConfigId ( configPath , configDependencies )
339
347
const configDir = path . dirname ( configPath )
340
348
let tailwindcss : any
341
349
let postcss : any
@@ -372,7 +380,7 @@ async function createProjectService(
372
380
postcssVersion === state . modules . postcss . version &&
373
381
tailwindcssVersion === state . modules . tailwindcss . version &&
374
382
configPath === state . configPath &&
375
- configModified === state . configModified
383
+ configId === state . configId
376
384
) {
377
385
return
378
386
}
@@ -452,7 +460,6 @@ async function createProjectService(
452
460
}
453
461
454
462
state . configPath = configPath
455
- state . configModified = configModified
456
463
state . modules = {
457
464
tailwindcss : { version : tailwindcssVersion , module : tailwindcss } ,
458
465
postcss : { version : postcssVersion , module : postcss } ,
@@ -593,18 +600,14 @@ async function createProjectService(
593
600
return exports
594
601
} )
595
602
596
- hook . watch ( )
597
603
let config
598
604
try {
599
605
config = __non_webpack_require__ ( state . configPath )
600
606
} catch ( error ) {
601
- hook . unwatch ( )
602
607
hook . unhook ( )
603
608
throw error
604
609
}
605
610
606
- hook . unwatch ( )
607
-
608
611
let postcssResult : Result
609
612
try {
610
613
postcssResult = await postcss
@@ -656,9 +659,12 @@ async function createProjectService(
656
659
if ( state . dependencies ) {
657
660
watcher . unwatch ( state . dependencies )
658
661
}
659
- state . dependencies = hook . deps
662
+ state . dependencies = getModuleDependencies ( state . configPath )
663
+ console . log ( { deps : state . dependencies } )
660
664
watcher . add ( state . dependencies )
661
665
666
+ state . configId = getConfigId ( state . configPath , state . dependencies )
667
+
662
668
state . config = resolveConfig . module ( config )
663
669
state . separator = typeof userSeperator === 'string' ? userSeperator : ':'
664
670
state . plugins = await getPlugins ( config )
0 commit comments