feat(atomic-loader): support @fluentui/react-brand-icons#1096
Closed
micahgodbolt wants to merge 1 commit into
Closed
feat(atomic-loader): support @fluentui/react-brand-icons#1096micahgodbolt wants to merge 1 commit into
micahgodbolt wants to merge 1 commit into
Conversation
Extend the atomic webpack loader to transform barrel imports from @fluentui/react-brand-icons in addition to @fluentui/react-icons. Both packages use the same atomic subpath export pattern (./svg/*), the same icon suffix convention (Regular, Filled, Color), and the same utility exports (bundleIcon, createFluentIcon, etc.). Changes: - Parameterize the hardcoded MODULE_NAME to support multiple packages - Add 'modules' option to configure which packages are transformed - Default to both @fluentui/react-icons and @fluentui/react-brand-icons - Add tests for brand icon imports, re-exports, mixed files, and opt-out - Update README with brand-icons examples and modules option docs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Hotell
reviewed
Jun 9, 2026
| function getAtomicImportPath(importName: string, iconVariant: 'svg' | 'fonts' | 'svg-sprite', moduleName: string): string { | ||
| if (importName === 'useIconContext' || importName === 'IconDirectionContextProvider') { | ||
| return '@fluentui/react-icons/providers'; | ||
| return `${moduleName}/providers`; |
Collaborator
| iconVariant: 'svg' | 'fonts' | 'svg-sprite'; | ||
| path: string; | ||
| /** Icon package names to transform. Defaults to react-icons and react-brand-icons. */ | ||
| modules?: string[]; |
Collaborator
There was a problem hiding this comment.
this is bad design, product icons don't and wont support all iconVariants, so this api needs either better more generic design or handle the logic properly internally
Collaborator
|
also FYI the chunk is tree shakeable, the atomizer purpose is primarily for 2 things:
|
Collaborator
|
this is replaced #1113 feel free to close @micahgodbolt |
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.

Problem
@fluentui/react-brand-icons(published frommicrosoftdesign/Design System/_git/fluent-product-icons) already ships atomic subpath exports (./svg/*), but the@fluentui/react-icons-atomic-webpack-loaderis hardcoded to only transform@fluentui/react-iconsbarrel imports.This forces consumers to either:
m365-copilot-navin 1JS does today)Key Insight: The Packages Are Nearly Identical
react-iconsreact-brand-icons./svg/<kebab-name>./svg/<kebab-name>sideEffectsThe existing
ICON_SUFFIX_REGEX(/(\d*)?(Regular|Filled|Light|Color)$/) already matches brand icon names with zero changes.Proposed Solution
Extend the existing loader (not a new package) with a
modulesoption:src/transform.tsReplace hardcoded
MODULE_NAME = '@fluentui/react-icons'with a configurableSetof module names. Pass the matched module name through togetAtomicImportPathso paths resolve correctly per-package.src/index.tsAdd
modulesoption (default: both packages). Update fast-path string check to test against all configured modules.API (backward compatible)
Before / After
Implementation
I have a working implementation with all 25 tests passing (17 existing + 8 new). The diff is ~130 lines across 4 files:
src/transform.ts— parameterize module namesrc/index.ts— addmodulesoption, update fast-pathtest/transform.test.ts— 8 new testsREADME.md— document brand-icons + modules optionHappy to submit a PR if someone can point me to the right process (my EMU account can't fork this repo). I can share a
git format-patchif helpful.Motivation
1JS consumers (M365 Copilot, etc.) need brand icons but can't adopt them without atomic import support — the bundle cost of the barrel import is prohibitive.