chore(react-icons): improve font/svg generator performance and add svg-sprites opt-in generators#1013
Merged
Hotell merged 21 commits intomicrosoft:mainfrom Mar 24, 2026
Merged
Conversation
…ild, expose new atoms/svg-sprites/* export map
…conver.js logic, fix infra type issues, setup infra type checking, resolve invalid JSDoc annotations, decouple perWriter with parseIconSource, optimize processing into 1 loop only
…for createIcon svg-sprite signature
Hotell
commented
Mar 20, 2026
| "lint": "eslint src", | ||
| "test": "vitest --exclude build-verify.test.js" | ||
| "test": "vitest --exclude build-verify.test.js", | ||
| "type-check:infra": "../../node_modules/.bin/tsc -p tsconfig.utils.json" |
Collaborator
Author
There was a problem hiding this comment.
this is necessary as our infra uses latest node / TS 5+ which is hoisted to workspace root
e3f03b2 to
50417b4
Compare
| const addCirclePath = path.join(atomDir, 'add-circle.js'); | ||
| expect(fs.existsSync(addCirclePath)).toBe(true); | ||
| const addCircleContent = await readFile(addCirclePath, 'utf-8'); | ||
| expect(addCircleContent).toContain('{ color: true }'); |
Contributor
There was a problem hiding this comment.
If color variants will be deprecated, do we need tests for them?
Collaborator
Author
There was a problem hiding this comment.
we do,
deprecated != removed.
to maintain API contract we can remove it only with major bump -> 3.0.0
ValentinaKozlova
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces:
@fluentui/react-iconsas a preview feature, gated behind an opt-in--spritesCLI flag.NOTE: Sprites are not included in stable releases.
Generators Refactoring & Fixes
convert.js—processPerIcon()now accepts optionalspriteDestparameter; sprite metadata is only computed when sprites are enabled.convert.utils.js—generatePerIconFiles()refactored to handle both per-icon atoms and sprite generation in a single pass.per-icon.writer.js— Refactored grouping logic; shared between SVG atoms and sprite writer.convert-font.js/convert-font.utils.js— RefactoredgeneratePerIconFilessignature to accept{ resizable, sized }object instead of flat array.convert-font.utils.test.js— Fixed test calls to match the refactoredgeneratePerIconFilessignature (was passing flat array, now passes{ resizable: [], sized: entries }).merge-metadata.js— Added log start/end blocks.SVG Sprites
SVG Sprite Generation Pipeline (new)
sprite.writer.js— New module that generates SVG sprite pairs (.svg+.tsx) from the same icon data used for per-icon atoms. Each sprite file contains<symbol>elements forall icon variants, and a companion TSX module that uses
createFluentIconwith a sprite URL reference.src/utils/createFluentIcon.svg-sprite.tsx— NewcreateFluentIconfactory for sprite-based icons that renders<use href="...">references instead of inline SVG paths.src/assets.d.ts— merged TypeScript declaration for.svgand font static asset imports.Opt-in
--spritesFlagconvert.js— Added--spritesboolean CLI flag toparseArgs(). When absent (default),--spriteDestis ignored and all sprite generation, directory creation, and metadatawriting are skipped. When
--spritesis passed,--spriteDestis required and sprites are generated as before.build.js— Sprite SVG asset copying (src/atoms/svg-sprite/*.svg→lib/andlib-cjs/) is guarded behind anexistsSync()check. When sprites are present,addSpriteExportMap()dynamically injects the./svg-sprite/*export map entry intopackage.json.package.json— Removed static./svg-sprite/*export map entry. It is now generated at build time only when sprites are enabled.Documentation
docs/preview-features.md— Documentation for the SVG sprite preview feature.README.md— Added reference to preview features docs.How to Enable Sprites
Add
--spritesto theconvert:svgscript and restore the./svg-sprite/*export map inpackage.json:# In convert:svg script, add --sprites flag: node convert.js --source=./intermediate --dest=./src --perIconDest=./src/atoms/svg --spriteDest=./src/atoms/svg-sprite --sprites --rtl=./intermediate/rtl.json --metadata=./tmp/metadata-svg.jsonWhen sprites are stabilized, the --sprites flag can be added permanently and the export map will be auto-generated during build.