Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

build(website): build with Docusaurus Faster

EtienneLescot959872b7dd7a
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 4ab83d6b1..ac2f95609 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -83,6 +83,19 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
run: npm run build
+ # The rspack-minimizers plugin in docusaurus.config.ts edits options that
+ # Rspack keeps privately, so an Rspack update can make it a silent no-op:
+ # the license files disappear and range media queries come back, and the
+ # build still passes. `if` rather than `! grep`, which `bash -e` ignores
+ # unless it is the last command.
+ - name: Check minifier output
+ working-directory: website/build
+ run: |
+ ls assets/js/main.*.js.LICENSE.txt
+ if grep -qE '\((width|height)[<>]' assets/css/*.css */assets/css/*.css; then
+ echo "Range media syntax in CSS: the rspack-minimizers plugin no longer applies."
+ exit 1
+ fi
- name: Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts
index 942ef3335..456f4ac93 100644
--- a/website/docusaurus.config.ts
+++ b/website/docusaurus.config.ts
@@ -225,6 +225,16 @@ function readAppLanguages(tag: string | undefined): AppLanguage[] {
});
}
+// The two @rspack/core minimizers the rspack-minimizers plugin adjusts, reduced
+// to what it touches: the options each instance was constructed with.
+type RspackMinimizer<Options> = abstract new (...args: never[]) => { _args: [Options] };
+type RspackMinimizers = {
+ SwcJsMinimizerRspackPlugin: RspackMinimizer<{ extractComments?: boolean }>;
+ LightningCssMinimizerRspackPlugin: RspackMinimizer<{
+ minimizerOptions: { include?: { mediaRangeSyntax?: boolean } };
+ }>;
+};
+
type BuildLookups = {
starCount: number | null;
release: Awaited<ReturnType<typeof fetchLatestRelease>>;
@@ -361,6 +371,33 @@ export default async function createConfig(): Promise<Config> {
},
},
+ // Docusaurus Faster (Rspack, SWC, Lightning CSS). Each of the eight locales
+ // is a full build of its own, and bundling is most of `npm run build`.
+ // Measured locally on Windows, not on CI: with no cache, as in CI, the full
+ // build took 2m54s to 3m02s with webpack and 29s to 52s with this; with a
+ // warm cache, about 23s either way. The output matches the webpack build's
+ // once the rspack-minimizers plugin below and the two flags turned off here
+ // are in place. ssgWorkerThreads is left out: Docusaurus only starts worker
+ // threads above 100 pages per locale (the English build has 42), and it
+ // needs a future.v4 flag.
+ future: {
+ faster: {
+ swcJsLoader: true,
+ swcJsMinimizer: true,
+ lightningCssMinimizer: true,
+ mdxCrossCompilerCache: true,
+ rspackBundler: true,
+ rspackPersistentCache: true,
+ // Its HTML parser turns the NUL bytes React leaves in an attribute into
+ // U+FFFD before fix-build-output can drop them: 19 ja, zh and pt-BR pages
+ // had one in a sidebar title="…" or an aria-label.
+ swcHtmlMinimizer: false,
+ // The eager Git reader keys files by absolute path, and the sitemap asks
+ // for a .tsx page by relative path: / and /download/ lost <lastmod>.
+ gitEagerVcs: false,
+ },
+ },
+
headTags: [
{
tagName: "link",
@@ -422,6 +459,29 @@ export default async function createConfig(): Promise<Config> {
}
},
}),
+ // Rspack's minimizers, as Docusaurus Faster builds them, change two things
+ // the webpack ones did not, and Docusaurus takes no option for either, so
+ // this edits the options each instance keeps in `_args` until Rspack
+ // applies it. Recheck on a Docusaurus or Rspack upgrade. SWC dropped the
+ // license comments of the bundled libraries (React, NProgress, lucide),
+ // which Terser moved to *.js.LICENSE.txt. Lightning CSS wrote every
+ // `min-width` query in range syntax, which UC Browser 15.5, a browserslist
+ // target that Lightning CSS cannot target, does not read.
+ () => ({
+ name: "rspack-minimizers",
+ configureWebpack(config, isServer, { currentBundler }) {
+ if (isServer || currentBundler.name !== "rspack") return {};
+ const rspack = currentBundler.instance as unknown as RspackMinimizers;
+ for (const plugin of config.optimization?.minimizer ?? []) {
+ if (plugin instanceof rspack.SwcJsMinimizerRspackPlugin) {
+ plugin._args[0].extractComments = true;
+ } else if (plugin instanceof rspack.LightningCssMinimizerRspackPlugin) {
+ plugin._args[0].minimizerOptions.include = { mediaRangeSyntax: true };
+ }
+ }
+ return {};
+ },
+ }),
],
presets: [
diff --git a/website/package-lock.json b/website/package-lock.json
index 7990a1bfa..05996fd04 100644
--- a/website/package-lock.json
+++ b/website/package-lock.json
@@ -9,6 +9,7 @@
"version": "0.0.0",
"dependencies": {
"@docusaurus/core": "~3.10.1",
+ "@docusaurus/faster": "~3.10.1",
"@docusaurus/preset-classic": "~3.10.1",
"@docusaurus/theme-common": "~3.10.1",
"@docusaurus/utils": "~3.10.1",
@@ -3562,8 +3563,6 @@
"resolved": "https://registry.npmjs.org/@docusaurus/faster/-/faster-3.10.1.tgz",
"integrity": "sha512-XTZhE5C1gZ/DaYYMlSk02dwP5vhpQON5QHVz1s3892mSESAywgWanURpXEDAvt4GvGuq7s+XP8rTWHZvfaJmdQ==",
"license": "MIT",
- "optional": true,
- "peer": true,
"dependencies": {
"@docusaurus/types": "3.10.1",
"@rspack/core": "^1.7.10",
@@ -4144,7 +4143,6 @@
"integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==",
"license": "MIT",
"optional": true,
- "peer": true,
"dependencies": {
"@emnapi/wasi-threads": "1.2.3",
"tslib": "^2.4.0"
@@ -4156,7 +4154,6 @@
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
"license": "MIT",
"optional": true,
- "peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
@@ -4167,7 +4164,6 @@
"integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==",
"license": "MIT",
"optional": true,
- "peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
@@ -4744,17 +4740,13 @@
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/@module-federation/error-codes/-/error-codes-0.22.0.tgz",
"integrity": "sha512-xF9SjnEy7vTdx+xekjPCV5cIHOGCkdn3pIxo9vU7gEZMIw0SvAEdsy6Uh17xaCpm8V0FWvR0SZoK9Ik6jGOaug==",
- "license": "MIT",
- "optional": true,
- "peer": true
+ "license": "MIT"
},
"node_modules/@module-federation/runtime": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/@module-federation/runtime/-/runtime-0.22.0.tgz",
"integrity": "sha512-38g5iPju2tPC3KHMPxRKmy4k4onNp6ypFPS1eKGsNLUkXgHsPMBFqAjDw96iEcjri91BrahG4XcdyKi97xZzlA==",
"license": "MIT",
- "optional": true,
- "peer": true,
"dependencies": {
"@module-federation/error-codes": "0.22.0",
"@module-federation/runtime-core": "0.22.0",
@@ -4766,8 +4758,6 @@
"resolved": "https://registry.npmjs.org/@module-federation/runtime-core/-/runtime-core-0.22.0.tgz",
"integrity": "sha512-GR1TcD6/s7zqItfhC87zAp30PqzvceoeDGYTgF3Vx2TXvsfDrhP6Qw9T4vudDQL3uJRne6t7CzdT29YyVxlgIA==",
"license": "MIT",
- "optional": true,
- "peer": true,
"dependencies": {
"@module-federation/error-codes": "0.22.0",
"@module-federation/sdk": "0.22.0"
@@ -4778,8 +4768,6 @@
"resolved": "https://registry.npmjs.org/@module-federation/runtime-tools/-/runtime-tools-0.22.0.tgz",
"integrity": "sha512-4ScUJ/aUfEernb+4PbLdhM/c60VHl698Gn1gY21m9vyC1Ucn69fPCA1y2EwcCB7IItseRMoNhdcWQnzt/OPCNA==",
"license": "MIT",
- "optional": true,
- "peer": true,
"dependencies": {
"@module-federation/runtime": "0.22.0",
"@module-federation/webpack-bundler-runtime": "0.22.0"
@@ -4789,17 +4777,13 @@
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/@module-federation/sdk/-/sdk-0.22.0.tgz",
"integrity": "sha512-x4aFNBKn2KVQRuNVC5A7SnrSCSqyfIWmm1DvubjbO9iKFe7ith5niw8dqSFBekYBg2Fwy+eMg4sEFNVvCAdo6g==",
- "license": "MIT",
- "optional": true,
- "peer": true
+ "license": "MIT"
},
"node_modules/@module-federation/webpack-bundler-runtime": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/@module-federation/webpack-bundler-runtime/-/webpack-bundler-runtime-0.22.0.tgz",
"integrity": "sha512-aM8gCqXu+/4wBmJtVeMeeMN5guw3chf+2i6HajKtQv7SJfxV/f4IyNQJUeUQu9HfiAZHjqtMV5Lvq/Lvh8LdyA==",
"license": "MIT",
- "optional": true,
- "peer": true,
"dependencies": {
"@module-federation/runtime": "0.22.0",
"@module-federation/sdk": "0.22.0"
@@ -4811,7 +4795,6 @@
"integrity": "sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw==",
"license": "MIT",
"optional": true,
- "peer": true,
"dependencies": {
"@emnapi/core": "^1.5.0",
"@emnapi/runtime": "^1.5.0",
@@ -5074,8 +5057,6 @@
"resolved": "https://registry.npmjs.org/@rspack/binding/-/binding-1.7.12.tgz",
"integrity": "sha512-f4HHuLbvuld8Ba4iB/4ibse5XrKxFrgmM3S4P2AOKnPlekAFlBjmltCuaTL/W2ggYvILaVY+YcFXrEH1rrKeQA==",
"license": "MIT",
- "optional": true,
- "peer": true,
"optionalDependencies": {
"@rspack/binding-darwin-arm64": "1.7.12",
"@rspack/binding-darwin-x64": "1.7.12",
@@ -5100,8 +5081,7 @@
"optional": true,
"os": [
"darwin"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-darwin-x64": {
"version": "1.7.12",
@@ -5114,8 +5094,7 @@
"optional": true,
"os": [
"darwin"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-linux-arm64-gnu": {
"version": "1.7.12",
@@ -5128,8 +5107,7 @@
"optional": true,
"os": [
"linux"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-linux-arm64-musl": {
"version": "1.7.12",
@@ -5142,8 +5120,7 @@
"optional": true,
"os": [
"linux"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-linux-x64-gnu": {
"version": "1.7.12",
@@ -5156,8 +5133,7 @@
"optional": true,
"os": [
"linux"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-linux-x64-musl": {
"version": "1.7.12",
@@ -5170,8 +5146,7 @@
"optional": true,
"os": [
"linux"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-wasm32-wasi": {
"version": "1.7.12",
@@ -5182,7 +5157,6 @@
],
"license": "MIT",
"optional": true,
- "peer": true,
"dependencies": {
"@napi-rs/wasm-runtime": "1.0.7"
}
@@ -5198,8 +5172,7 @@
"optional": true,
"os": [
"win32"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-win32-ia32-msvc": {
"version": "1.7.12",
@@ -5212,8 +5185,7 @@
"optional": true,
"os": [
"win32"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/binding-win32-x64-msvc": {
"version": "1.7.12",
@@ -5226,16 +5198,13 @@
"optional": true,
"os": [
"win32"
- ],
- "peer": true
+ ]
},
"node_modules/@rspack/core": {
"version": "1.7.12",
"resolved": "https://registry.npmjs.org/@rspack/core/-/core-1.7.12.tgz",
"integrity": "sha512-6CwFIHlhRmXfZoMj3v9MZ1SMTPBn+cHVXeMIeaGp5sufqinKsISbsqHu6ZMJu2wDSmZLdmQJX6zLxkhcAUlhkQ==",
"license": "MIT",
- "optional": true,
- "peer": true,
"dependencies": {
"@module-federation/runtime-tools": "0.22.0",
"@rspack/binding": "1.7.12",
@@ -5257,9 +5226,7 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@rspack/lite-tapable/-/lite-tapable-1.1.0.tgz",
"integrity": "sha512-E2B0JhYFmVAwdDiG14+DW0Di4Ze4Jg10Pc4/lILUrd5DRCaklduz2OvJ5HYQ6G+hd+WTzqQb3QnDNfK4yvAFYw==",
- "license": "MIT",
- "optional": true,
- "peer": true
+ "license": "MIT"
},
"node_modules/@sideway/address": {
"version": "4.1.5",
@@ -5574,8 +5541,6 @@
"integrity": "sha512-95I4kiSMeveI/Mhi+tE4fiWcWLUMfzfKrk0jtr8LRMqHgOgq+xHS+zExkDqoO4b5OeeuXHMWVdD5MeP3X6sULw==",
"hasInstallScript": true,
"license": "Apache-2.0",
- "optional": true,
- "peer": true,
"dependencies": {
"@swc/counter": "^0.1.3",
"@swc/types": "^0.1.28"
@@ -5622,7 +5587,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5639,7 +5603,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5656,7 +5619,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5673,7 +5635,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5690,7 +5651,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5707,7 +5667,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5724,7 +5683,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5741,7 +5699,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5758,7 +5715,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5775,7 +5731,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5792,7 +5747,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5809,7 +5763,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5818,17 +5771,13 @@
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz",
"integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==",
- "license": "Apache-2.0",
- "optional": true,
- "peer": true
+ "license": "Apache-2.0"
},
"node_modules/@swc/html": {
"version": "1.16.2",
"resolved": "https://registry.npmjs.org/@swc/html/-/html-1.16.2.tgz",
"integrity": "sha512-RmWH8m5dePWDFpHpmFKquZCRe5SyD/Sb0FBPxWcWv/tsjtlJl6oHeaxBsTL2edvaHuW385Fy5nPuTjDD/a+GEA==",
"license": "Apache-2.0",
- "optional": true,
- "peer": true,
"dependencies": {
"@swc/counter": "^0.1.3"
},
@@ -5862,7 +5811,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5879,7 +5827,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5896,7 +5843,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5913,7 +5859,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5930,7 +5875,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5947,7 +5891,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5964,7 +5907,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5981,7 +5923,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -5998,7 +5939,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -6015,7 +5955,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -6032,7 +5971,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -6049,7 +5987,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=10"
}
@@ -6059,8 +5996,6 @@
"resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.28.tgz",
"integrity": "sha512-V6Mnml8v09QALx6K0elJ7o9K/MkVDtW3t6L+7Ou/JcWtb3xwId2AH4FeOceySd2JaO87IMw4+6vSZxLm34LPbw==",
"license": "Apache-2.0",
- "optional": true,
- "peer": true,
"dependencies": {
"@swc/counter": "^0.1.3"
}
@@ -6083,7 +6018,6 @@
"integrity": "sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==",
"license": "MIT",
"optional": true,
- "peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
@@ -8699,8 +8633,6 @@
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
"license": "Apache-2.0",
- "optional": true,
- "peer": true,
"engines": {
"node": ">=8"
}
@@ -11275,8 +11207,6 @@
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
"integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
"license": "MPL-2.0",
- "optional": true,
- "peer": true,
"dependencies": {
"detect-libc": "^2.0.3"
},
@@ -11313,7 +11243,6 @@
"os": [
"android"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11334,7 +11263,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11355,7 +11283,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11376,7 +11303,6 @@
"os": [
"freebsd"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11397,7 +11323,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11418,7 +11343,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11439,7 +11363,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11460,7 +11383,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11481,7 +11403,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11502,7 +11423,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -11523,7 +11443,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -18152,8 +18071,6 @@
"resolved": "https://registry.npmjs.org/swc-loader/-/swc-loader-0.2.7.tgz",
"integrity": "sha512-nwYWw3Fh9ame3Rtm7StS9SBLpHRRnYcK7bnpF3UKZmesAK0gw2/ADvlURFAINmPvKtDLzp+GBiP9yLoEjg6S9w==",
"license": "MIT",
- "optional": true,
- "peer": true,
"dependencies": {
"@swc/counter": "^0.1.3"
},
diff --git a/website/package.json b/website/package.json
index fc971a115..454aca615 100644
--- a/website/package.json
+++ b/website/package.json
@@ -14,6 +14,7 @@
},
"dependencies": {
"@docusaurus/core": "~3.10.1",
+ "@docusaurus/faster": "~3.10.1",
"@docusaurus/preset-classic": "~3.10.1",
"@docusaurus/theme-common": "~3.10.1",
"@docusaurus/utils": "~3.10.1",