Skip to content

Conversation

@lluisemper
Copy link

Add showDiff option to printFileSize for build-to-build size comparison

Add a new showDiff option to performance.printFileSize that displays file size changes compared to the previous build. This helps developers track how their changes affect bundle sizes over time.

Summary

Adds a showDiff option to performance.printFileSize that displays file size changes between builds. Shows color-coded differences (red for increases, green for decreases, "NEW" for new files) in a dedicated "Diff" column. Caches previous build sizes in node_modules/.cache/rsbuild/ for comparison, with automatic hash normalization to match files across builds. Opt-in feature (disabled by default).

E.G.
Screenshot 2025-11-23 at 19 25 32

Related Links

#6100

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

…ize comparison

Add a new `showDiff` option to performance.printFileSize that displays file size changes compared to the previous build. This helps developers track how their changes affect bundle sizes over time.
Copilot AI review requested due to automatic review settings November 23, 2025 19:00
@netlify
Copy link

netlify bot commented Nov 23, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 239acad
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/692ab8bb85aa1b0008238704
😎 Deploy Preview https://deploy-preview-6635--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 57 (🔴 down 15 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant
Copy link

CLAassistant commented Nov 23, 2025

CLA assistant check
All committers have signed the CLA.

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 adds a new showDiff option to performance.printFileSize that displays file size changes between builds. The feature helps developers track how their changes affect bundle sizes by showing color-coded differences (red for increases, green for decreases, "NEW" for new files) in a dedicated "Diff" column. The implementation caches build sizes in node_modules/.cache/rsbuild/ and uses hash normalization to match files across builds. The feature is opt-in and disabled by default.

Key changes:

  • Adds showDiff boolean option to PrintFileSizeOptions type
  • Implements file size caching mechanism with hash normalization for cross-build file matching
  • Updates output formatting to include a conditional "Diff" column with color-coded size changes

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
website/docs/en/config/performance/print-file-size.mdx Documents the new showDiff option with examples showing the diff column output
packages/core/tests/fileSize.test.ts Adds comprehensive test coverage for the normalizeFileName function and updates asset exclusion tests
packages/core/src/types/config.ts Adds showDiff boolean property to PrintFileSizeOptions interface
packages/core/src/plugins/fileSize.ts Implements core diff functionality including cache management, file name normalization, and diff column rendering

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

Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

I feel that create-react-app's logging style is more concise. It does not add an extra “Diff” column but instead shows size changes in parentheses right after the existing size.

This makes the format more flexible, so we could also show the diff for the gzip size if we want.

Image

@lluisemper lluisemper requested a review from Copilot November 29, 2025 09:03
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


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

Comment on lines +74 to +77
expect(normalizeFileName('bundle.A1B2C3D4.js')).toBe(
'bundle.A1B2C3D4.js',
);
// Only lowercase a-f are matched by the regex
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

This test verifies that uppercase hex digits are NOT removed, but there's no test verifying that lowercase hex digits ARE removed in the same scenario. Add a test case with normalizeFileName('bundle.a1b2c3d4.js') to ensure the lowercase version is correctly normalized to 'bundle.js'.

Copilot uses AI. Check for mistakes.
@lluisemper
Copy link
Author

Thank you for reviewing! I have pushed some changes

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.

3 participants