Ensure @tailwindcss/cli recovers from a deleted transitive dependency#20137
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR improves CLI watch mode reliability when dependencies change or are deleted. It adds a 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/`@tailwindcss-cli/src/commands/build/index.ts:
- Around line 317-323: The current rollback always restores fullRebuildPaths
from backupRebuildPaths on any watch-time exception; change this so the rollback
only occurs if the dependency tree is actually invalid (i.e., if
createCompiler() did not complete successfully). Introduce a local flag (e.g.,
createdCompiler = false) before the try, set createdCompiler = true immediately
after createCompiler() returns, and in the catch or finally restore
fullRebuildPaths from backupRebuildPaths only when createdCompiler is false;
reference the existing variables backupRebuildPaths and fullRebuildPaths and the
createCompiler() call to locate where to add the flag and conditional rollback.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 741153da-c4d0-4567-9d8d-4efb417e3d3a
📒 Files selected for processing (3)
integrations/cli/index.test.tsintegrations/utils.tspackages/@tailwindcss-cli/src/commands/build/index.ts
Confidence Score: 4/5The recovery logic is correct and the approach is sound, but there is a known runtime issue in the catch block that would prevent the 'Done in' timing line from printing and would cause the new integration test to hang — this was already flagged in a prior review thread and has not yet been addressed. The packages/@tailwindcss-cli/src/commands/build/index.ts — specifically the catch block around line 436 where Reviews (2): Last reviewed commit: "update changelog" | Re-trigger Greptile |
ed0ebb6 to
a8c2357
Compare
This PR fixes an issue where the
@tailwindcss/clican get into a non-recoverable state when any of the transitive dependencies break.Tailwind CSS has 2 kinds of dependencies:
input.css, any plugins, anytailwind.config.jsfiles 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.cssfile, or any of its dependencies changes, then we want to perform a full rebuild.The idea is that your
@thememight have changed, or new plugins have been added, or old plugins have been removed.If you have an
input.cssfile:That relies on a custom config:
tailwind.config.js: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/clicommand.Fixes: #20113
Closes: #20114
Closes: #20133
Test plan