Skip to content

Commit b943377

Browse files
authored
fix: json module size (#12189)
* fix: json module size * fix: json module size
1 parent ccc95d7 commit b943377

File tree

2 files changed

+8
-3
lines changed
  • crates/rspack_plugin_json/src
  • tests/rspack-test/statsOutputCases/ignore-warnings/__snapshots__

2 files changed

+8
-3
lines changed

crates/rspack_plugin_json/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ impl ParserAndGenerator for JsonParserAndGenerator {
4242
}
4343

4444
fn size(&self, module: &dyn Module, _source_type: Option<&SourceType>) -> f64 {
45-
module.source().map_or(0, |source| source.size()) as f64
45+
module
46+
.build_info()
47+
.json_data
48+
.as_ref()
49+
.map(|data| stringify(data.clone()).len() as f64)
50+
.unwrap_or(0.0)
4651
}
4752

4853
async fn parse<'a>(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
asset main.js 912 bytes [emitted] (name: main)
2-
orphan modules 797 bytes [orphan] 10 modules
3-
./index.js + 9 modules 797 bytes [code generated]
2+
orphan modules 784 bytes [orphan] 10 modules
3+
./index.js + 9 modules 784 bytes [code generated]
44
Rspack x.x.x compiled successfully in X s

0 commit comments

Comments
 (0)