Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show remote modules size on deno compile #27415

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cli/standalone/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't output this because npm packages are stored in the file system whose size is already displayed.

Let's wait for #27395 to land because implementing this after that will basically just be getting the size from the RemoteModulesStoreBuilder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR landed.

self.fill_npm_vfs(&mut vfs).context("Building npm vfs.")?;
Some(snapshot)
} else {
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 2 additions & 0 deletions tests/specs/compile/env_vars_support/compile.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ out[WILDLINE]

Size: [WILDLINE]

Remote modules size: [WILDLINE]

Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ main[WILDLINE]

Size: [WILDLINE]

Remote modules size: [WILDLINE]

2 changes: 2 additions & 0 deletions tests/specs/compile/include/symlink_twice/compile.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ main[WILDLINE]

Size: [WILDLINE]

Remote modules size: [WILDLINE]

2 changes: 2 additions & 0 deletions tests/specs/compile/npm_fs/compile.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ main[WILDLINE]

Size: [WILDLINE]

Remote modules size: [WILDLINE]

Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ bin[WILDLINE]

Size: [WILDLINE]

Remote modules size: [WILDLINE]

Loading