Inefficient imports in carbon-components-react
See original GitHub issueWhat package(s) are you using?
-
carbon-components-react
Detailed description
I don’t even know how to describe it. Right now the whole library is vastly bloated and inefficient. Let’s say I want to import dropdown component, here’s what “import cost” plugin tells me:
Wow, a whooping 1,49 MB just to import dropdown component? Okay, going further. Inside the dropdown component:
As I can see, settings
is used only for adding prefixes. Why can’t you use this import:
Ahhh, so much better! Already saved 205 KB. Okay, coming next.
Is it really necessary to pull the whole icons-react
library? Why don’t you use this instead:
Saved 1,3 MB!
And so on, you get the idea. Same happens in every single component. Can you fix this to make the library at least somewhat usable?
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Guide
If you're importing styles from carbon-components , you can now import styles directly from @carbon/react or the @carbon/react/scss folder.
Read more >How am I supposed to use IBM's Svelte Carbon ...
Hello,. Recently I was rewriting the frontend for a small web application I have into Svelte and I liked the look of the...
Read more >Frontend Development - Open edX Community Wiki
(Plus) Carbon leverages an import-once mixin to prevent multiple imports of the same scss file. Allows components to freely require their dependencies: https:// ......
Read more >How We Reduced Our React App's Load Time by 60%
Using React by itself will not result in a highly performant application. If you're not careful, the application can pick up bloat easily....
Read more >Integrate ReactJS into a legacy Dojo application
Step 3: Whatever reusable components created in Step2, Import those components into Parent Component and frame it according to their rendering ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same
@joshblack,
I am having a similar issue where carbon/icons-react appears to pull in the whole library (1.8mb) despite specific icons being included.
import { Reset16, PlayFilledAlt16, PauseFilled16 } from '@carbon/icons-react';
I have the snippet above in two components within my code.
Is this expected behavior?
Update:
I also had used the UIShell component at some point in my code.
import { Header } from 'carbon-components-react/lib/components/UIShell';
Removing this UIShell code, indeed removed the large ‘@carbon/icons-react’ import. @joshblack I suspect the UIShell is somehow pulling in the entire ‘@carbon/icons-react’ - this might be something worth looking in to.-V