question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inefficient imports in carbon-components-react

See original GitHub issue

What 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:

dropdown

Wow, a whooping 1,49 MB just to import dropdown component? Okay, going further. Inside the dropdown component:

settings

As I can see, settings is used only for adding prefixes. Why can’t you use this import:

settings1

Ahhh, so much better! Already saved 205 KB. Okay, coming next.

icons

Is it really necessary to pull the whole icons-react library? Why don’t you use this instead:

icons1

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:closed
  • Created 4 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
GraxMonzocommented, Jun 20, 2020

@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?

image

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

Same

2reactions
victordibiacommented, Dec 29, 2019

@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?

image

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found