react-simple-icons: v5.2.0 tree shaking doesn't work as intended
I’ve been using this library for a long time and I’m very thankful for your work!
I’ve recently updated to v5.2.0 and tree shaking is now broken. I saw this issue #32 but I guess something must’ve changed since v3.
This is how I’m importing the icons:
import { Facebook, Instagram, Twitter } from "@icons-pack/react-simple-icons";
It’s a Next.js application with Typescript. Below you can see a before and after in bundle size:
No icons:
Page Size First Load JS
┌ ● / 811 B 129 kB
...
With icons:
Page Size First Load JS
┌ ● / 811 B 1.68 MB
...
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 18 (11 by maintainers)
Commits related to this issue
- 📦 downgrade react-simple-icons to 5.11 (icons-pack/react-simple-icons#140) — committed to skyclo/www by skyclo a year ago
- Downgrade `react-simple-icons` (#2533) The latest version has a tree shaking problem https://github.com/icons-pack/react-simple-icons/issues/140, which caused some of our pages to have 2MB! of java... — committed to LAION-AI/Open-Assistant by AbdBarho a year ago
- Update icons library Fix huge package issue when build: https://github.com/icons-pack/react-simple-icons/issues/140 — committed to ruchernchong/portfolio by ruchernchong a year ago
thanks @wootsbot, it solved the situation.
I was wondering, would it be a possible to import icons individually?
This has the advantage of being very explicit, while also giving faster build times because the bundler does not have to tree shake the entire package in every file where an icon is imported (looking at you MUI).
This works for now. Hoping to see a proper resolution for the v7s soon
This has been resolved in version v8.0.1.
@AbdBarho I’m working on a compiled refactor, I think at the moment it can help to solve
https://github.com/icons-pack/react-simple-icons/issues/140#issuecomment-1374944592
This has been resolved in version v8.0.1. I have had the opportunity to submit this refactoring. Please, feel free to report if you encounter any issues.
Just tried 7.1.1, same problem:
Is https://github.com/simple-icons/simple-icons/issues/8112 possibly related? I can confirm that this is an issue for me and prevents my Remix app from deploying on CF Pages (bundle size is > 1MB when using a few icons).
Edit: Downgrading to 5.11 fixes the issue.