-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Vite: Add option to disable module-graph based scanning and turn it on for Astro #16425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
If true that this would allow tailwind 4 to once again purge unused utility classes, then that would be an ENORMOUS win for developers and the web as a whole! Thank you for working on this! |
… to full fs scanning" This reverts commit daacc5e.
9cbe546
to
552806d
Compare
This was referenced Feb 17, 2025
We're going with an option-less approach for now since it's less confusing and won't require debugging if things go wrong: #16631 |
philipp-spiess
added a commit
that referenced
this pull request
Feb 20, 2025
Alternative to #16425 Fixes #16585 Fixes #16389 Fixes #16252 Fixes #15794 Fixes #16646 Fixes #16358 This PR changes the Vite plugin to use the file-system to discover potential class names instead of relying on the module-graph. This comes after a lot of testing and various issue reports where builds that span different Vite instances were missing class names. Because we now scan for candidates using the file-system, we can also remove a lot of the bookkeeping necessary to make production builds and development builds work as we no longer have to change the resulting stylesheet based on the `transform` callbacks of other files that might happen later. This change comes at a small performance penalty that is noticeable especially on very large projects with many files to scan. However, we offset that change by fixing an issue that I found in the current Vite integration that did a needless rebuild of the whole Tailwind root whenever any source file changed. Because of how impactful this change is, I expect many normal to medium sized projects to actually see a performance improvement after these changes. Furthermore we do plan to continue to use the module-graph to further improve the performance in dev mode. ## Test plan - Added new integration tests with cases found across the issues above. - Manual testing by adding a local version of the Vite plugin to repos from the issue list above and the [tailwindcss playgrounds](https://github.com/philipp-spiess/tailwindcss-playgrounds).
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 adds an option to the Vite plugin to control wether or not the module-graph based dependency scanner is used.
The main motivation for doing this is a number of SSR specific build issues where differences in the dependency graphs for SSR and client builds would cause unexpected production builds. Some specific examples:
The new option has a way to force
module-graph
andfile-system
based candidate scanning but will default to anautomatic
mode that will detect Astro and change the default behavior there to immediately fix the most prominent issue (#15794).It is configured like this:
Test plan
client:only
directive that was able to reproduce the issue Astro client: directive will cause tailwindcss to be invalid #15794I ensured that the new option turns-on automatically for Astro and that enabling it manually fixes the other cases.