Skip to content

Commit 1482c75

Browse files
Fix watching of files on Linux when renames are involved (#9796)
* Fix watching files on Linux * Update changelog
1 parent 757a8d6 commit 1482c75

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Fix watching of files on Linux when renames are involved ([#9796](https://github.com/tailwindlabs/tailwindcss/pull/9796))
1113

1214
## [3.2.3] - 2022-11-09
1315

src/cli/build/watching.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ export function createWatcher(args, { state, rebuild }) {
9797
*
9898
* @param {*} file
9999
* @param {(() => Promise<string>) | null} content
100+
* @param {boolean} skipPendingCheck
100101
* @returns {Promise<void>}
101102
*/
102-
function recordChangedFile(file, content = null) {
103+
function recordChangedFile(file, content = null, skipPendingCheck = false) {
103104
file = path.resolve(file)
104105

105106
// Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
106107
// In that case rebuild has already been queued by rename, so can be skipped in change
107-
if (pendingRebuilds.has(file)) {
108+
if (pendingRebuilds.has(file) && !skipPendingCheck) {
108109
return Promise.resolve()
109110
}
110111

@@ -198,8 +199,10 @@ export function createWatcher(args, { state, rebuild }) {
198199
}
199200

200201
// This will push the rebuild onto the chain
202+
// We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
203+
// This is because the order of events and timing is different on Linux
201204
// @ts-ignore: TypeScript isn't picking up that content is a string here
202-
await recordChangedFile(filePath, () => content)
205+
await recordChangedFile(filePath, () => content, true)
203206
} catch {
204207
// If reading the file fails, it's was probably a deleted temporary file
205208
// So we can ignore it and no rebuild is needed

0 commit comments

Comments
 (0)