From 83f92474c5e8375ebe2213b4d62d4211fd011c2f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 5 Apr 2024 18:33:01 -0400 Subject: perf(lsp): use lockfile to reduce npm pkg resolution time (#23247) This functionality was broken. The series of events was: 1. Load the npm resolution from the lockfile. 2. Discover only a subset of the specifiers in the documents. 3. Clear the npm snapshot. 4. Redo npm resolution with the new specifiers (~500ms). What this now does: 1. Load the npm resolution from the lockfile. 2. Discover only a subset of the specifiers in the documents and take into account the specifiers from the lockfile. 3. Do not redo resolution (~1ms). --- cli/npm/managed/resolution.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cli/npm') diff --git a/cli/npm/managed/resolution.rs b/cli/npm/managed/resolution.rs index 4d9c4c3e9..1903d339b 100644 --- a/cli/npm/managed/resolution.rs +++ b/cli/npm/managed/resolution.rs @@ -310,9 +310,15 @@ async fn add_package_reqs_to_snapshot( .iter() .all(|req| snapshot.package_reqs().contains_key(req)) { - log::debug!("Snapshot already up to date. Skipping pending resolution."); + log::debug!( + "Snapshot already up to date. Skipping pending npm resolution." + ); snapshot } else { + log::debug!( + /* this string is used in tests!! */ + "Running pending npm resolution." + ); let pending_resolver = get_npm_pending_resolver(api); let result = pending_resolver .resolve_pending(snapshot, package_reqs) -- cgit v1.2.3