From 03a7739d75285320d7ebff7626a122c6a6592878 Mon Sep 17 00:00:00 2001 From: Winter Date: Wed, 9 Nov 2022 22:13:12 -0500 Subject: [PATCH] prefetch-npm-deps: skip bundled dependencies in v1 lockfiles --- pkgs/build-support/node/fetch-npm-deps/src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/build-support/node/fetch-npm-deps/src/main.rs b/pkgs/build-support/node/fetch-npm-deps/src/main.rs index 9ad1c3874206..5f1e0096d570 100644 --- a/pkgs/build-support/node/fetch-npm-deps/src/main.rs +++ b/pkgs/build-support/node/fetch-npm-deps/src/main.rs @@ -26,6 +26,8 @@ struct PackageLock { #[derive(Deserialize)] struct OldPackage { version: UrlOrString, + #[serde(default)] + bundled: bool, resolved: Option, integrity: Option, dependencies: Option>, @@ -61,6 +63,13 @@ fn to_new_packages( let mut new = HashMap::new(); for (name, mut package) in old_packages { + // In some cases, a bundled dependency happens to have the same version as a non-bundled one, causing + // the bundled one without a URL to override the entry for the non-bundled instance, which prevents the + // dependency from being downloaded. + if package.bundled { + continue; + } + if let UrlOrString::Url(v) = &package.version { for (scheme, host) in [ ("github", "github.com"), @@ -404,6 +413,7 @@ mod tests { version: UrlOrString::Url(Url::parse( "github:mapbox/node-sqlite3#593c9d498be2510d286349134537e3bf89401c4a", ).unwrap()), + bundled: false, resolved: None, integrity: None, dependencies: None,