diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-03-08 12:22:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-08 12:22:08 -0500 |
commit | 23e1ba7e2dba1b9453e064f6c92c10b64071b708 (patch) | |
tree | cf56494b547c96cd20a03d4393eb90656fac3a3a /cli/npm/cache.rs | |
parent | 0cce9c2bcc9667935a571d30847e66ef5d01a196 (diff) |
fix(npm): improve peer dependency resolution with circular dependencies (#18069)
This improves peer dependency resolution yet again. We did not handle
scenarios like the following:
```
// a -> b -> c -> d -> c -> b (peer)
```
...which would maybe work ok the first time its run in some cases, but
then lead to a lockfile that would error on load.
This now keeps track of circular dependencies and updates nodes
accordingly. That said, there is still a lurking bug in this code
somewhere that I've added a comment for (there is a mitigation on the
tail end that seems to work well). The current state is much better than
before and I can look into it later. I think it's something small that's
incorrect.
Diffstat (limited to 'cli/npm/cache.rs')
-rw-r--r-- | cli/npm/cache.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs index 1bc2f8487..81fb76772 100644 --- a/cli/npm/cache.rs +++ b/cli/npm/cache.rs @@ -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; @@ -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 } const NPM_PACKAGE_SYNC_LOCK_FILENAME: &str = ".deno_sync_lock"; |