-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add @source not
support
#17255
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
Merged
Merged
Add @source not
support
#17255
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
41102c9
to
39588cf
Compare
d3700cc
to
41e1ac2
Compare
d1d31ef
to
97f9505
Compare
This isn't strictly necessary for this PR, but noticed missing values when updating the `globs` -> `sources` and made TypeScript happy by adding this.
These tests will reflect 2 big changes: 1. New tests in general 2. Tests where we used auto source detection and `.gitignore` files, will now favor the `@source '…'` rules over the `.gitignore` rules. Note: If you _don't_ want this behavior, then you can use `@source not '…'` to override rules.
We still emit `globs` for `@tailwindcss/postcss`, but we also added better normalized globs based on your `@source` directives. We returned them as a new property to stay backward compatible, but this also means that the `@tailwindcss/cli` can make use of this.
Some people don't have `node_modules` in the `.gitignore` file so in some scenario's this will always be scanned. Another example is if you use the Vercel CLI to deploy your project because `.gitignore` files are not pushed... This is technically a breaking change, but now that we have `@source not '…'` you can include files/folders from `node_modules` even though the folder is ignored by default.
This reverts commit fb4d8d8.
3d2fc5c
to
5e9cdf8
Compare
5e9cdf8
to
9d4c2af
Compare
thecrypticace
approved these changes
Mar 25, 2025
This was referenced Mar 25, 2025
RobinMalfait
added a commit
that referenced
this pull request
Mar 28, 2025
We didn't add a changelog for the PR (#17255) and there are a few things we need to talk about. So opened this PR to get everything in and once we're happy we can merge it in one go instead of changing on `main` directly. --------- Co-authored-by: Philipp Spiess <[email protected]>
philipp-spiess
added a commit
that referenced
this pull request
Mar 28, 2025
We didn't add a changelog for the PR (#17255) and there are a few things we need to talk about. So opened this PR to get everything in and once we're happy we can merge it in one go instead of changing on `main` directly. --------- Co-authored-by: Philipp Spiess <[email protected]>
28 tasks
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 a new source detection feature:
@source not "…"
. It can be used to exclude files specifically from your source configuration without having to think about creating a rule that matches all but the requested file:While working on this feature, we noticed that there are multiple places with different heuristics we used to scan the file system. These are:
@source "./my-dir"
)@source "./**/*.bin"
— these contain file extensions)Because of the different heuristics, we were able to construct failing cases (e.g. when you create a new file into
my-dir
that would be thrown out by auto-source detection, it'd would actually be scanned). We were also leaving a lot of performance on the table as the file system is traversed multiple times for certain problems.To resolve these issues, we're now unifying all of these systems into one
ignore
crate walker setup. We also implemented features like auto-source-detection and thenot
flag as additional gitignore rules only, avoid the need for a lot of custom code needed to make decisions.High level, this is what happens after the now:
@source
rules into a list of roots (that is the source directory for this rule) and optional globs (that is the actual rules for files in this file). For custom sources (i.e with a customglob
), we add an allowlist rule to the gitignore setup, so that we can be sure these files are always included.@source
rule, we create respective ignore rules.So, consider the following setup:
This creates a git ignore file that (simplified) looks like this:
We then use this information on top of your existing
.gitignore
setup to resolve files (i.e so if your.gitignore
contains rules e.g.dist/
this line is going to be added before any of the rules lined out in the example above. This allows negative rules to allow-list your.gitignore
rules.To implement this, we're rely on the
ignore
crate but we had to make various changes, very specific, to it so we decided to fork the crate. All changes are prefixed with a// CHANGED:
block but here are the most-important ones:.gitignore
rulesBehavioral changes
@source
now wins over your.gitignore
file and the auto-content rules.node_modules
and.git
folders as well as the.gitignore
file are now ignored by default (but can be overridden by an explicit@source
rule).node_modules
) now also win over your.gitignore
configuration and auto-content rules.@source not "…"
to negate any previous rules.content
rules in your legacy JavaScript configuration (e.g.content: ['!./src']
) now work with v4.@source
definitions matter now, because you can technically include or negate previous rules. This is similar to your.gitingore
file.@source
configuration into accountCombining with other features
Note that the
not
flag is also already compatible with@source inline(…)
added in an earlier commit:Test plan
@source not "…"
specific examples and updated the existing tests to match the subtle behavior changes[ci-all]
that, when added to the description of a PR, causes the PR to run unit and integration tests on all operating systems.[ci-all]