-
Notifications
You must be signed in to change notification settings - Fork 5.9k
fix(npm): resolve bundled npm deps in packages properly when not using a node_modules directory
#32679
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
Open
dsherret
wants to merge
6
commits into
denoland:main
Choose a base branch
from
dsherret:fix_bundled_deps_resolution_global_install
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+239
−150
Open
fix(npm): resolve bundled npm deps in packages properly when not using a node_modules directory
#32679
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
60c2e19
fix(npm): resolve bundled npm deps in packages properly when using gl…
dsherret 26c0f4d
update failing test
dsherret d6ad435
Fix the issue.
dsherret 4d6810d
lint
dsherret d0cf512
use the cache more
dsherret 79b5f45
Eagerly look for responses and use better join_package_name_to_path
dsherret File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -667,7 +667,7 @@ impl NpmResolutionSnapshot { | |
| Box::new(PackageNotFoundFromReferrerError::Referrer(referrer.clone())) | ||
| })?; | ||
|
|
||
| let name = name_without_path(name); | ||
| let name = crate::package_name_without_subpath(name); | ||
| if let Some(id) = referrer_package.dependencies.get(name) { | ||
| return Ok(self.packages.get(id).unwrap()); | ||
| } | ||
|
|
@@ -863,21 +863,6 @@ impl SnapshotPackageCopyIndexResolver { | |
| } | ||
| } | ||
|
|
||
| fn name_without_path(name: &str) -> &str { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed and consolidated. |
||
| let mut search_start_index = 0; | ||
| if name.starts_with('@') | ||
| && let Some(slash_index) = name.find('/') | ||
| { | ||
| search_start_index = slash_index + 1; | ||
| } | ||
| if let Some(slash_index) = &name[search_start_index..].find('/') { | ||
| // get the name up until the path slash | ||
| &name[0..search_start_index + slash_index] | ||
| } else { | ||
| name | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Error, Clone, JsError)] | ||
| pub enum SnapshotFromLockfileError { | ||
| #[error("Could not find '{}' specified in the lockfile.", .source.0)] | ||
|
|
@@ -1070,14 +1055,6 @@ mod tests { | |
| use super::*; | ||
| use crate::registry::TestNpmRegistryApi; | ||
|
|
||
| #[test] | ||
| fn test_name_without_path() { | ||
| assert_eq!(name_without_path("foo"), "foo"); | ||
| assert_eq!(name_without_path("@foo/bar"), "@foo/bar"); | ||
| assert_eq!(name_without_path("@foo/bar/baz"), "@foo/bar"); | ||
| assert_eq!(name_without_path("@hello"), "@hello"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_copy_index_resolver() { | ||
| let mut copy_index_resolver = | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.