Library
React Components / v9 (@fluentui/react-components)
System Info
Are you reporting Accessibility issue?
no
Reproduction
Import FluentProvider and render it in a blank app.
Bug Description
Actual Behavior
All of @fluentui/react-icons is parsed at minimum, and downloaded if you use a bundler that loads packages independently (like Cloudpack.)
This is due to a single line of code:
|
import { IconDirectionContextProvider } from '@fluentui/react-icons'; |
import { IconDirectionContextProvider } from '@fluentui/react-icons';
This results in a big dent in development loop performance, and in the Cloudpack case, the most vanilla page renders 500ms slower.
Expected Behavior
Loading the FluentProvider should not add more than a couple milliseconds to the page load.
This is how:
Create an independent entry-point for the non-icon code, and add it to the exports map. Then change the fluent provider code to use that entry point, rather than asking the tooling to loading every possible icon and then figuring out you only want the provider.
In other words, change this line of code in the FluentProvider render to this:
import { IconDirectionContextProvider } from '@fluentui/react-icons/providers';
Note: the /providers path in the import!
In the react-icons package.json, document the ./providers entry:
"exports": {
// etc
"./providers": {
"types": "./lib/providers.d.ts",
"import": "./lib/providers.js",
"require": "./lib-commonjs/providers.js"
}
}
...and add ./src/providers.ts to export just providers:
export { IconDirectionContextProvider } from './IconDirectionContextProvider';
// etc
Now when a dev loads up fluent provider, no huge perf penalty. Much better initial experience!
One other note: there are many packages in fluent ui that import @fluentui/react-icons. These are going to cause the same issue. We should consider a couple of additional entries for these:
./common-icons - this should export all icons fluent components generally need. Chevrons, Add, upload, plus/minus, share, etc.
./extended-icons - dumping ground for everything else
Once these are there, we scrub the entire repo and only import from ./common-icons. Partners can get extended icons from ./extended-icons. Or, even better, break that into 3 or 4 more logical groupings to give partners more ways to import what they need than only the "everything" option.
Logs
Requested priority
Normal
Products/sites affected
office
Are you willing to submit a PR to fix?
no
Validations
Library
React Components / v9 (@fluentui/react-components)
System Info
Are you reporting Accessibility issue?
no
Reproduction
Import
FluentProviderand render it in a blank app.Bug Description
Actual Behavior
All of
@fluentui/react-iconsis parsed at minimum, and downloaded if you use a bundler that loads packages independently (like Cloudpack.)This is due to a single line of code:
fluentui/packages/react-components/react-provider/src/components/FluentProvider/renderFluentProvider.tsx
Line 15 in 87f37bc
This results in a big dent in development loop performance, and in the Cloudpack case, the most vanilla page renders 500ms slower.
Expected Behavior
Loading the
FluentProvidershould not add more than a couple milliseconds to the page load.This is how:
Create an independent entry-point for the non-icon code, and add it to the exports map. Then change the fluent provider code to use that entry point, rather than asking the tooling to loading every possible icon and then figuring out you only want the provider.
In other words, change this line of code in the FluentProvider render to this:
Note: the
/providerspath in the import!In the react-icons package.json, document the
./providersentry:...and add
./src/providers.tsto export just providers:Now when a dev loads up fluent provider, no huge perf penalty. Much better initial experience!
One other note: there are many packages in fluent ui that import
@fluentui/react-icons. These are going to cause the same issue. We should consider a couple of additional entries for these:./common-icons- this should export all icons fluent components generally need. Chevrons, Add, upload, plus/minus, share, etc../extended-icons- dumping ground for everything elseOnce these are there, we scrub the entire repo and only import from
./common-icons. Partners can get extended icons from./extended-icons. Or, even better, break that into 3 or 4 more logical groupings to give partners more ways to import what they need than only the "everything" option.Logs
Requested priority
Normal
Products/sites affected
office
Are you willing to submit a PR to fix?
no
Validations