-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Module resolution should not look for node_modules outside project roots #52637
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
Comments
Hmm, this is interesting. While I agree with the basic principle, it’s technically a deviation from runtime behavior, wherein node will happily drill all the way up to the root looking for |
It also deviates from result you would get on commandLine vs in editor. So this will create discrepancies in errors if any. |
I think this is useful behavior for JS projects where you need specific (major) versions of Not sure if it is common use case, but something similar might be in monorepo where you open only specific package instead of the root. |
It might be interesting to see how much of a perf win it would be to set this as a compiler option. Even in a program with no errors, there are often many failed package lookups, e.g. for Node built-in modules that end up being fulfilled by ambient module declarations. |
There are situations when you really need the current behavior or else things would get weird. For example, let's say you clone
Let's say that top-level If you open your editor at Even worse, this is independent of these multi-project repo examples. If you simply open your editor in one of the |
Yeah. Such a setting could never ever ever be inferred from where you open your editor. It would have to be a compiler option. But I think there are legitimate use cases outside of performance. If you’re planning to ship a package to npm, or collaborate on a repo with other people, or mount a codebase in a Docker image, you really don’t want it to work only because you accidentally had a node_modules folder with a bunch of |
We have similar use case where we want to publish some modules from the We'd like the feature to be able to stop the package lookups from outside the |
Currently, module resolution looks for node_modules all the way to the root of the filesystem. However, this is slow for certain virtual filesystems, like the one used in vscode-web, which maps only a part of the file system to in-memory files and the rest to web requests. microsoft/vscode#173591 shows the workaround needed to stop tsserver from reading these parts of the filesystem.
Instead, module resolution should not look for node_modules directories outside project roots -- at least as specified in updateOpen messages, but I think there are other ways too.
The text was updated successfully, but these errors were encountered: