-
TLDR: We're looking at changing the underlying bundler at Gatsby. See the "How can I help?" section to see what we're looking to get from you, our community! MotivationWe at Gatsby are always aiming to provide the most efficient product to create blazing fast websites. A significant portion of Gatsby’s build is taken by bundling generated assets for deployment. Currently, we use webpack to handle that bundling. Though webpack has been a tried and true tool for web applications in the last decade, it has recently proven to be slow, relatively speaking. Other bundlers (specifically bundlers using highly performant languages like Rust/Go) have become mainstage that provide improvements in speed and bundler size. We’ve done some initial benchmarking with a simple test site, which can be found here. In switching bundlers, we plan to see improvements in warm, cold, and develop builds. While we aim to continuously improve the build speed and efficiency, we want to enable the use of modern tools without reducing the feature set. As we iterate on this project, we hope to provide updated APIs that will make swapping tools much easier in the future. We plan to provide support for the best development tools and increased speed as you develop your blazing fast websites. Considerations
Alternatives
What’s next?Over the next few months, we’ll be working on a proof of concept for moving bundlers. As we continue discussing this RFC, we’ll be iterating on the project. Expect another RFC in a few months as these changes continue to be hashed out. With the launch of Gatsby 5, we’re planning to ship a new bundler by default with an opt-out flag to stay on the current webpack configuration. Adoption StrategyAs of now, Gatsby’s plan is to support both the new configuration and an opt-out flag to continue using webpack throughout the lifetime of Gatsby 5. We will be creating a new API for a generic How can I help?At this stage of the RFC, we’re principally looking for areas we’ve missed while we’re evaluating and planning for a bundler change. There will be a later stage where we have actual projects for you to try and provide more detailed feedback, and we will provide updates in this discussion. Our questions to you, our users are:
While I’m sure some of us have strong preferences for specific bundlers, we’re really focused on understanding the considerations regardless the specific target bundler so that we responsibly frame and plan for this kind of change. Resources |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments 27 replies
-
Speaking purely from a selfish standpoint, Vite seems to be clearly the winner in terms of parse time and bundle size. Yes I'm one of those people who cares about every byte that gets sent to the client. I appreciate though that there are many other considerations especially for plug-in maintainers and the overall health of the Gatsby ecosystem. |
Beta Was this translation helpful? Give feedback.
-
I don't find the numbers nor the rationale convincing. Webpack has a massive ecosystem, massive downloads per month (still growing, see https://www.npmtrends.com/vite-vs-webpack), is still improving fast and has support ($) from major tech companies. Just earlier, the folks at Vercel have proven once again that you can make webpack blazing fast if you focus on improving existing projects and not reinvent the wheel: https://nextjs.org/blog/next-12-1 Taking your rough benchmarks, you are telling us that you are ready to break most Gatsby plugins (a big portion of Gatsby plugins are just wrapper for webpack plugins and loaders) and alienate Gatsby developers for ~4 seconds in build time? The NextJS team has proven that it is possible to get very fast build times by replacing specific parts that are slow, with faster alternatives, why can't Gatsby do the same? I don't find the arguments strong enough for such a major change. I feel that there are A LOT of low-hanging fruits from the likes of esloader, swc and other babel/tsc/terser replacements that could be tried before Gatsby introduce such a massive change. Although this is an RFC, it looks like the decision has been taken already... v4 already included Vite as a dependency to support TS in config files. |
Beta Was this translation helpful? Give feedback.
-
A decent amount of webpack “slowness” is related to it being node based, the buffers used to read the FS are extremely slow for UTF strings. I’ve been working on this for a little while. if you need a speed boost. Tweak libuv thread pool size |
Beta Was this translation helpful? Give feedback.
-
Everyone always talks about build speed but another important factor is memory usage during the build. |
Beta Was this translation helpful? Give feedback.
-
The way gatsby ships webpack is already a headache, the more I think about this, the more I struggle to imagine a scenario where this is going to make life better. The rollout of major version changes has hardly been smooth even without introducing breaking changes on this scale. Drop the opt-out, default to webpack and let people who want something different play with your new toy and maybe, maybe it'd start to make more sense, but this just seems like a horrible idea for the ecosystem at this point in time. |
Beta Was this translation helpful? Give feedback.
-
There are a few things to bear in mind with those benchmarks, and there are a few takeaways... For the majority of people, there will only be a small gain (eg. ~4 seconds). However, for much more complex sites, which Gatsby is trying hard to cater to as well (eg. enterprise), there is a massive improvement: Note: this is essentially the same as our use-case, so we'd benefit from this. For even more complex sites, webpack doesn't even work: So this is likely to be a key motivator for moving away from webpack to something like esbuild. On the flip-side, I agree with the concerns about existing plugins that currently rely on webpack. Gatsby has a huge eco-system of plugins that haven't been updated to support Gatsby v4, but they still work. Changing the bundler is likely to kill off a number of those. Also, webpack has a pretty great API and is highly customisable with plenty of plugins too. Some of the other bundlers, despite being blazingly fast, are still relatively new, and inherently risky if you're going with an opt-out approach. I thought this feature comparison was quite interesting as it mentions esbuild and vite: It seems esbuild is still not yet production ready and relying heavily on the community to create plugins for things like HMR. One worrying factor of esbuild is that there is a whole section dedicated to it being flagged by anti-virus software due to it being native code. |
Beta Was this translation helpful? Give feedback.
-
Love this initiative. Big vote of support here. One data point in support of esbuild is that another awesome dev toolchain, Serverless Stack uses it for building/bundling lambdas. They chose it to make their live lambda debugging developer experience as fast/awesome as possible. |
Beta Was this translation helpful? Give feedback.
-
Yes! Faster and smaller, please 👏👏 |
Beta Was this translation helpful? Give feedback.
-
@j0sh77 Which bundler do you folks going to move to ? ESBuild or Vite? |
Beta Was this translation helpful? Give feedback.
-
When will this be implemented? Should we wait until is released and tested? |
Beta Was this translation helpful? Give feedback.
-
I personally would love to see the Vite approach, where Vite uses the browser during development for handling project files, while it uses a faster bundler (esbuild) for dependencies, but still uses a well supported/large ecosystem bundler for the prod builds (Rollup/Babel support). So yeah, a Vite approach, but with Webpack, would be gold ✨ And if there are special Babel Plugins, they still can be potentially run in the "browser" during development (or on the dev server if needed). I have some experience with esbuild, and when you try to use it with emotion it gets tricky – esbuild still does not support the React v17 jsx transform. Also interesting to see is, that many (most) of the esbuild community plugins do use Babel (and not Go) to make the work. So this slows down things significant again, because, suddenly, your code needs to build an AST anyway. And what about the memory consumption then? 🤦♂️ Another thing I want to share is the removal of GraphQL queries. Right now this plugin does the job. But it could be written like the flow team did for removing flow types – the performance looks like a lot faster, even its written in Node.js. swc on the other hand, tries hard to create a better system/interface so quality plugins can come into the game. But its very early still and experimental. Very interesting is also bun but it may take some years to catch up. In conclusion:
|
Beta Was this translation helpful? Give feedback.
-
Hey all! Through the month of April, the Gatsby Core team pursued a proof of concept for migrating to a faster bundler with Parcel to produce the fastest developer experience for Gatsby developers. Goals of the proof of concept can be found below in the original RFC description.
The outcome of the proof of concept is that Gatsby will not migrate to a new bundler as part of Gatsby 5. There are few key reasons why we made this call:
To be clear, we’re not saying “never” to a new bundler in Gatsby. For example, Gatsby already uses and will continue to use Parcel for our support of We are, however, saying “not right now.” Further, the Parcel core team has been fantastic to work with, and we plan to stay in touch as Parcel evolves, and will re-evaluate when the necessary features are planned for development with their team. So, where do we go from here? We believe there are meaningful optimization opportunities within the Gatsby build process, and we’re building a plan for those optimizations which we’ll release as they’re implemented. Thank you to everyone who contributed their perspectives on this research. |
Beta Was this translation helpful? Give feedback.
-
Came here to say its quite unfortunate to see this is not getting on the immediate roadmap! Since moving to v4 and webpack 5 the development building has been super slow and to a point that we need to spend time thinking and experimenting on how to solve this instead of shipping meaningful features. And building less pages is not a solution at this point. It takes us a whopping 300 seconds to build development bundle and by reducing drastically the nodes we build we arrive at 180 seconds which is still super slow compared to what the experience was a little bit back! (Working on a decent Macbookpro from with 16gb Ram and 2.9 i5 intel). 120k lines of code between js and css files and around 1000 files. For comparison our production builds which build even more nodes take only 95 seconds to build bundles (CircleCi Docker / X-Large)!!!!!!! |
Beta Was this translation helpful? Give feedback.
-
Bun Bun Bun Bun Time🥇 👍 💯 |
Beta Was this translation helpful? Give feedback.
-
I think this is what you've been waiting for: https://turbo.build/pack 👈 |
Beta Was this translation helpful? Give feedback.
-
@j0sh77 Soon a brand new port of Webpack, written in Rust will be released. They need to know what Hooks they also should port. Please help them out with everything we need to make it work with Gatsby 🙏🏻 https://twitter.com/scriptedalchemy/status/1620622790138400769?s=46&t=EGW3V18F3st94N9vwLXrXw |
Beta Was this translation helpful? Give feedback.
-
Hi team i tried Got the following error, but am super keen to keep slugging away on this if its helpful?
Gatsby Info
|
Beta Was this translation helpful? Give feedback.
Hey all!
Through the month of April, the Gatsby Core team pursued a proof of concept for migrating to a faster bundler with Parcel to produce the fastest developer experience for Gatsby developers. Goals of the proof of concept can be found below in the original RFC description.
Our proof of concept used Parcel as the target bundler, since Parcel:
The outcome of the proof of concept is that Gatsby will not migrate to a new bundler as part of Gatsby 5.…