Skip to content

Commit 93a9244

Browse files
authored
chore: update docusaurus to 3.8.0 (zitadel#9974)
> [!IMPORTANT] > We need to change the ENV `VERCEL_FORCE_NO_BUILD_CACHE` to `0` which is currently `1` to enable the cache on all deployments This pull request includes several updates to the documentation and benchmarking components, focusing on improving performance, error handling, and compatibility with newer versions of Docusaurus. The key changes include the removal of outdated configurations, updates to dependencies, and enhancements to the `BenchmarkChart` component for better error handling and data validation. ### Documentation and Configuration Updates: * **Removed outdated Babel and Webpack configurations**: The `babel.config.js` file was deleted, and the Webpack configuration was removed from `docusaurus.config.js` to align with the latest Docusaurus setup. [[1]](diffhunk://#diff-2ed4f5b03d34a87ef641e9e36af4a98a1c0ddaf74d07ce93665957be69b7b09aL1-L4) [[2]](diffhunk://#diff-28742c737e523f302e6de471b7fc27284dc8cf720be639e6afe4c17a550cd654L204-L225) * **Added experimental features in Docusaurus**: Introduced a `future` section in `docusaurus.config.js` to enable experimental features like `swcJsLoader`, `rspackBundler`, and `lightningCssMinimizer`, while disabling problematic settings due to known issues. ### Dependency Updates: * **Upgraded Docusaurus and related packages**: Updated dependencies in `package.json` to use Docusaurus version `^3.8.0` and newer versions of associated plugins and themes for improved performance and compatibility. [[1]](diffhunk://#diff-adfa337ce44dc2902621da20152a048dac41878cf3716dfc4cc56d03aa212a56L25-R39) [[2]](diffhunk://#diff-adfa337ce44dc2902621da20152a048dac41878cf3716dfc4cc56d03aa212a56L66-R67) ### Component Enhancements: * **Improved `BenchmarkChart` error handling**: Refactored the `BenchmarkChart` component to validate input data, handle errors gracefully, and provide meaningful fallback messages when data is missing or invalid. [[1]](diffhunk://#diff-ce9fccf51f6b863dd58a39f361a9cf980b10357bccc7381f928788483b30cb0eL4-R21) [[2]](diffhunk://#diff-ce9fccf51f6b863dd58a39f361a9cf980b10357bccc7381f928788483b30cb0eR72-R76) * **Fixed edge cases in chart rendering**: Addressed issues like invalid timestamps, undefined `p99` values, and empty data sets to ensure robust chart generation. [[1]](diffhunk://#diff-ce9fccf51f6b863dd58a39f361a9cf980b10357bccc7381f928788483b30cb0eL19-L29) [[2]](diffhunk://#diff-ce9fccf51f6b863dd58a39f361a9cf980b10357bccc7381f928788483b30cb0eL38-R61) ### Documentation Benchmark Updates: * **Simplified imports in benchmark files**: Replaced the use of `raw-loader` with direct imports for benchmark data in multiple `.mdx` files to streamline the documentation setup. [[1]](diffhunk://#diff-a9710709396e5ff6756aedf89dfcbd62aeea15368ba33bf3932ebf33046a29e8L66-R66) [[2]](diffhunk://#diff-0a9b6103c97c58792450bfd2d337bbb8a6b72df2ae326cc56ebc96e01c0acd6bL35-R35) [[3]](diffhunk://#diff-38f45388e065c57f1282a43bb319354da3c218e96d95ca20f4d11709f48491b8L36-R36) [[4]](diffhunk://#diff-b8e792ebe42fcb16a493e35d23b58a91c2117d949953487e70f379c64e5cb7c0L36-R36) [[5]](diffhunk://#diff-3778acfa893504004008b162fa95f21f1c7c40dcf1868bbbaaa504ac5d51901aL38-R38)
1 parent 5e87faf commit 93a9244

File tree

10 files changed

+3837
-1657
lines changed

10 files changed

+3837
-1657
lines changed

docs/babel.config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/docs/apis/benchmarks/_template.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ TODO: describe the outcome of the test?
6363

6464
## Endpoint latencies
6565

66-
import OutputSource from "!!raw-loader!./output.json";
66+
import OutputSource from "./output.json";
6767

6868
import { BenchmarkChart } from '/src/components/benchmark_chart';
6969

docs/docs/apis/benchmarks/v2.65.0/machine_jwt_profile_grant/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Tests are halted after this test run because of too many [client read events](ht
3232

3333
## /token endpoint latencies
3434

35-
import OutputSource from "!!raw-loader!./output.json";
35+
import OutputSource from "./output.json";
3636

3737
import { BenchmarkChart } from '/src/components/benchmark_chart';
3838

docs/docs/apis/benchmarks/v2.66.0/machine_jwt_profile_grant/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The tests showed heavy database load by time by the first two database queries.
3333

3434
## Endpoint latencies
3535

36-
import OutputSource from "!!raw-loader!./output.json";
36+
import OutputSource from "./output.json";
3737

3838
import { BenchmarkChart } from '/src/components/benchmark_chart';
3939

docs/docs/apis/benchmarks/v2.70.0/machine_jwt_profile_grant/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The performance goals of [this issue](https://github.com/zitadel/zitadel/issues/
3333

3434
## Endpoint latencies
3535

36-
import OutputSource from "!!raw-loader!./output.json";
36+
import OutputSource from "./output.json";
3737

3838
import { BenchmarkChart } from '/src/components/benchmark_chart';
3939

docs/docs/apis/benchmarks/v2.70.0/oidc_session/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The tests showed that querying the user takes too much time because Zitadel ensu
3535

3636
## Endpoint latencies
3737

38-
import OutputSource from "!!raw-loader!./output.json";
38+
import OutputSource from "./output.json";
3939

4040
import { BenchmarkChart } from '/src/components/benchmark_chart';
4141

docs/docusaurus.config.js

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -201,28 +201,6 @@ module.exports = {
201201
runmeLinkLabel: 'Checkout via Runme'
202202
},
203203
},
204-
webpack: {
205-
jsLoader: (isServer) => ({
206-
loader: require.resolve('swc-loader'),
207-
options: {
208-
jsc: {
209-
parser: {
210-
syntax: 'typescript',
211-
tsx: true,
212-
},
213-
transform: {
214-
react: {
215-
runtime: 'automatic',
216-
},
217-
},
218-
target: 'es2017',
219-
},
220-
module: {
221-
type: isServer ? 'commonjs' : 'es6',
222-
},
223-
},
224-
}),
225-
},
226204
presets: [
227205
[
228206
"classic",
@@ -397,4 +375,17 @@ module.exports = {
397375
},
398376
],
399377
themes: [ "docusaurus-theme-github-codeblock", "docusaurus-theme-openapi-docs"],
378+
future: {
379+
v4: false, // Disabled because of some problems related to https://github.com/facebook/docusaurus/issues/11040
380+
experimental_faster: {
381+
swcJsLoader: false, // Disabled because of memory usage > 8GB which is a problem on vercel default runners
382+
swcJsMinimizer: true,
383+
swcHtmlMinimizer : true,
384+
lightningCssMinimizer: true,
385+
mdxCrossCompilerCache: true,
386+
ssgWorkerThreads: false, // Disabled because of some problems related to https://github.com/facebook/docusaurus/issues/11040
387+
rspackBundler: true,
388+
rspackPersistentCache: true,
389+
},
390+
},
400391
};

docs/package.json

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"docusaurus": "docusaurus",
77
"start": "docusaurus start",
88
"start:api": "yarn run generate && docusaurus start",
9-
"build": "yarn run generate && NODE_OPTIONS=--max-old-space-size=8192 docusaurus build",
9+
"build": "yarn run generate && docusaurus build",
1010
"swizzle": "docusaurus swizzle",
1111
"deploy": "docusaurus deploy",
1212
"clear": "docusaurus clear",
@@ -22,33 +22,27 @@
2222
},
2323
"dependencies": {
2424
"@bufbuild/buf": "^1.14.0",
25-
"@docusaurus/core": "3.4.0",
26-
"@docusaurus/preset-classic": "3.4.0",
27-
"@docusaurus/theme-mermaid": "3.4.0",
28-
"@docusaurus/theme-search-algolia": "3.4.0",
25+
"@docusaurus/core": "^3.8.0",
26+
"@docusaurus/faster": "^3.8.0",
27+
"@docusaurus/preset-classic": "^3.8.0",
28+
"@docusaurus/theme-mermaid": "^3.8.0",
29+
"@docusaurus/theme-search-algolia": "^3.8.0",
2930
"@headlessui/react": "^1.7.4",
3031
"@heroicons/react": "^2.0.13",
31-
"@mdx-js/react": "^3.0.0",
32-
"@swc/core": "^1.3.74",
3332
"autoprefixer": "^10.4.13",
3433
"clsx": "^1.2.1",
35-
"docusaurus-plugin-image-zoom": "^1.0.1",
36-
"docusaurus-plugin-openapi-docs": "3.0.1",
34+
"docusaurus-plugin-image-zoom": "^3.0.1",
35+
"docusaurus-plugin-openapi-docs": "4.4.0",
3736
"docusaurus-theme-github-codeblock": "^2.0.2",
38-
"docusaurus-theme-openapi-docs": "3.0.1",
37+
"docusaurus-theme-openapi-docs": "4.4.0",
3938
"mdx-mermaid": "^2.0.0",
40-
"mermaid": "^10.9.1",
4139
"postcss": "^8.4.31",
42-
"prism-react-renderer": "^2.1.0",
4340
"raw-loader": "^4.0.2",
4441
"react": "^18.2.0",
4542
"react-copy-to-clipboard": "^5.1.0",
4643
"react-dom": "^18.2.0",
4744
"react-google-charts": "^5.2.1",
48-
"react-player": "^2.15.1",
49-
"sitemap": "7.1.1",
50-
"swc-loader": "^0.2.3",
51-
"wait-on": "6.0.1"
45+
"react-player": "^2.15.1"
5246
},
5347
"browserslist": {
5448
"production": [
@@ -63,8 +57,8 @@
6357
]
6458
},
6559
"devDependencies": {
66-
"@docusaurus/module-type-aliases": "3.4.0",
67-
"@docusaurus/types": "3.4.0",
60+
"@docusaurus/module-type-aliases": "^3.8.0",
61+
"@docusaurus/types": "^3.8.0",
6862
"tailwindcss": "^3.2.4"
6963
},
7064
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import React from "react";
22
import Chart from "react-google-charts";
33

4-
export function BenchmarkChart(testResults=[], height='500px') {
4+
export function BenchmarkChart({ testResults = [], height = '500px' } = {}) {
5+
if (!Array.isArray(testResults)) {
6+
console.error("BenchmarkChart: testResults is not an array. Received:", testResults);
7+
return <p>Error: Benchmark data is not available or in the wrong format.</p>;
8+
}
9+
10+
if (testResults.length === 0) {
11+
return <p>No benchmark data to display.</p>;
12+
}
13+
514
const dataPerMetric = new Map();
615
let maxVValue = 0;
716

8-
JSON.parse(testResults.testResults).forEach((result) => {
17+
testResults.forEach((result) => {
18+
if (!result || typeof result.metric_name === 'undefined') {
19+
console.warn("BenchmarkChart: Skipping invalid result item:", result);
20+
return;
21+
}
922
if (!dataPerMetric.has(result.metric_name)) {
1023
dataPerMetric.set(result.metric_name, [
1124
[
@@ -16,17 +29,16 @@ export function BenchmarkChart(testResults=[], height='500px') {
1629
],
1730
]);
1831
}
19-
if (result.p99 > maxVValue) {
32+
if (result.p99 !== undefined && result.p99 > maxVValue) {
2033
maxVValue = result.p99;
2134
}
2235
dataPerMetric.get(result.metric_name).push([
23-
new Date(result.timestamp),
36+
result.timestamp ? new Date(result.timestamp) : null,
2437
result.p50,
2538
result.p95,
2639
result.p99,
2740
]);
2841
});
29-
3042
const options = {
3143
legend: { position: 'bottom' },
3244
focusTarget: 'category',
@@ -35,17 +47,18 @@ export function BenchmarkChart(testResults=[], height='500px') {
3547
},
3648
vAxis: {
3749
title: 'latency (ms)',
38-
maxValue: maxVValue,
50+
maxValue: maxVValue > 0 ? maxVValue : undefined,
3951
},
4052
title: ''
4153
};
4254
const charts = [];
4355

4456
dataPerMetric.forEach((data, metric) => {
45-
const opt = Object.create(options);
57+
const opt = { ...options };
4658
opt.title = metric;
4759
charts.push(
4860
<Chart
61+
key={metric}
4962
chartType="LineChart"
5063
width="100%"
5164
height={height}
@@ -56,6 +69,9 @@ export function BenchmarkChart(testResults=[], height='500px') {
5669
);
5770
});
5871

72+
if (charts.length === 0) {
73+
return <p>No chart data could be generated.</p>;
74+
}
5975

60-
return (charts);
76+
return <>{charts}</>;
6177
}

0 commit comments

Comments
 (0)