Summary:
A module resolution should be invalidated whenever the (non-)existence of a path checked during resolution may have changed. To implement this, we'll need more information from the FileSystem APIs.
Existence
A positive existence check is straightforwardly invalidated when either:
The resolved realPath is deleted (we already watch for this), or
Any symlink traversed on the way to the real path is deleted or modified. We will need to track symlinks traversed by their real paths.
Non-existence
For non-existence, note that it is not sufficient to simply watch for file events whose path matches the path originally looked up, because file events are emitted for real paths, and the checked path may resolve through one or more symlinks.
We will require:
The first missing real path segment encountered (because we can watch for additions at this path, but not necessarily any of its descendants, should a symlink be created at this path), and
The symlinks traversed to get to that first missing segment (because changes to these invalidate which real path we should watch for an addition).
This diff
This adds links, the set of traversed links by their canonical paths, and missing (for non-existence) - the first non-navigable path segment by its canonical path.
Summary: A module resolution should be invalidated whenever the (non-)existence of a path checked during resolution may have changed. To implement this, we'll need more information from the
FileSystem
APIs.Existence
A positive existence check is straightforwardly invalidated when either:
realPath
is deleted (we already watch for this), orNon-existence
For non-existence, note that it is not sufficient to simply watch for file events whose path matches the path originally looked up, because file events are emitted for real paths, and the checked path may resolve through one or more symlinks.
We will require:
This diff
This adds
links
, the set of traversed links by their canonical paths, andmissing
(for non-existence) - the first non-navigable path segment by its canonical path.Changelog: Internal
Reviewed By: huntie
Differential Revision: D52391404