Skip to content

Commit

Permalink
fix: update asset size to usize
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykingxyz committed Oct 15, 2024
1 parent 7ad52cd commit cb6b72d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions crates/rspack_binding_values/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ impl From<rspack_core::StatsChunkGroupAsset> for JsStatsChunkGroupAsset {
fn from(stats: rspack_core::StatsChunkGroupAsset) -> Self {
Self {
name: stats.name,
size: stats.size,
size: stats.size as f64,
}
}
}
Expand Down Expand Up @@ -1024,11 +1024,11 @@ impl From<rspack_core::StatsChunkGroup> for JsStatsChunkGroup {
name: stats.name,
chunks: stats.chunks,
assets: stats.assets.into_iter().map(Into::into).collect(),
assets_size: stats.assets_size,
assets_size: stats.assets_size as f64,
auxiliary_assets: stats
.auxiliary_assets
.map(|assets| assets.into_iter().map(Into::into).collect()),
auxiliary_assets_size: stats.auxiliary_assets_size,
auxiliary_assets_size: stats.auxiliary_assets_size.map(|inner| inner as f64),
children: stats.children.map(|i| i.into()),
child_assets: stats.child_assets.map(|i| i.into()),
is_over_size_limit: stats.is_over_size_limit,
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/stats/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,17 @@ pub struct StatsChunk<'a> {
#[derive(Debug)]
pub struct StatsChunkGroupAsset {
pub name: String,
pub size: f64,
pub size: usize,
}

#[derive(Debug)]
pub struct StatsChunkGroup {
pub name: String,
pub chunks: Vec<String>,
pub assets: Vec<StatsChunkGroupAsset>,
pub assets_size: f64,
pub assets_size: usize,
pub auxiliary_assets: Option<Vec<StatsChunkGroupAsset>>,
pub auxiliary_assets_size: Option<f64>,
pub auxiliary_assets_size: Option<usize>,
pub children: Option<StatsChunkGroupChildren>,
pub is_over_size_limit: Option<bool>,
pub child_assets: Option<StatschunkGroupChildAssets>,
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/stats/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use crate::{
ChunkGroupByUkey, ChunkGroupOrderKey, ChunkGroupUkey, Compilation, CompilerOptions, ModuleGraph,
};

pub fn get_asset_size(file: &str, compilation: &Compilation) -> f64 {
pub fn get_asset_size(file: &str, compilation: &Compilation) -> usize {
compilation
.assets()
.get(file)
.and_then(|asset| asset.get_source().map(|s| s.size() as f64))
.unwrap_or(-1f64)
.and_then(|asset| asset.get_source().map(|s| s.size()))
.unwrap_or(0)
}

pub fn sort_modules(modules: &mut [StatsModule]) {
Expand Down

0 comments on commit cb6b72d

Please sign in to comment.