Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 22, 2025

Fix Bundle Size Regressions from Adding New Icons ✅

Problem Analysis:
The current chunking strategy in packages/react-icons/convert.js / packages/react-icons/convert-font.js uses sequential chunking (groups of 1000 icons in alphabetical order). When new icons are added, existing icons shift between chunks, causing webpack's SplitChunksPlugin to detect size changes in all chunks, leading to bundle reshuffling and size regressions.

Technical Implementation:

  • Created chunking-utils.js with hash-based chunking algorithm using hash(iconName) % numChunks
  • Replaced custom hash function with Node.js crypto.createHash('sha256') for better reliability
  • Replaced sequential splice(0, 1000) chunking in both convert.js and convert-font.js
  • Unified chunk size: 1000 icons per chunk for both SVG and font icons (previously inconsistent: 1000 for SVG, 500 for fonts)
  • Results in ~30 chunks for both SVG and font icons
  • Ensured existing icons stay in the same chunk when new icons are added
  • Added comprehensive tests achieving 100% chunk stability
  • Enhanced test coverage with explicit assertions for new icons (A1) and exact chunk counts
  • Consolidated all tests into a single test file for better maintainability
  • Rebuilt package and updated all build verification snapshots

Impact:

  • Prevents bundle size regressions - existing chunks remain unchanged when adding icons
  • Maintains webpack compatibility - SplitChunksPlugin no longer sees size changes in existing chunks
  • Deterministic builds - chunk assignment is consistent across builds
  • No breaking changes - maintains existing API and build process
  • More reliable hashing - uses native crypto module instead of custom implementation
  • Simplified configuration - consistent 1000 icons per chunk across SVG and font icons
  • Cleaner test suite - all tests consolidated in one file for easier maintenance

The solution completely resolves the bundle size regression issue preventing Teams from bumping the icons package.

Fixes #881.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] [Bug]: adding new icons is causing bundle size regressions Fix bundle size regressions when adding new icons through stable chunking Sep 22, 2025
Copilot AI requested a review from Hotell September 22, 2025 17:09
Copilot finished work on behalf of Hotell September 22, 2025 17:09
Copilot AI requested a review from Hotell October 13, 2025 13:22
Copilot finished work on behalf of Hotell October 13, 2025 13:32
@Hotell Hotell changed the title Fix bundle size regressions when adding new icons through stable chunking feat(react-icons): enable deteministic chunking when generating icon chunks Oct 16, 2025
Copilot AI requested a review from Hotell October 16, 2025 16:44
Copilot finished work on behalf of Hotell October 16, 2025 16:44
@Hotell Hotell changed the title feat(react-icons): enable deteministic chunking when generating icon chunks feat(react-icons): enable deteministic chunking when generating chunks Oct 16, 2025
@Hotell
Copy link
Contributor

Hotell commented Oct 21, 2025

@copilot tests are failing

fix it by running in order:

  • nx run @fluentui/react-icons:build
  • nx run @fluentui/react-icons:"build:verify" -u
  • commit

Copy link
Contributor Author

Copilot AI commented Oct 21, 2025

@copilot tests are failing

fix it by running in order:
...

Fixed by rebuilding the package and updating build verification snapshots. All 29 tests now pass. Commit: f784941

Copilot finished work on behalf of Hotell October 21, 2025 08:31
Copilot AI requested a review from Hotell October 21, 2025 08:44
Copilot finished work on behalf of Hotell October 21, 2025 08:44
@Hotell Hotell marked this pull request as ready for review October 21, 2025 11:22
@Hotell Hotell requested review from a team as code owners October 21, 2025 11:22
@Hotell Hotell marked this pull request as draft October 22, 2025 12:46
@Hotell
Copy link
Contributor

Hotell commented Oct 22, 2025

replaced by #911

@Hotell Hotell closed this Oct 22, 2025
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.

[Bug]: adding new icons is causing bundle size regressions

2 participants