Conversation
- Add @docusaurus/faster for Rspack bundler, SWC transpilation/minification, Lightning CSS, MDX cross-compiler cache, and multi-threaded SSG - Limit dev server to current version only for faster local development - Remove babel.config.js (replaced by SWC) - Add Docusaurus build cache step in CI workflow - Upgrade Node from 20 to 24 in CI - Compress 138 large PNG images with pngquant (65-80% quality)
330 additional images compressed (quality 65-80%, skip-if-larger). Reduces repository size and speeds up checkout, CI, and deployment.
Required by org policy that all actions must be pinned to a full-length commit SHA.
Rspack (which replaced webpack) runs as native Rust code outside the Node heap. With 6 GB allocated to Node, peak memory reached 8.3 GB total (Node + Rspack native), exceeding the 7 GB runner limit and causing the Linux OOM killer to terminate the build. Setting the heap to 4 GB leaves ~3 GB for Rspack and the OS.
The Rspack build peaks at ~8 GB, exceeding the 7 GB runner limit. Adding 10 GB swap prevents the Linux OOM killer from terminating the build process.
GitHub runners already have a 4 GB /swapfile in use. Disable it first, then recreate at 14 GB to give enough headroom for the Rspack build.
With 14 GB swap as safety net, the 6 GB heap allows V8 to GC less aggressively, improving build performance. Brief memory peaks above 7 GB will use swap instead of crashing.
There was a problem hiding this comment.
Pull request overview
Improve Docusaurus build performance by enabling the @docusaurus/faster toolchain, limiting dev-time version builds, and optimizing CI with caching and a newer Node runtime.
Changes:
- Enable
@docusaurus/faster/ Rspack + SWC viafuture.experimental_fasterflags - In dev, build only the
currentdocs version to speed upyarn start - Update CI to use Node 24, add swap space, and cache Docusaurus build artifacts
Reviewed changes
Copilot reviewed 4 out of 473 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| package.json | Adds @docusaurus/faster dependency to support faster build toolchain |
| docusaurus.config.ts | Enables faster toolchain flags and limits versions in development builds |
| babel.config.js | Removes Babel config no longer needed with SWC |
| .github/workflows/ci_cd.yml | Adds swap, updates Node version, and introduces build caching |
Comments suppressed due to low confidence (1)
package.json:23
- The new dependency uses a caret range (
^3.9.2) while other Docusaurus packages in this file appear to be pinned more tightly (e.g.,@docusaurus/theme-mermaid:3.9.2). To reduce the risk of version skew between tightly-coupled Docusaurus packages, consider pinning@docusaurus/fasterto the same exact version.
"@docusaurus/faster": "^3.9.2",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ...(process.env.NODE_ENV === 'development' && { | ||
| onlyIncludeVersions: ['current'], | ||
| }), |
There was a problem hiding this comment.
This object spread pattern can fail TypeScript type-checking with errors like 'Spread types may only be created from object types' because the expression is false | { ... }. Prefer a ternary that always returns an object (e.g., condition ? { ... } : {}) to keep the config TS-safe.
| ...(process.env.NODE_ENV === 'development' && { | |
| onlyIncludeVersions: ['current'], | |
| }), | |
| ...(process.env.NODE_ENV === 'development' | |
| ? { onlyIncludeVersions: ['current'] } | |
| : {}), |
| # Resize existing swap from default 4 GB to 14 GB | ||
| sudo swapoff /swapfile || true | ||
| sudo rm -f /swapfile | ||
| sudo fallocate -l 14G /swapfile | ||
| sudo chmod 600 /swapfile | ||
| sudo mkswap /swapfile | ||
| sudo swapon /swapfile |
There was a problem hiding this comment.
Allocating a fixed 14G swapfile can fail on ubuntu-latest if there isn’t enough free disk after checkout and dependency install (leading to workflow failures). Consider sizing swap dynamically based on available disk space, or using a smaller/default swap increase to reduce the chance of fallocate failing.
| # Resize existing swap from default 4 GB to 14 GB | |
| sudo swapoff /swapfile || true | |
| sudo rm -f /swapfile | |
| sudo fallocate -l 14G /swapfile | |
| sudo chmod 600 /swapfile | |
| sudo mkswap /swapfile | |
| sudo swapon /swapfile | |
| # Resize existing swap from default 4 GB to up to 14 GB, depending on free disk space | |
| sudo swapoff /swapfile || true | |
| sudo rm -f /swapfile | |
| # Determine available disk space (in MiB) on the root filesystem | |
| AVAIL_MB=$(df -m / | awk 'NR==2 {print $4}') | |
| # Leave 2 GiB free to avoid filling the disk | |
| TARGET_MB=$((AVAIL_MB - 2048)) | |
| # Cap swap size at 14 GiB (14336 MiB) | |
| MAX_SWAP_MB=14336 | |
| if [ "$TARGET_MB" -gt "$MAX_SWAP_MB" ]; then | |
| TARGET_MB=$MAX_SWAP_MB | |
| fi | |
| # Ensure a reasonable minimum of 4 GiB (4096 MiB) | |
| MIN_SWAP_MB=4096 | |
| if [ "$TARGET_MB" -lt "$MIN_SWAP_MB" ]; then | |
| echo "Not enough free disk space to safely allocate ${MIN_SWAP_MB} MiB swap; skipping swap resize." | |
| else | |
| echo "Allocating ${TARGET_MB} MiB of swap space..." | |
| sudo fallocate -l "${TARGET_MB}M" /swapfile | |
| sudo chmod 600 /swapfile | |
| sudo mkswap /swapfile | |
| sudo swapon /swapfile | |
| fi |
| - name: Cache Docusaurus build | ||
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | ||
| with: | ||
| path: | | ||
| .docusaurus | ||
| node_modules/.cache | ||
| key: docusaurus-${{ runner.os }}-${{ hashFiles('yarn.lock', 'docusaurus.config.ts', 'versions.json') }} | ||
| restore-keys: | | ||
| docusaurus-${{ runner.os }}- |
There was a problem hiding this comment.
The cache key doesn’t include the Node version. If the Node version changes (or differs across runners), restoring .docusaurus / node_modules/.cache across Node versions can cause flaky builds or hard-to-debug bundler cache issues. Consider incorporating node-version (and potentially Docusaurus version) into the cache key.
Summary
@docusaurus/faster— includes MDX cross-compiler cache, Lightning CSS, multi-threaded SSG, and persistent build cacheyarn start), so the dev server starts in seconds instead of minutesAll 18 versions and all API language tabs remain in production builds.
Test plan
yarn start— dev server starts quickly with only "current" versionyarn build— full production build succeeds with all 18 versionsexperimental_fasterflags can be toggled off