fix: ensure local files mapped to yarn virtuals are watched #19276
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.
Description
There's a somewhat minimal repro here: https://github.com/mrginglymus/vitest-pnp though the focus of that is worrying about the coverage reporting on vitest.
The specific problem is this:
Then files are reported as being in
<cwd>/.yarn/__virtual__/my-package...
.I've failed to exactly follow how files are added to the watcher, but what I can see is that
ensureWatchedFile
bails if the file considered 'out of root', as presumably it would otherwise be watched.However, these virtual files are not watched; I don't know how the initial watchlist is populated, but I could envisage it either having an exclusion of directories with a leading
.
, or scanning the on-disk filesystem (which would not include the virtual files).Either way, what 'fixes' this for me locally is to either change the root (to trick
ensureWatchedFile
) or apply this fix which considers virtual files to be out of root.