From 478ef99303e99999528b30c6cba287c4dd1d5556 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Thu, 10 Nov 2022 12:14:21 -0500 Subject: [PATCH 1/2] Fix watching files on Linux --- src/cli/build/watching.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cli/build/watching.js b/src/cli/build/watching.js index c5204b610e54..ffbfd1ac096a 100644 --- a/src/cli/build/watching.js +++ b/src/cli/build/watching.js @@ -97,14 +97,15 @@ export function createWatcher(args, { state, rebuild }) { * * @param {*} file * @param {(() => Promise) | null} content + * @param {boolean} skipPendingCheck * @returns {Promise} */ - function recordChangedFile(file, content = null) { + function recordChangedFile(file, content = null, skipPendingCheck = false) { file = path.resolve(file) // Applications like Vim/Neovim fire both rename and change events in succession for atomic writes // In that case rebuild has already been queued by rename, so can be skipped in change - if (pendingRebuilds.has(file)) { + if (pendingRebuilds.has(file) && !skipPendingCheck) { return Promise.resolve() } @@ -198,8 +199,10 @@ export function createWatcher(args, { state, rebuild }) { } // This will push the rebuild onto the chain + // We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux + // This is because the order of events and timing is different on Linux // @ts-ignore: TypeScript isn't picking up that content is a string here - await recordChangedFile(filePath, () => content) + await recordChangedFile(filePath, () => content, true) } catch { // If reading the file fails, it's was probably a deleted temporary file // So we can ignore it and no rebuild is needed From e89ac9e25646e274bf3abf92bb126761475ea082 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Thu, 10 Nov 2022 12:17:08 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c08731a119..a2caf67580ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Fix watching of files on Linux when renames are involved ([#9796](https://github.com/tailwindlabs/tailwindcss/pull/9796)) ## [3.2.3] - 2022-11-09