fix(npm): resolve bundled npm deps in packages properly when not using a node_modules directory#32679
Open
dsherret wants to merge 6 commits intodenoland:mainfrom
Open
Conversation
dsherret
commented
Mar 12, 2026
| )); | ||
| ManagedNpmResolverCreateOptions { | ||
| sys, | ||
| sys: factory.node_resolution_sys.clone(), |
Member
Author
There was a problem hiding this comment.
As part of this change, I was worried it would slow things down, so I updated the global resolver to use the NodeResolutionSys, which has a built-in cache. It should be faster than before now, but I didn't measure it yet.
dsherret
commented
Mar 12, 2026
| } | ||
| } | ||
|
|
||
| fn name_without_path(name: &str) -> &str { |
Member
Author
There was a problem hiding this comment.
Removed and consolidated.
dsherret
commented
Mar 12, 2026
| } | ||
| } | ||
|
|
||
| pub fn join_package_name_to_path(path: &Path, package_name: &str) -> PathBuf { |
Member
Author
There was a problem hiding this comment.
Removed and consolidated. New method is the more efficient one that accepts a Cow<'_, Path> that can be pushed to when owned.
dsherret
commented
Mar 12, 2026
| // first, as these should always take priority over global resolution | ||
| if let Some(bundled_folder) = self.resolve_bundled_dep(name, referrer)? { | ||
| return Ok(bundled_folder); | ||
| } |
Member
Author
There was a problem hiding this comment.
Main fix is here. Notice we do this upfront rather than only on error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We now attempt to find bundled dependencies at the start instead of on error. Previously we were doing it only on error... and sometimes it wouldn't error leading to bad resolution.
Closes #32529