Skip to content

Commit

Permalink
add stats
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Jul 27, 2024
1 parent 47d7ab1 commit 8980a86
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 27 deletions.
1 change: 1 addition & 0 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export class JsStatsModule {
get type(): string
get moduleType(): string
get identifier(): string
get layer(): string | undefined
get name(): string
get id(): string | undefined
get chunks(): Array<string | undefined | null>
Expand Down
2 changes: 2 additions & 0 deletions crates/rspack_binding_values/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ pub struct JsStatsModule {
r#type: &'static str,
module_type: &'static str,
identifier: &'static str,
layer: Option<String>,
name: String,
id: Option<String>,
chunks: Vec<Option<String>>,
Expand Down Expand Up @@ -431,6 +432,7 @@ impl TryFrom<StatsModule<'_>> for JsStatsModule {
depth: stats_module.depth.map(|d| d as u32),
chunks: stats_module.chunks,
module_type: stats_module.module_type.as_str(),
layer: stats_module.layer.map(|i| i.into_owned()),
identifier: stats_module.identifier.as_str(),
id: stats_module.id.map(|i| i.to_owned()),
dependent: stats_module.dependent,
Expand Down
4 changes: 4 additions & 0 deletions crates/rspack_core/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ impl Stats<'_> {
Ok(StatsModule {
r#type: "module",
module_type: *module.module_type(),
layer: module.get_layer().map(|layer| layer.into()),
identifier,
depth: module_graph.get_depth(&identifier),
name_for_condition: module.name_for_condition().map(|n| n.to_string()),
Expand Down Expand Up @@ -1008,6 +1009,7 @@ impl Stats<'_> {
r#type: "module",
depth: None,
module_type: module.module_type,
layer: None,
identifier: module.identifier,
name_for_condition: module.name_for_condition.clone(),
name: module.name.clone().into(),
Expand Down Expand Up @@ -1076,6 +1078,7 @@ impl Stats<'_> {
r#type: "module",
depth: None,
module_type: *module.module_type(),
layer: module.get_layer().map(|layer| layer.into()),
identifier: module.identifier(),
name_for_condition: module.name_for_condition().map(|n| n.to_string()),
name: module.name().as_str().into(),
Expand Down Expand Up @@ -1337,6 +1340,7 @@ pub struct StatsAssetInfoRelated {
pub struct StatsModule<'s> {
pub r#type: &'static str,
pub module_type: ModuleType,
pub layer: Option<Cow<'s, str>>,
pub identifier: ModuleIdentifier,
pub name: Cow<'s, str>,
pub name_for_condition: Option<String>,
Expand Down
Loading

0 comments on commit 8980a86

Please sign in to comment.