-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package performance and bundle-size #4882
Comments
I think this would be an amazing addition. I've recently noticed that on a simple example of using @carbon/icons-react package (within cra), the bundle was 2.16MB despite only importing a single icon: Looking at the es/index.js, looks like each is labeled as PURE but seems like that's not doing enough. |
@paul-sachs most like that's related to some kind of webpack configuration issue, if you install and use it from a stock CRA it will get tree-shaken so something is going on in the build and optimization pipeline 🤔 |
@joshblack this was a pretty clean cra app (created a few days ago) with some customize-cra to enable less loading along with bundle analyzer. I was surprised as well. Maybe you're right, might be just something weird about my config. |
@paul-sachs Did you solve that issue? |
@baeharam check the code for any ".../lib/..." imports that was the case for me |
@doublepithre I use typescript and when I use full import, type cannot be inferred. Any idea?
|
@baeharam try installing types for this package |
@doublepithre |
@doublepithre thank you!! this was the same issue I was having, removed the imports and my bundle size has been significantly reduced. 👍 |
I just filed #9651 (creating a Babel plugin to transform standard imports into subpackage imports), which I think would do wonders for developer experience, as well as resolve (/moot) the type problems for subpackage imports. |
Just bumped into this issue really bad. This is a bundle analysis for a Gatsby app. It's not just that tree shaking isn't working, in my case each icon brings a whole bucket of icons with it. Each bucket is 150-175K. This is humongous. I got several MB of icons and many many chunks @doublepithre solution worked brilliantly for me
|
Hi @cortopy, generally when all of the icons are included there is some part of a project that imports from Here's a quick way that we test to make sure icons are able to be tree-shaken: #6602 (comment) If there are steps to reproduce the issue that you're experiencing, let me know! Happy to take a look and see what's going on. |
Thanks @joshblack . In my case I didn't have any import of The only thing different I had was |
For these two, I like the idea of adding dangerJS and using it to get prod/PR bundle sizes and compare them, then comment on PRs. React uses this approach. They're using pre-minified bundles though. We'll need to minify ours before compressing with gzip and report on each. Ideally this would apply for every package in the monorepo, but we could start with just I also think compiling |
The risk of not doing this. We risk bloating the bundle size without knowing about it. |
Is the effort to reduce the size of packages still on? Trying to use tools like Bundlephobia to measure... Show build errors: Instead of the bundle size like other packages: |
In our Nuxt project, the top 5 dependencies are:
Using:
|
Just to clarify, this issue is for beginning to analyze, report, and track bundle size information. It's not an effort to reduce the bundle size (yet). Once we begin tracking the bundle size(s) and ensuring tree-shaking works on every PR, a workstream could spawn to work on evaluating if and how bundle size could be reduced.
I'm not sure why bundlephobia fails to build the package, pastelsky/bundlephobia#795 |
@tay1orjones thanks for the update! |
I see it works with other measure tools like pkg-size:
|
With Vite (rollup) I was doing bundle optimisation and experimenting with changing all the paths from the I compared 3 different approaches and settled on the vite-plugin way (published here; https://github.com/tablecheck/frontend/tree/main/packages/vite-import-massager-plugin)
Screenshot of carbon icons import in the main bundle. |
@SimeonC Last year we had a similar report about the default approach: If you'd like to continue discussing this please open a new issue. This one here is just regarding adding tooling for tracking our own bundle size(s) in PRs and over time. |
In 2020, we want to become more aware and sensitive to the performance of the packages we ship. Overall, this would include focusing on the following areas:
The text was updated successfully, but these errors were encountered: