perf: more efficient deno cache and npm package info usage (#16592)

1. There was a lot of cloning going on with `NpmPackageInfo`. This is
now stored in an `Arc<NpmPackageInfo>` and cloning only happens on the
individual version.
2. The package cache is now cleared from memory after resolution.
3. This surfaced a bug in `deno cache` and I noticed it can be more
efficient if we have multiple root specifiers if we provide all the
specifiers as roots.
This commit is contained in:
David Sherret 2022-11-11 11:33:57 -05:00 committed by GitHub
parent 7f0546a6b7
commit 8dc242f789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 59 deletions

View file

@ -284,23 +284,23 @@ async fn check_command(
async fn load_and_type_check(
ps: &ProcState,
files: &Vec<String>,
files: &[String],
) -> Result<(), AnyError> {
let lib = ps.options.ts_type_lib_window();
for file in files {
let specifier = resolve_url_or_path(file)?;
ps.prepare_module_load(
vec![specifier],
false,
lib,
Permissions::allow_all(),
Permissions::allow_all(),
false,
)
.await?;
}
let specifiers = files
.iter()
.map(|file| resolve_url_or_path(file))
.collect::<Result<Vec<_>, _>>()?;
ps.prepare_module_load(
specifiers,
false,
lib,
Permissions::allow_all(),
Permissions::allow_all(),
false,
)
.await?;
Ok(())
}