mirror of
https://github.com/denoland/deno.git
synced 2025-03-09 13:49:37 -04:00
feat: show remote modules size on deno compile
This commit is contained in:
parent
14e4064986
commit
9a6536114c
6 changed files with 33 additions and 0 deletions
|
@ -575,11 +575,29 @@ impl<'a> DenoCompileBinaryWriter<'a> {
|
|||
None => None,
|
||||
};
|
||||
let mut vfs = VfsBuilder::new();
|
||||
let mut remote_modules_size = 0.0;
|
||||
let npm_snapshot = match self.npm_resolver.as_inner() {
|
||||
InnerCliNpmResolverRef::Managed(managed) => {
|
||||
let snapshot =
|
||||
managed.serialized_valid_snapshot_for_system(&self.npm_system_info);
|
||||
if !snapshot.as_serialized().packages.is_empty() {
|
||||
let npm_snapshot = managed.snapshot();
|
||||
// make sure that graph.npm_packages.is_empty() isn't empty
|
||||
if !graph.npm_packages.is_empty() {
|
||||
for module in graph.modules() {
|
||||
if let deno_graph::Module::Npm(module) = module {
|
||||
let nv = module.nv_reference.nv();
|
||||
if let Ok(package) =
|
||||
npm_snapshot.resolve_package_from_deno_module(nv)
|
||||
{
|
||||
// package.id.clone() is found now
|
||||
if let Ok(size) = managed.package_size(&package.id) {
|
||||
remote_modules_size += size as f64;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.fill_npm_vfs(&mut vfs).context("Building npm vfs.")?;
|
||||
Some(snapshot)
|
||||
} else {
|
||||
|
@ -738,6 +756,11 @@ impl<'a> DenoCompileBinaryWriter<'a> {
|
|||
};
|
||||
|
||||
output_vfs(&vfs, display_output_filename);
|
||||
log::info!(
|
||||
"{} {}\n",
|
||||
crate::colors::bold("Remote modules size:"),
|
||||
crate::util::display::human_size(remote_modules_size)
|
||||
);
|
||||
|
||||
let metadata = Metadata {
|
||||
argv: compile_flags.args.clone(),
|
||||
|
|
|
@ -10,3 +10,5 @@ out[WILDLINE]
|
|||
|
||||
Size: [WILDLINE]
|
||||
|
||||
Remote modules size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -47,3 +47,5 @@ main[WILDLINE]
|
|||
|
||||
Size: [WILDLINE]
|
||||
|
||||
Remote modules size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -9,3 +9,5 @@ main[WILDLINE]
|
|||
|
||||
Size: [WILDLINE]
|
||||
|
||||
Remote modules size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -8,3 +8,5 @@ main[WILDLINE]
|
|||
|
||||
Size: [WILDLINE]
|
||||
|
||||
Remote modules size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -15,3 +15,5 @@ bin[WILDLINE]
|
|||
|
||||
Size: [WILDLINE]
|
||||
|
||||
Remote modules size: [WILDLINE]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue