tailwindcss/packages
Robin Malfait 44818a6cf6
Ensure @tailwindcss/cli recovers from a deleted transitive dependency (#20137)
This PR fixes an issue where the `@tailwindcss/cli` can get into a
non-recoverable state when any of the transitive dependencies break.

Tailwind CSS has 2 kinds of dependencies:

1. All your templates
2. All dependencies that contribute to your configuration such as the
`input.css`, any plugins, any `tailwind.config.js` files and so on.

When a template changes, we just have to scan for new Tailwind CSS
classes and emit a new CSS file. But when the `input.css` file, or any
of its dependencies changes, then we want to perform a full rebuild.

The idea is that your `@theme` might have changed, or new plugins have
been added, or old plugins have been removed.

If you have an `input.css` file:
```css
@import "tailwindcss";
@config "./tailwind.config.js";
```

That relies on a custom config: `tailwind.config.js`:
```js
const theme = require('./my-custom-theme.js');
module.exports = {
  theme
}
```

If that file relies on yet another file: `./my-custom-theme.js`, then
changes there should also trigger a full rebuild.

Since we're dealing with JavaScript here, we want to clear the require
cache and rebuild the dependency tree such that another change to any of
these files triggers a full fresh build.

However, if any of those (transitive) dependencies are deleted, then we
will end up in an invalid state. Creating a new compiler will result in
a build error. The compiler won't be able to figure out the entire
dependency tree, and we're stuck.

Once the user fixes the potentially missing dependency, the watchers
will not be watching any of those files because we created a fresh
compiler.

With this PR, we fix that by keeping track of old paths and using those
while we are still in an invalid state. The moment everything is fixed,
a fresh dependency tree is created and everything starts working again
without you having to restart the `@tailwindcss/cli` command.

Fixes: #20113
Closes: #20114
Closes: #20133

## Test plan

- Added an integration test that removes the transitive dependency.
Re-adding that file later will recover the CLI state.
2026-06-01 19:15:40 +02:00
..
@tailwindcss-browser Bump dependencies (#20095) 2026-05-21 17:58:55 +02:00
@tailwindcss-cli Ensure @tailwindcss/cli recovers from a deleted transitive dependency (#20137) 2026-06-01 19:15:40 +02:00
@tailwindcss-node duration must be at least 500ms 2026-05-26 23:34:51 +02:00
@tailwindcss-postcss Bump dependencies (#20095) 2026-05-21 17:58:55 +02:00
@tailwindcss-standalone Bump dependencies (#20095) 2026-05-21 17:58:55 +02:00
@tailwindcss-upgrade Remove unused test (#20117) 2026-05-26 19:45:00 +02:00
@tailwindcss-vite Fix 'Sourcemap is likely to be incorrect' warnings when using @tailwindcss/vite (#20103) 2026-05-22 17:57:25 +02:00
@tailwindcss-webpack Add Rspack optional peer dependency for @tailwindcss/webpack (#20027) 2026-05-23 11:14:48 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Canonicalization: limit arbitrary to bare values conversion (#20130) 2026-05-29 21:31:47 +02:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00