iconsax-react: Production bundle returns all 6000 icons even when I import only 1 icon
As a dev, I would like to use iconsax library and I would like to use some of the icons, in my case, only one icon:
import { Folder } from 'iconsax-react';
...
return <Folder className={styles.icon} color={iconColor} variant="Bulk" aria-hidden />;
...
when I look at the generated bundle I expect to see one icon with the variant Bulk being generated, but instead, I see that all 6000 icons are included. This brings a lot of performance issues.
Looking at the Chrome DevTools I can see that the icons chunk takes 16 seconds to load when it is not in cache.

Solution
To include in the bundle only the icons used. Maybe the import should be something like this
import Folder from 'iconsax-react/Folder';
This way, we could even use it as lazy, please have a look at my simplified code:
import React, { Suspense, lazy } from 'react';
const Folder = lazy(() => import('iconsax-react/Folder')); <--- Lazy import
...
return (
<Suspense fallback={null}>
<Folder className={styles.icon} color={iconColor} variant="Bulk" aria-hidden />
</Suspense>;
)
...
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 16 (5 by maintainers)
I’m aware of this issue but unfortunately I did not have access to my computer this month to working on it.
that’s good idea. I might do that.
fixed this issue. version 0.0.4:
version 0.0.6:
please check new version and let me know if there is any issue.
@tofful I have same problem in react native. I think there is some problem with generation of modules. But didn’t have time to look what’s wrong.