Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Rspack-native module source transform so that JSON module sizes provided by the Rsdoctor Rspack plugin are propagated into the module graph as parsedSize, enabling accurate bundle size reporting for JSON assets when using the native plugin path.
Changes:
- Reads
json_module_sizesfromPlugin.RspackNativeModuleSourcePatchand looks up corresponding modules by Webpack identifier. - Sets
parsedSizeon matched modules using the JSON size reported by the native plugin, without altering existingsourceSizehandling frommoduleOriginalSources.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (jsonModuleSizes && jsonModuleSizes.length > 0) { | ||
| for (const jsonModuleSize of jsonModuleSizes) { | ||
| const module = mg.getModuleByWebpackId(jsonModuleSize.identifier); | ||
| if (module) { | ||
| // Set parsedSize for JSON modules from Rspack's tree-shaken size | ||
| module.setSize({ | ||
| parsedSize: jsonModuleSize.size, | ||
| }); |
There was a problem hiding this comment.
The new JSON module parsedSize handling in patchNativeModuleSources is not covered by tests, whereas related behavior (e.g. JSON parsedSize from stats in graph/src/transform/module-graph/transform.ts and Rspack native graph transforms in core/tests/build/utils/rspack-transform.test.ts) is tested. To avoid regressions and ensure the Rspack-native path matches the expected JSON size semantics, please add tests that exercise json_module_sizes (including cases like multiple JSON modules and absence of entries).
Summary
feat: rsdoctor plugin add json size
Related Links
web-infra-dev/rspack#12927