Skip to content

Conversation

@Hotell
Copy link
Collaborator

@Hotell Hotell commented Jan 30, 2026

follows #961 (comment)


1) Regex handling + module filtering

  • Before: isFluentUIReactFontChunk created and executed an inline RegExp for every module (/.../.test(m.resource)) . This was executed ~300 times while running npm test
  • After: The RegExp is hoisted to a module-level constant (REACT_ICONS_FONT_MODULE_IMPORT_PATTERN) and isFluentUIReactFontChunk adds a cheap prefilter (resource.includes('react-icons')) before running the regex.

Impact: Fewer regex executions across large module graphs; lower per-module overhead.

2) Subset text generation complexity

  • Before: Built subsetText by scanning all glyph entries in the font codepoint map:
    • Object.entries(codepointMap).filter(...).map(...).join('')
  • After: Builds subsetText by iterating only usedExports and doing O(1) lookups in codepointMap:
    • for (const glyphName of usedExports) { codepointMap[glyphName] ... }

Impact: Changes from O(total glyphs in font) per font → O(used icons) per font, which is typically much smaller.

3) Correct async waiting (also affects perf/consistency)

  • Before: await optimizationPromises; (does not actually await the array of promises).
  • After: await Promise.all(optimizationPromises);

Impact: Ensures all subsetting work completes during optimizeAssets (fixes non-determinism and prevents leftover async work outside the compilation stage).


Perf gains

  • about 0.10s faster (~4%) on our small synthetic test (npm test)
  • a larger app/module graph should show the regex + glyph-scan wins more clearly.

@Hotell Hotell changed the title React icons fs wp plugin/perf update perf(react-icons-font-subsetting-webpack-plugin): improve plugin performance Jan 30, 2026
@Hotell Hotell marked this pull request as ready for review January 30, 2026 15:00
@Hotell Hotell requested a review from dmytrokirpa January 30, 2026 15:06
@Hotell Hotell force-pushed the react-icons-fs-wp-plugin/perf-update branch from a975c4d to 1c861f8 Compare January 30, 2026 16:27
@Hotell Hotell force-pushed the react-icons-fs-wp-plugin/perf-update branch from 1c861f8 to dfcce10 Compare January 30, 2026 17:22
@Hotell Hotell merged commit 5250e12 into microsoft:main Feb 2, 2026
7 checks passed
@Hotell Hotell deleted the react-icons-fs-wp-plugin/perf-update branch February 2, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants