Skip to content

Commit f77808c

Browse files
committed
fix(pack-api): correctly calculate module size in webpack stats (#2495)
1 parent eca43f1 commit f77808c

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

crates/pack-api/src/webpack_stats.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,14 @@ pub async fn generate_webpack_stats(
273273
.map(|(chunk_item, chunk_ids)| async move {
274274
let content_ident = chunk_item.content_ident().await?;
275275
let asset_path = chunk_item.asset_ident().path().await?;
276-
let size_vc = content_ident.path.read().len();
277-
let size: Option<u64> = *size_vc.await?;
276+
let size = content_ident
277+
.path
278+
.read()
279+
.await
280+
.ok()
281+
.and_then(|file_content| {
282+
file_content.as_content().map(|f| f.content().len() as u64)
283+
});
278284
let path = asset_path.path.clone();
279285
Ok::<_, anyhow::Error>(WebpackStatsModule {
280286
name: path.clone(),

next.js

0 commit comments

Comments
 (0)