-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
Docusaurus v3.6 is out with the Docusaurus Faster options 🥳 🎉
https://docusaurus.io/blog/releases/3.6
Docusaurus Faster
This is a meta-issue for the Docusaurus Faster project.
The goal is to modernize our infrastructure and greatly reduce the time and memory it takes to build a Docusaurus site in production mode, to fix this long-standing issue #4765.
yarn add @docusaurus faster
Before using these flags, you will need to add an extra package encapsulating all the opt-in dependencies:
It includes multiple experimental PRs adding new siteConfig.future.experimental_faster
options:
swcJsLoader
: Use SWC to transpile JS (instead of Babel).swcJsMinimizer
: Use SWC to minify JS (instead of Terser).swcHtmlMinimizer
: Use SWC to minify HTML and inlined JS/CSS (instead of html-minifier-terser).lightningCssMinimizer
: Use Lightning CSS to minify CSS (instead of cssnano and clean-css).rspackBundler
: Use Rspack to bundle your app (instead of webpack).mdxCrossCompilerCache
: Compile MDX files only once for both browser/Node.js environments instead of twice.ssgWorkerThreads
(🆕 v3.8+): Uses a Node.js Worker thread pool to optimize CPU usage during SSG.rspackPersistentCache
(🆕 v3.8+): Uses Rspack Persistent Cache to rebuild your site much faster.
const config = {
future: {
experimental_faster: {
optionName: true
},
},
}
We recommend turning them on all at once with a simple boolean shortcut. We also recommend turning future.v4
feature flag on, because some Docusaurus Faster options rely on upcoming changes.
const config = {
future: {
v4: true, // opt-in for Docusaurus v4 planned changes
experimental_faster: true, // turns Docusaurus Faster on globally
},
}
But you can also turn them on/off one by one to troubleshoot potential problems.
Note that the rspackBundler
option requires swcJsLoader
, swcJsMinimizer
, and lightningCssMinimizer
to be enabled first.
It is possible that certain combinations of options do not work, and our CI doesn't cover all possible permutations (only true
/ false
).
It also includes notable memory improvements:
- Rspack takes much less memory to bundle your app
- Fix important memory leak affecting i18n sites
What to expect
With experimental_faster: true
, our Docusaurus website builds:
- ~ 3-4x faster on cold builds 🔥
- ~ same on hot re-builds (because Rspack doesn't support persistent cache yet)
- the Rspack bundling consumes much less memory
Although rebuilds (with warm ./node_modules/.cache
) are not faster (yet), we recommend you enable the experimental_faster: true
option to future-proof your site against our new dependencies and report us potential problems you encounter.
Our core plugins/themes are all compatible with this new option, and we expect most community plugins to be compatible out-of-the-box. Some plugins might need minor adjustments to make them compatible with Rspack, and we'll help the community to make our ecosystem compatible with Rspack.
This option is relatively safe to use in production: we have deployed our own website with it already:
- If your Docusaurus site is standard, it should be fine out of the box
- If your Docusaurus site is more complex, make sure to test it thoroughly and give us feedback
For Docusaurus plugins authors
Some plugins implementing the configureWebpack()
lifecycle hook might need to adjust their code to add support for Rspack.
I will write a guide for them in this sister issue: #10572
Upgrade PRs
Example upgrade PRs to look at, including some benchmarks.
Community websites:
Popular plugins:
- PaloAltoNetworks/docusaurus-openapi-docs - demo website
- easyops-cn/docusaurus-search-local - demo website
- Redocusaurus - demo website
Contributing to this issue
We want our community to share feedback on this Docusaurus Faster project.
Please try to adopt it as part of the v3.6+ / canary releases, and tell us how it works for you.
If you encounter problems, please let us know here, and we might create dedicated issues if needed.
This general issue is a great place to follow the Docusaurus Faster project overall, as we try to stabilize it and aim to make it the default for an upcoming major version.