Repository navigation
Watch files that a full rebuild adds in @tailwindcss/postcss - #20763
Open
RobinMalfait wants to merge 2 commits into
Open
RobinMalfait wants to merge 2 commits into
RobinMalfait wants to merge 2 commits into
Conversation
The plugin reported the config files, plugins and imported stylesheets of the previous compiler, and only then did a full rebuild. Files that only the new compiler found, like a new `@import`, `@config` or `@plugin`, were not reported as `dependency` messages of that build. Bundlers like webpack reset the dependencies of a module on each build, so a change to such a file did not cause a rebuild until something else changed the CSS file. Report each dependency as soon as the compiler finds it, once per build. The error path reports the same paths, so it uses the same helper and does not add duplicates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where
@tailwindcss/postcssdoesn't watch a file that a full rebuild finds for the first time, like a new@import,@configor@plugin.On a full rebuild, the plugin reported the
dependencymessages of the previous compiler, and only then created the new compiler. The new compiler's files were only reported on the next build. Bundlers like webpack (postcss-loader, and Next.js with webpack) reset the dependencies of a module on each build, so a change to such a file didn't cause a rebuild, until something else changed the CSS file.This only shows for files that the scanner doesn't report already: files outside of
source(…), in another workspace package, or ignored by git.Given this setup, in
webpack --watch:@import './buttons.css';tostyles/index.css. The output now contains the styles ofbuttons.css.buttons.css. Before this PR, nothing rebuilds. With this PR, the output updates.The fix reports each dependency as soon as the compiler finds it, once per build. The error path re-reports the same paths, so it uses the same helper and doesn't add duplicates. When a new file makes the compile fail, it was already reported by the error path, and that still works.
#20762 fixes the same bug in
@tailwindcss/webpackand@tailwindcss/turbopack.Test plan
packages/@tailwindcss-postcss/src/index.test.tsfor thedependencymessages of a full rebuild, on success (once, no duplicates) and on failure.webpack + PostCSS (watch): rebuilds when a newly imported file changes, inintegrations/webpack/index.test.ts.