bundle-stats icon indicating copy to clipboard operation
bundle-stats copied to clipboard

change percventage to size in bytes

Open Joaco2603 opened this issue 2 months ago • 4 comments

Change summary

  • Updated the Webpack duplicate-code metric to report duplicate module size in bytes instead of percentages.
  • Adjusted metric configuration to use file-size formatting and treat higher duplicate values as regressions.
  • Refreshed extractor tests, duplicate-package insights, and report snapshots to align with the new byte-based metric.

Summary by CodeRabbit

  • New Features
    • Duplicate code is now reported as total size (file size) instead of a percentage, with clearer labeling that smaller is better.
  • Bug Fixes
    • Duplicate package insights are downgraded from error to warning, with updated wording (e.g., “Bundle contains X duplicate packages”).
  • Tests
    • Re-enabled a previously isolated test and updated expectations to align with new duplicate code sizing and insight severity.
  • Chores
    • Added ignore rules for test output artifacts to reduce noise in version control.

Joaco2603 avatar Oct 07 '25 04:10 Joaco2603

Walkthrough

  • Added packages/utils/jest-output.txt containing a single whitespace and updated .gitignore to ignore **/jest-output.txt.
  • In packages/utils/src/webpack/extract/modules.ts, switched duplicateCode from a percentage to a raw duplicate code size; removed lodash/round, totalCodeSize accumulation, and percentage calculations.
  • Updated metrics in packages/utils/src/webpack/metrics.ts: DUPLICATE_CODE now describes total duplicate size, type changed from Percentage to FileSize, biggerIsBetter set to false.
  • Adjusted tests:
    • modules-packages-duplicate.ts: removed describe.only; changed expected insight type from error to warning; updated message wording/counts.
    • modules.ts: updated expected duplicateCode values to large absolute sizes (e.g., 600, 5000).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly summarizes the main change of reporting the duplicate-code metric in bytes instead of a percentage. It is concise, clear, and directly aligned with the pull request's objectives. This focus helps teammates quickly grasp the core update when scanning PR history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7198506cb7ae2c4ad1ba437fd73d14331d0faca and a702f494b966eb71bf46648208b4c301b14e6e52.

📒 Files selected for processing (1)
  • .gitignore (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .gitignore

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 07 '25 04:10 coderabbitai[bot]

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

socket-security[bot] avatar Oct 07 '25 04:10 socket-security[bot]

@Joaco2603 Thank you for the PR! I will take a closer look at it in the coming days.

vio avatar Oct 08 '25 21:10 vio

#12695 Bundle Size — 382.66KiB (-0.02%).

a702f49(current) vs 89d8cd8 master#12692(baseline)

[!WARNING] Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 1 regression Improvement 1 improvement
                 Current
#12695
     Baseline
#12692
Regression  Initial JS 335.02KiB(~+0.01%) 335.01KiB
Improvement  Initial CSS 47.64KiB(-0.2%) 47.74KiB
Change  Cache Invalidation 41.09% 28.62%
No change  Chunks 3 3
No change  Assets 4 4
No change  Modules 701 701
No change  Duplicate Modules 0 0
No change  Duplicate Code 0% 0%
No change  Packages 39 39
No change  Duplicate Packages 1 1
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#12695
     Baseline
#12692
Regression  JS 335.02KiB (~+0.01%) 335.01KiB
Improvement  CSS 47.64KiB (-0.2%) 47.74KiB

Bundle analysis reportBranch Joaco2603:feature/duplicateCode_...Project dashboard


Generated by RelativeCIDocumentationReport issue

relativeci[bot] avatar Oct 08 '25 21:10 relativeci[bot]