Skip to content
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

fix(npm): improve peer dependency resolution with circular dependencies #18069

Merged
merged 15 commits into from
Mar 8, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/.cargo_home/
/.idea/
/.vs/
/.vscode/
gclient_config.py_entries
/gh-pages/
Expand Down
8 changes: 7 additions & 1 deletion cli/npm/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use deno_core::parking_lot::Mutex;
use deno_core::url::Url;
use deno_graph::npm::NpmPackageNv;
use deno_graph::semver::Version;
use once_cell::sync::Lazy;

use crate::args::CacheSetting;
use crate::cache::DenoDir;
Expand All @@ -27,10 +28,15 @@ use crate::util::progress_bar::ProgressBar;
use super::registry::NpmPackageVersionDistInfo;
use super::tarball::verify_and_extract_tarball;

static SHOULD_SYNC_DOWNLOAD: Lazy<bool> =
Lazy::new(|| std::env::var("DENO_UNSTABLE_NPM_SYNC_DOWNLOAD").is_ok());

/// For some of the tests, we want downloading of packages
/// to be deterministic so that the output is always the same
pub fn should_sync_download() -> bool {
std::env::var("DENO_UNSTABLE_NPM_SYNC_DOWNLOAD").is_ok()
// this gets called a lot when doing npm resolution and was taking
// a significant amount of time, so cache it in a lazy
*SHOULD_SYNC_DOWNLOAD
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before: 8.6% of execution -- After: 0%

}

const NPM_PACKAGE_SYNC_LOCK_FILENAME: &str = ".deno_sync_lock";
Expand Down
Loading