You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
getDirectoryToWatchFailedLookupLocation in resolutionCache.ts checks if a failed lookup location is in the project's root dir, and if so, watches the entire project root, recursively (intentionally, it has a comment // Always watch root directory recursively).
For projects containing potentially very many subdirectories (just large projects, but also projects with large node_modules subtrees), this will read thousands of directories and create corresponding thousands of watchers.
I wonder if we could do better, but I don't understand the thinking that went into this. Was the idea that just having a recursive watch on the root is more effective than watching lots of more precise locations?
I'd consider only adding a watch for the closest non-existing file from the lookup location, e.g. for a location /foo/bar/baz/index.ts not being found, with baz/ not existing, a watch on /foo/bar would be sufficient, and create fewer watches and file reads than watching every file in the project recursively.