Replies: 2 comments
-
Hi, @kaelig, thx for your tips & tricks. In our company we have rich codebase and bundles can be like 50mb plus and build time can be 5 mins plus. So we decided to change our speeding up strategy from speeding up webpack & co to microfrontends. According to my calculations with this strategy we can speed up both build time and bundle size 3 times. |
Beta Was this translation helpful? Give feedback.
-
This article by @liorheber contains a few great performance tips as well: https://medium.com/kenshoos-engineering-blog/how-to-test-400-react-components-without-breaking-a-sweat-aa304a5cc72b ❤️ |
Beta Was this translation helpful? Give feedback.
-
While setting up Storybook on a pretty large TypeScript codebase (the Shopify admin), I found that some configuration tweaks led to significantly better development performance (both build times & incremental compilation times).
Finding these optimizations tweaks was a rather painful process, so I thought I'd share them back in case it could be useful to other people.
Please consider sharing your optimization tricks in the comments below, and help the community get faster Storybooks.
🙏❤
Our config (and build performance telemetry plugin)
Here's our Stack: React 16, Webpack 4, TypeScript (compiled using Babel), GraphQL, Apollo, and a few big-ish decorators including Polaris React's theme & localization providers.
At the time of posting this, loading our Storybook downloads ~30MB of assets, for the most part JS bundles.
To make it easy to benchmark the effect of the optimizations, I keep all of them behind the flag
enableExperimentalPerformanceTweaks
, and created aTelemetryPlugin
that reports a few metrics into a dashboard, so I can track possible performance regressions/improvements when updating Storybook, or as the number of stories increases.Here are all of the optimization tweaks in our config, annotated with the performance benefit they bring. Your mileage may vary, and some optimizations will result in lack of certain functionality (worth it for us). Feedback and questions are welcome!
Setup
Bundle splitting
If you have a large amount of dependencies, you can easily end up with very large >10mb bundles. Large bundles are slower to load than multiple smaller bundles (especially when developing in GitHub Codespaces or equivalent), so this helps us parallelize downloads and save some load time.
We apply this setting both to the manager and preview (iframe) using
config.optimization = { splitChunks };
.General settings
Preview (iframe) webpack config
Manager webpack config
Performance telemetry plugin
We keep an eye on compilation time and bundle size over time, to see the impact of Storybook updates, config changes, and # of stories on our development experience.
Beta Was this translation helpful? Give feedback.
All reactions