You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After consuming @primer/octicons-v2-react in the memex package, I noticed that the bundle size jumped about 130 kb (gzipped / minified). I thought that perhaps we didn't have tree-shaking working properly in our build system, so I played around with it a little bit, but couldn't quite get anything working.
So, I decided to start with a clean repo (based on create-react-app), and see if I could get it working there. When I was unable to, I decided to pull in a different icon library - react-feather to see if I could get tree-shaking working with it. I was able to with no extra configuration.
Here are the repro steps and the bundle size differences I encountered.
This quick test shows us that including a single react-feather icon in your bundle adds about 800 bytes, whereas adding a single @primer/octicons-v2-react icon to your bundle adds 129 KB - so tree-shaking is not happening.
The text was updated successfully, but these errors were encountered:
dmarcey
changed the title
Tree-Shaking doesn't work for @primer/octicons-v2-react
Request to add support for tree-shaking in @primer/octicons-v2-reactApr 21, 2020
dmarcey
changed the title
Request to add support for tree-shaking in @primer/octicons-v2-react
Request to add support for tree-shaking in @primer/octicons-v2-react
Apr 21, 2020
After consuming
@primer/octicons-v2-react
in the memex package, I noticed that the bundle size jumped about 130 kb (gzipped / minified). I thought that perhaps we didn't have tree-shaking working properly in our build system, so I played around with it a little bit, but couldn't quite get anything working.So, I decided to start with a clean repo (based on
create-react-app
), and see if I could get it working there. When I was unable to, I decided to pull in a different icon library -react-feather
to see if I could get tree-shaking working with it. I was able to with no extra configuration.Here are the repro steps and the bundle size differences I encountered.
git clone [email protected]:dmarcey/tree-shaking-test.git
(https://github.com/dmarcey/tree-shaking-test)cd tree-shaking-test
yarn install
yarn build
Bundle size:39.39 KB build/static/js/2.a430f49c.chunk.js
import
and usage ofCamera
).yarn build
Bundle size:40.17 KB (+802 B) build/static/js/2.b6d6f8f9.chunk.js
yarn build
import
and usage ofRepoIcon
)yarn build
Bundle size:168.39 KB (+129 KB) build/static/js/2.6febd43a.chunk.js
This quick test shows us that including a single
react-feather
icon in your bundle adds about 800 bytes, whereas adding a single@primer/octicons-v2-react
icon to your bundle adds 129 KB - so tree-shaking is not happening.I stumbled across #335 by chance - where it looks like there was an attempt made to have each icon in its own file - which looks to be the same approach taken by
react-feather
, which are then all exported individual at a top-levelindex.js
.https://github.com/feathericons/react-feather/tree/master/src/icons
Let me know if any more info is needed - we'd love to help get this resolved before octicons v2 goes live!
cc/ @colebemis @emplums
The text was updated successfully, but these errors were encountered: