From 83482b7856b06122b2f8443dc7481c178e6590a6 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 7 Oct 2024 15:07:53 +0200 Subject: [PATCH 1/8] Fix postcss client crash when a file is removed before we process the change notification --- CHANGELOG.md | 2 ++ packages/@tailwindcss-cli/src/commands/build/index.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d39ed950b7..8f32b3766152 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) - _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600)) - Don't set `display: none` on elements that use `hidden="until-found"` ([#14631](https://github.com/tailwindlabs/tailwindcss/pull/14631)) +- Fix an issue that could caused the postcss client to crash when files are deleted +- _Experimental_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) ## [4.0.0-alpha.26] - 2024-10-03 diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index c705c6a05836..9207ea43711e 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -3,7 +3,7 @@ import { compile, env } from '@tailwindcss/node' import { clearRequireCache } from '@tailwindcss/node/require-cache' import { Scanner, type ChangedContent } from '@tailwindcss/oxide' import { Features, transform } from 'lightningcss' -import { existsSync } from 'node:fs' +import { existsSync, Stats } from 'node:fs' import fs from 'node:fs/promises' import path from 'node:path' import type { Arg, Result } from '../../utils/args' @@ -346,8 +346,11 @@ async function createWatchers(dirs: string[], cb: (files: string[]) => void) { if (event.type === 'delete') return // Ignore directory changes. We only care about file changes - let stats = await fs.lstat(event.path) - if (stats.isDirectory()) { + let stats: Stats | null = null + try { + stats = await fs.lstat(event.path) + } catch {} + if (stats === null || stats.isDirectory()) { return } From f0d6598dace07065382b187c6d6a141166d6c8e7 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 8 Oct 2024 15:45:33 +0200 Subject: [PATCH 2/8] Apply suggestions from code review Co-authored-by: Jordan Pittman --- CHANGELOG.md | 1 + packages/@tailwindcss-cli/src/commands/build/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f32b3766152..3ee99f424a0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600)) - Don't set `display: none` on elements that use `hidden="until-found"` ([#14631](https://github.com/tailwindlabs/tailwindcss/pull/14631)) - Fix an issue that could caused the postcss client to crash when files are deleted +- Fix issue that could cause the CLI to crash when files are deleted while watching ([#14616](https://github.com/tailwindlabs/tailwindcss/pull/14616)) - _Experimental_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) ## [4.0.0-alpha.26] - 2024-10-03 diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index 9207ea43711e..d71f6a963014 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -3,7 +3,7 @@ import { compile, env } from '@tailwindcss/node' import { clearRequireCache } from '@tailwindcss/node/require-cache' import { Scanner, type ChangedContent } from '@tailwindcss/oxide' import { Features, transform } from 'lightningcss' -import { existsSync, Stats } from 'node:fs' +import { existsSync, type Stats } from 'node:fs' import fs from 'node:fs/promises' import path from 'node:path' import type { Arg, Result } from '../../utils/args' @@ -350,7 +350,7 @@ async function createWatchers(dirs: string[], cb: (files: string[]) => void) { try { stats = await fs.lstat(event.path) } catch {} - if (stats === null || stats.isDirectory()) { + if (!stats?.isFile()) { return } From d8ef0e224cb35ef73da360ae688166d98a0125dd Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 8 Oct 2024 15:51:12 +0200 Subject: [PATCH 3/8] Also follow symlinks --- packages/@tailwindcss-cli/src/commands/build/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index d71f6a963014..ae363db579b6 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -350,7 +350,7 @@ async function createWatchers(dirs: string[], cb: (files: string[]) => void) { try { stats = await fs.lstat(event.path) } catch {} - if (!stats?.isFile()) { + if (!stats?.isFile() || !stats?.isSymbolicLink()) { return } From b9751d6e04d611ff52aea478e3730e430a7177c8 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 9 Oct 2024 14:59:02 +0200 Subject: [PATCH 4/8] Update Changelog --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee99f424a0f..6ed2e07d881a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,18 +11,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add support for `tailwindcss/colors.js`, `tailwindcss/defaultTheme.js`, and `tailwindcss/plugin.js` exports ([#14595](https://github.com/tailwindlabs/tailwindcss/pull/14595)) - Support `keyframes` in JS config file themes ([#14594](https://github.com/tailwindlabs/tailwindcss/pull/14594)) -- _Experimental_: The upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597)) +- _Upgrade (experimental)_: The upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597)) ### Fixed - Don’t crash when scanning a candidate equal to the configured prefix ([#14588](https://github.com/tailwindlabs/tailwindcss/pull/14588)) - Ensure there's always a space before `!important` when stringifying CSS ([#14611](https://github.com/tailwindlabs/tailwindcss/pull/14611)) -- _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) -- _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600)) - Don't set `display: none` on elements that use `hidden="until-found"` ([#14631](https://github.com/tailwindlabs/tailwindcss/pull/14631)) - Fix an issue that could caused the postcss client to crash when files are deleted - Fix issue that could cause the CLI to crash when files are deleted while watching ([#14616](https://github.com/tailwindlabs/tailwindcss/pull/14616)) -- _Experimental_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) +- _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) +- _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600)) +- _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) ## [4.0.0-alpha.26] - 2024-10-03 From dfbfb780f616c757da0c4dc7435a5a5df9e0de0b Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 9 Oct 2024 15:01:41 +0200 Subject: [PATCH 5/8] Fixes --- packages/@tailwindcss-cli/src/commands/build/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index ae363db579b6..02a39b266826 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -350,7 +350,7 @@ async function createWatchers(dirs: string[], cb: (files: string[]) => void) { try { stats = await fs.lstat(event.path) } catch {} - if (!stats?.isFile() || !stats?.isSymbolicLink()) { + if (!stats?.isFile() && !stats?.isSymbolicLink()) { return } From 2f0708a8a50b0e7b5be032c5d3d958387fc3ad0f Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 9 Oct 2024 15:12:49 +0200 Subject: [PATCH 6/8] Remove leftover --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ed2e07d881a..37fad508a909 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,14 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add support for `tailwindcss/colors.js`, `tailwindcss/defaultTheme.js`, and `tailwindcss/plugin.js` exports ([#14595](https://github.com/tailwindlabs/tailwindcss/pull/14595)) - Support `keyframes` in JS config file themes ([#14594](https://github.com/tailwindlabs/tailwindcss/pull/14594)) -- _Upgrade (experimental)_: The upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597)) +- _Upgrade (experimental)_: tThe upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597)) ### Fixed - Don’t crash when scanning a candidate equal to the configured prefix ([#14588](https://github.com/tailwindlabs/tailwindcss/pull/14588)) - Ensure there's always a space before `!important` when stringifying CSS ([#14611](https://github.com/tailwindlabs/tailwindcss/pull/14611)) - Don't set `display: none` on elements that use `hidden="until-found"` ([#14631](https://github.com/tailwindlabs/tailwindcss/pull/14631)) -- Fix an issue that could caused the postcss client to crash when files are deleted - Fix issue that could cause the CLI to crash when files are deleted while watching ([#14616](https://github.com/tailwindlabs/tailwindcss/pull/14616)) - _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) - _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600)) From 6c8d15b4e6462d944aea9b7b53cf95ca7df1cd63 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 9 Oct 2024 15:13:30 +0200 Subject: [PATCH 7/8] Typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37fad508a909..06bfd3efda8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add support for `tailwindcss/colors.js`, `tailwindcss/defaultTheme.js`, and `tailwindcss/plugin.js` exports ([#14595](https://github.com/tailwindlabs/tailwindcss/pull/14595)) - Support `keyframes` in JS config file themes ([#14594](https://github.com/tailwindlabs/tailwindcss/pull/14594)) -- _Upgrade (experimental)_: tThe upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597)) +- _Upgrade (experimental)_: The upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597)) ### Fixed From 38af213becf0540778c366a0381fffdf47c32403 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 9 Oct 2024 16:52:07 +0200 Subject: [PATCH 8/8] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06bfd3efda8d..b88542fdae72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix issue that could cause the CLI to crash when files are deleted while watching ([#14616](https://github.com/tailwindlabs/tailwindcss/pull/14616)) - _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) - _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600)) -- _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596)) ## [4.0.0-alpha.26] - 2024-10-03