-
Notifications
You must be signed in to change notification settings - Fork 5.6k
feat(unstable/npm): support peer dependencies #16561
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
Merged
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
b2e36a3
Start of work
dsherret fa2d28d
Fix.
dsherret 225187b
Merge branch 'main' into npm_peer_deps
dsherret c725a9c
More work.
dsherret b7f1424
Committing current state.
dsherret a6973aa
Merge branch 'main' into npm_peer_deps
dsherret 19dd3d7
Serialization and deserialization of npm package ids
dsherret 2d9b75b
Compiling...
dsherret 53f11d7
Passing existing tests... now to write new ones
dsherret b4c0d71
Split up resolution.rs into multiple files
dsherret 96a8975
Ability to inject a custom npm registry api for testing purposes
dsherret 8e8c438
Start of adding unit tests for graph resolver code.
dsherret c2899a6
More progress, but test is still failing
dsherret 5338523
Working basic resolution... now to add more complex tests.
dsherret 13d4f01
Tests for resolving ancestor sibling not at the top of the tree.
dsherret d1867f4
More tests.
dsherret 6f02b54
Fix another failing test.
dsherret db8465f
Fix tests.
dsherret b2dac59
Handle dependency being specified as dep and peer dep
dsherret 01c05f2
Starting to add support for handling circular stuff.
dsherret de0e1bc
Working resolution::graph tests
dsherret f71961c
Fix clippy.
dsherret 647e391
Add test for circular dependencies
dsherret 86227ca
Add comment.
dsherret e316c67
Basic idea for linking this up to the cache folder.
dsherret b481234
Working on hooking up the cache with the snapshot.
dsherret 406c923
Hooked up resolution to execution. Untested.
dsherret b5342a7
Clippy.
dsherret 7dee311
Add test and fix issues for "copy_index"
dsherret b4979c5
Update monch
dsherret 846a83e
Fix lack of determinism going up the tree
dsherret 422b512
Use hard links.
dsherret d37eab6
Failing refactor.
dsherret 9a40e57
Revert "Failing refactor."
dsherret 15a06af
Not sure if faster... maybe slower?
dsherret 0e929fe
Add `GraphSpecifierPath`
dsherret d719c5c
Adding integration test and fixing bugs.
dsherret 9f429dc
--reload fixes
dsherret 044dfef
Merge branch 'main' into npm_peer_deps
dsherret 500dab6
Fix broken test.
dsherret ebf24a9
Clippy
dsherret 7cbc849
Add more information for panic.
dsherret 999fb28
Fix infinite loop
dsherret e2202cd
Add deno info support.
dsherret db16f8f
Merge branch 'main' into npm_peer_deps
dsherret 0468e83
Clippy.
dsherret c483944
Fix.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ use std::rc::Rc; | |
use std::sync::Arc; | ||
|
||
use crate::args::ConfigFile; | ||
use crate::npm::NpmPackageId; | ||
use crate::npm::NpmPackageReq; | ||
use crate::npm::NpmResolutionPackage; | ||
use crate::tools::fmt::format_json; | ||
|
@@ -40,7 +41,7 @@ pub struct NpmPackageInfo { | |
|
||
#[derive(Clone, Debug, Default, Serialize, Deserialize)] | ||
pub struct NpmContent { | ||
/// Mapping between requests for npm packages and resolved specifiers, eg. | ||
/// Mapping between requests for npm packages and resolved packages, eg. | ||
/// { | ||
/// "chalk": "[email protected]" | ||
/// "react@17": "[email protected]" | ||
|
@@ -269,7 +270,7 @@ impl Lockfile { | |
&mut self, | ||
package: &NpmResolutionPackage, | ||
) -> Result<(), LockfileError> { | ||
let specifier = package.id.serialize_for_lock_file(); | ||
let specifier = package.id.as_serialized(); | ||
if let Some(package_info) = self.content.npm.packages.get(&specifier) { | ||
let integrity = package | ||
.dist | ||
|
@@ -286,7 +287,7 @@ This could be caused by: | |
* the source itself may be corrupt | ||
|
||
Use \"--lock-write\" flag to regenerate the lockfile at \"{}\".", | ||
package.id, self.filename.display() | ||
package.id.display(), self.filename.display() | ||
))); | ||
} | ||
} else { | ||
|
@@ -300,7 +301,7 @@ Use \"--lock-write\" flag to regenerate the lockfile at \"{}\".", | |
let dependencies = package | ||
.dependencies | ||
.iter() | ||
.map(|(name, id)| (name.to_string(), id.serialize_for_lock_file())) | ||
.map(|(name, id)| (name.to_string(), id.as_serialized())) | ||
.collect::<BTreeMap<String, String>>(); | ||
|
||
let integrity = package | ||
|
@@ -309,7 +310,7 @@ Use \"--lock-write\" flag to regenerate the lockfile at \"{}\".", | |
.as_ref() | ||
.unwrap_or(&package.dist.shasum); | ||
self.content.npm.packages.insert( | ||
package.id.serialize_for_lock_file(), | ||
package.id.as_serialized(), | ||
NpmPackageInfo { | ||
integrity: integrity.to_string(), | ||
dependencies, | ||
|
@@ -321,12 +322,13 @@ Use \"--lock-write\" flag to regenerate the lockfile at \"{}\".", | |
pub fn insert_npm_specifier( | ||
&mut self, | ||
package_req: &NpmPackageReq, | ||
version: String, | ||
package_id: &NpmPackageId, | ||
) { | ||
self.content.npm.specifiers.insert( | ||
package_req.to_string(), | ||
format!("{}@{}", package_req.name, version), | ||
); | ||
self | ||
.content | ||
.npm | ||
.specifiers | ||
.insert(package_req.to_string(), package_id.as_serialized()); | ||
self.has_content_changed = true; | ||
} | ||
} | ||
|
@@ -559,10 +561,12 @@ mod tests { | |
id: NpmPackageId { | ||
name: "nanoid".to_string(), | ||
version: NpmVersion::parse("3.3.4").unwrap(), | ||
peer_dependencies: Vec::new(), | ||
}, | ||
copy_index: 0, | ||
dist: NpmPackageVersionDistInfo { | ||
tarball: "foo".to_string(), | ||
shasum: "foo".to_string(), | ||
tarball: "foo".to_string(), | ||
shasum: "foo".to_string(), | ||
integrity: Some("sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==".to_string()) | ||
}, | ||
dependencies: HashMap::new(), | ||
|
@@ -574,10 +578,12 @@ mod tests { | |
id: NpmPackageId { | ||
name: "picocolors".to_string(), | ||
version: NpmVersion::parse("1.0.0").unwrap(), | ||
peer_dependencies: Vec::new(), | ||
}, | ||
copy_index: 0, | ||
dist: NpmPackageVersionDistInfo { | ||
tarball: "foo".to_string(), | ||
shasum: "foo".to_string(), | ||
tarball: "foo".to_string(), | ||
shasum: "foo".to_string(), | ||
integrity: Some("sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==".to_string()) | ||
}, | ||
dependencies: HashMap::new(), | ||
|
@@ -590,10 +596,12 @@ mod tests { | |
id: NpmPackageId { | ||
name: "source-map-js".to_string(), | ||
version: NpmVersion::parse("1.0.2").unwrap(), | ||
peer_dependencies: Vec::new(), | ||
}, | ||
copy_index: 0, | ||
dist: NpmPackageVersionDistInfo { | ||
tarball: "foo".to_string(), | ||
shasum: "foo".to_string(), | ||
tarball: "foo".to_string(), | ||
shasum: "foo".to_string(), | ||
integrity: Some("sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==".to_string()) | ||
}, | ||
dependencies: HashMap::new(), | ||
|
@@ -606,7 +614,9 @@ mod tests { | |
id: NpmPackageId { | ||
name: "source-map-js".to_string(), | ||
version: NpmVersion::parse("1.0.2").unwrap(), | ||
peer_dependencies: Vec::new(), | ||
}, | ||
copy_index: 0, | ||
dist: NpmPackageVersionDistInfo { | ||
tarball: "foo".to_string(), | ||
shasum: "foo".to_string(), | ||
|
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.
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.
Uh oh!
There was an error while loading. Please reload this page.