fix(npm): fix require resolution if using --node-modules-dir (#17087)

In our `require()` implementation we use a special logic to resolve
"base path" when looking for matching packages, however this logic
is in contradiction to what needs to happen if there's a local
"node_modules"
directory used. This commit changes require implementation to be aware
if we're running off of global node modules cache or a local one.
This commit is contained in:
Bartek Iwańczuk 2022-12-16 23:41:51 +01:00 committed by GitHub
parent 058610b458
commit efcb93f8b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 9 deletions

View file

@ -280,6 +280,10 @@ impl CliOptions {
self.overrides.import_map_specifier = Some(path);
}
pub fn node_modules_dir(&self) -> bool {
self.flags.node_modules_dir
}
/// Resolves the path to use for a local node_modules folder.
pub fn resolve_local_node_modules_folder(
&self,