1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
diff --git a/src/server.ts b/src/server.ts
index 1651cbee9003fdfc0718343923adc92cbf9c0042..88f9bf0230d5373f547be14d275b77363f13ea99 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -68,6 +68,7 @@ import { doCodeActions } from 'tailwindcss-language-service/src/codeActions/codeActionProvider'
import { getDocumentColors } from 'tailwindcss-language-service/src/documentColorProvider'
import { fromRatio, names as namedColors } from '@ctrl/tinycolor'
import { debounce } from 'debounce'
+import { getModuleDependencies } from './util/getModuleDependencies'
// import postcssLoadConfig from 'postcss-load-config'
const CONFIG_FILE_GLOB = 'tailwind.config.{js,cjs}'
@@ -121,6 +122,12 @@ }
}
delete obj[path.pop()]
+}
+
+function getConfigId(configPath: string, configDependencies: string[]): string {
+ return JSON.stringify(
+ [configPath, ...configDependencies].map((file) => [file, fs.statSync(file).mtimeMs])
+ )
}
interface ProjectService {
@@ -335,7 +342,8 @@ pnpApi.setup()
setPnpApi(pnpApi)
}
- const configModified = fs.statSync(configPath).mtimeMs
+ const configDependencies = getModuleDependencies(configPath)
+ const configId = getConfigId(configPath, configDependencies)
const configDir = path.dirname(configPath)
let tailwindcss: any
let postcss: any
@@ -372,7 +380,7 @@ state.enabled &&
postcssVersion === state.modules.postcss.version &&
tailwindcssVersion === state.modules.tailwindcss.version &&
configPath === state.configPath &&
- configModified === state.configModified
+ configId === state.configId
) {
return
}
@@ -452,7 +460,6 @@ // )
}
state.configPath = configPath
- state.configModified = configModified
state.modules = {
tailwindcss: { version: tailwindcssVersion, module: tailwindcss },
postcss: { version: postcssVersion, module: postcss },
@@ -593,17 +600,13 @@
return exports
})
- hook.watch()
let config
try {
config = __non_webpack_require__(state.configPath)
} catch (error) {
- hook.unwatch()
hook.unhook()
throw error
}
-
- hook.unwatch()
let postcssResult: Result
try {
@@ -656,8 +659,11 @@
if (state.dependencies) {
watcher.unwatch(state.dependencies)
}
- state.dependencies = hook.deps
+ state.dependencies = getModuleDependencies(state.configPath)
+ console.log({ deps: state.dependencies })
watcher.add(state.dependencies)
+
+ state.configId = getConfigId(state.configPath, state.dependencies)
state.config = resolveConfig.module(config)
state.separator = typeof userSeperator === 'string' ? userSeperator : ':'
|