diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-10-25 18:20:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 18:20:07 +0200 |
commit | 9835b095e56bdfc2b195b2c4741631b78a759115 (patch) | |
tree | 1fa8ee44cdc374d48c2307c1bd35085af74ec85b /cli/proc_state.rs | |
parent | 10c3c0ee5733cfa5cf4c2825c6a8fce9f05060aa (diff) |
fix(npm): add support for npm packages in lock files (#15938)
This commit adds support for npm packages in the lock file.
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index ac83e9459..7fc28b553 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -235,7 +235,8 @@ impl ProcState { cli_options.cache_setting(), progress_bar.clone(), ); - let npm_resolver = NpmPackageResolver::new( + let maybe_lockfile = lockfile.as_ref().filter(|l| !l.lock().write).cloned(); + let mut npm_resolver = NpmPackageResolver::new( npm_cache.clone(), api, cli_options.unstable() @@ -246,6 +247,9 @@ impl ProcState { .resolve_local_node_modules_folder() .with_context(|| "Resolving local node_modules folder.")?, ); + if let Some(lockfile) = maybe_lockfile.clone() { + npm_resolver.add_lockfile(lockfile).await?; + } let node_analysis_cache = NodeAnalysisCache::new(Some(dir.node_analysis_db_file_path())); @@ -464,6 +468,8 @@ impl ProcState { } /// Add the builtin node modules to the graph data. + // FIXME(bartlomieju): appears this function can be called more than once + // if we have npm imports pub async fn prepare_node_std_graph(&self) -> Result<(), AnyError> { let node_std_graph = self .create_graph(vec![(node::MODULE_ALL_URL.clone(), ModuleKind::Esm)]) |