Skip to content

feat: rsdoctor plugin add json size#1524

Open
yifancong wants to merge 1 commit intomainfrom
feat/rspack-native-json-size
Open

feat: rsdoctor plugin add json size#1524
yifancong wants to merge 1 commit intomainfrom
feat/rspack-native-json-size

Conversation

@yifancong
Copy link
Contributor

@yifancong yifancong commented Feb 4, 2026

Summary

feat: rsdoctor plugin add json size

Related Links

web-infra-dev/rspack#12927

Copilot AI review requested due to automatic review settings February 4, 2026 06:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_sizes from Plugin.RspackNativeModuleSourcePatch and looks up corresponding modules by Webpack identifier.
  • Sets parsedSize on matched modules using the JSON size reported by the native plugin, without altering existing sourceSize handling from moduleOriginalSources.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +188 to +195
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,
});
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant