docusaurus
docusaurus copied to clipboard
[WIP]: Use Rspack instead of Webpack
Disclaimer
For now, this is only a POC to see how complicated it would be to switch bundlers or provide an alternative bundler as an experimental flag. We also hope to measure possible performance improvements.
We don't have a real plan yet.
Motivation
Rspack is mostly retro-compatible with Webpack and the most suitable choice for Docusaurus in the short term (see also https://github.com/facebook/docusaurus/issues/4765#issuecomment-2066226942)
This should improve bundling performance, the main bottleneck for many sites.
State
The current state of this PR:
-
yarn start
works for the Docusaurus website 🎉 -
yarn build
works for the Docusaurus website 🎉
But we are not done, there are many details to handle before it becomes usable. For example, restoring the ChunkAssetPlugin)
Note: the Rspack team is willing to help us and most of the initial POC code is inspired by @hardfist patch on our init template here: https://github.com/hardfist/docusaurus-rspack/pull/1
Performance
Approximate build time measurements taken on a local MacBook pro M3 on 14 August :
For yarn build:website:fast
:
- Rspack: 36s (bundling 26s, SSG 5s)
- Webpack: 57s (bundling 47s, SSG 6s)
For yarn build:website --locale en
:
- Rspack: 66s (bundling 43s, SSG 17s)
- Webpack: 98 (bundling 72s, SSG 20s)
Note: these measures involve running yarn clear:website
first. Rspack does not support (yet) persistent caching like Webpack.
Note: these results are not final, and ballpark estimates. They may change in the future.
Surprisingly, it seems to improve the SSG performance too. We'll have to figure out why, maybe the server output is more optimized.
Test Plan
CI
Test links
https://deploy-preview-10402--docusaurus-2.netlify.app/
Related issues/PRs
https://github.com/facebook/docusaurus/issues/4765