From 0f29a37b3a6d3ee48ce21c69ddc7a9b8b5ff2165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Tue, 24 Dec 2024 14:43:03 +0100 Subject: [PATCH] feat: Add React 19 support to Docusaurus v3 (#10763) --- .cspell.json | 1 + .github/workflows/lint.yml | 2 +- .github/workflows/tests.yml | 2 +- admin/scripts/test-release.sh | 7 +++-- admin/test-bad-package/README.mdx | 2 +- argos/tests/screenshot.spec.ts | 11 +++++-- package.json | 1 - .../templates/classic-typescript/package.json | 4 +-- .../templates/classic/package.json | 4 +-- packages/docusaurus-mdx-loader/package.json | 4 +-- .../package.json | 2 +- .../package.json | 4 +-- .../package.json | 4 +-- .../package.json | 4 +-- .../package.json | 4 +-- packages/docusaurus-plugin-debug/package.json | 4 +-- .../package.json | 4 +-- .../package.json | 4 +-- .../package.json | 4 +-- .../package.json | 6 ++-- packages/docusaurus-plugin-pwa/package.json | 4 +-- .../docusaurus-plugin-rsdoctor/package.json | 4 +-- .../docusaurus-plugin-sitemap/package.json | 4 +-- packages/docusaurus-plugin-svgr/package.json | 4 +-- .../package.json | 4 +-- .../docusaurus-preset-classic/package.json | 4 +-- .../docusaurus-theme-classic/package.json | 4 +-- packages/docusaurus-theme-common/package.json | 4 +-- .../package.json | 4 +-- .../docusaurus-theme-mermaid/package.json | 4 +-- .../package.json | 4 +-- packages/docusaurus-types/package.json | 6 ++-- packages/docusaurus/package.json | 6 ++-- packages/docusaurus/src/webpack/base.ts | 23 ++++++++------ project-words.txt | 4 --- website/package.json | 4 +-- yarn.lock | 31 ++++++++++++++----- 37 files changed, 111 insertions(+), 85 deletions(-) diff --git a/.cspell.json b/.cspell.json index 82ebc2c41a41..16dc7c67c9cf 100644 --- a/.cspell.json +++ b/.cspell.json @@ -26,6 +26,7 @@ "yarn.lock", "project-words.txt", "__snapshots__", + "admin/scripts", "website/src/data/users.tsx", "website/src/data/tweets.tsx", "website/docusaurus.config.localized.json", diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 63929dc49af5..893b76caba99 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,7 +33,7 @@ jobs: - name: Check for suspicious yarn.lock # for allowed aliases, see https://github.com/yargs/cliui/pull/139/files#r1670711112 - run: yarn lockfile-lint --path yarn.lock --type yarn --allowed-hosts yarn --validate-https --validate-package-names --validate-integrity --empty-hostname=false --allowed-package-name-aliases react-loadable string-width-cjs strip-ansi-cjs wrap-ansi-cjs + run: yarn lockfile-lint --path yarn.lock --type yarn --allowed-hosts yarn --validate-https --validate-package-names --validate-integrity --empty-hostname=false --allowed-package-name-aliases react-loadable react-helmet-async string-width-cjs strip-ansi-cjs wrap-ansi-cjs - name: Lint run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 41ad5ddc127a..3bb0c22bcb59 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,7 +49,7 @@ jobs: env: # Our website should build even with limited memory # See https://github.com/facebook/docusaurus/pull/10590 - NODE_OPTIONS: '--max-old-space-size=400' + NODE_OPTIONS: '--max-old-space-size=450' DOCUSAURUS_PERF_LOGGER: 'true' - name: Docusaurus site CSS order run: yarn workspace website test:css-order diff --git a/admin/scripts/test-release.sh b/admin/scripts/test-release.sh index 622c524c95fa..0ae82234a5ba 100755 --- a/admin/scripts/test-release.sh +++ b/admin/scripts/test-release.sh @@ -5,7 +5,9 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -set -euo pipefail +set -xeuo pipefail + +rm -rf ../test-website CUSTOM_REGISTRY_URL="http://localhost:4873" NEW_VERSION="$(node -p "require('./packages/docusaurus/package.json').version")-NEW" @@ -52,7 +54,8 @@ git diff --name-only -- '*.json' | sed 's, ,\\&,g' | xargs git checkout -- cd .. # Build skeleton website with new version -npm_config_registry="$CUSTOM_REGISTRY_URL" npx create-docusaurus@"$NEW_VERSION" test-website classic --javascript $EXTRA_OPTS +npm_config_registry="$CUSTOM_REGISTRY_URL" npx --yes --loglevel silly create-docusaurus@"$NEW_VERSION" test-website classic --javascript $EXTRA_OPTS + # Stop Docker container if [[ -z "${KEEP_CONTAINER:-true}" ]] && ( $(docker container inspect "$CONTAINER_NAME" > /dev/null 2>&1) ); then diff --git a/admin/test-bad-package/README.mdx b/admin/test-bad-package/README.mdx index 40abc5448c2b..260522db2417 100644 --- a/admin/test-bad-package/README.mdx +++ b/admin/test-bad-package/README.mdx @@ -12,7 +12,7 @@ import {version as ReactVersion} from 'react'; import {version as ReactDOMVersion} from 'react-dom'; export function TestComponent() { - const expectedVersion = 18; + const expectedVersion = 19; if (!ReactVersion.startsWith(`${expectedVersion}`)) { throw new Error( `'test-bad-package/README.mdx' is rendered with bad React version: ${ReactVersion}`, diff --git a/argos/tests/screenshot.spec.ts b/argos/tests/screenshot.spec.ts index a648b8256892..8d4d06562e1e 100644 --- a/argos/tests/screenshot.spec.ts +++ b/argos/tests/screenshot.spec.ts @@ -135,9 +135,14 @@ function throwOnConsole(page: Page) { // it's already happening in main branch 'Failed to load resource: the server responded with a status of 404 (Not Found)', - // TODO looks like legit hydration bugs to fix - 'Warning: Prop `%s` did not match. Server: %s Client: %s%s href "/docs/configuration" "/docs/configuration?docusaurus-theme=light"', - 'Warning: Prop `%s` did not match. Server: %s Client: %s%s href "/docs/configuration" "/docs/configuration?docusaurus-theme=dark"', + // TODO legit hydration bugs to fix on embeds of /docs/styling-layout + // useLocation() returns window.search/hash immediately :s + '/docs/configuration?docusaurus-theme=light', + '/docs/configuration?docusaurus-theme=dark', + + // Warning because react-live not supporting React automatic JSX runtime + // See https://github.com/FormidableLabs/react-live/issues/405 + 'Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance', // TODO weird problem related to KaTeX fonts refusing to decode? // on /docs/markdown-features/math-equations diff --git a/package.json b/package.json index aecf0f4b3652..ea1294c3c61c 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,6 @@ "prettier": "^2.8.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-helmet-async": "^1.3.0", "react-test-renderer": "^18.0.0", "rimraf": "^3.0.2", "sharp": "^0.32.3", diff --git a/packages/create-docusaurus/templates/classic-typescript/package.json b/packages/create-docusaurus/templates/classic-typescript/package.json index 5cbb27904f86..168d0e39cbdd 100644 --- a/packages/create-docusaurus/templates/classic-typescript/package.json +++ b/packages/create-docusaurus/templates/classic-typescript/package.json @@ -20,8 +20,8 @@ "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", "prism-react-renderer": "^2.3.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^19.0.0", + "react-dom": "^19.0.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.6.3", diff --git a/packages/create-docusaurus/templates/classic/package.json b/packages/create-docusaurus/templates/classic/package.json index aa0709133bc7..338f15974023 100644 --- a/packages/create-docusaurus/templates/classic/package.json +++ b/packages/create-docusaurus/templates/classic/package.json @@ -19,8 +19,8 @@ "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", "prism-react-renderer": "^2.3.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^19.0.0", + "react-dom": "^19.0.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.6.3", diff --git a/packages/docusaurus-mdx-loader/package.json b/packages/docusaurus-mdx-loader/package.json index 69546431d9d4..b37788b9f3e8 100644 --- a/packages/docusaurus-mdx-loader/package.json +++ b/packages/docusaurus-mdx-loader/package.json @@ -58,8 +58,8 @@ "unist-util-remove-position": "^5.0.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-module-type-aliases/package.json b/packages/docusaurus-module-type-aliases/package.json index a7ba21f20ea4..a5e4a28ad3b1 100644 --- a/packages/docusaurus-module-type-aliases/package.json +++ b/packages/docusaurus-module-type-aliases/package.json @@ -17,7 +17,7 @@ "@types/react": "*", "@types/react-router-config": "*", "@types/react-router-dom": "*", - "react-helmet-async": "*", + "react-helmet-async": "npm:@slorber/react-helmet-async@*", "react-loadable": "npm:@docusaurus/react-loadable@6.0.0" }, "peerDependencies": { diff --git a/packages/docusaurus-plugin-client-redirects/package.json b/packages/docusaurus-plugin-client-redirects/package.json index 7473f9b78c44..1e116f3d26f8 100644 --- a/packages/docusaurus-plugin-client-redirects/package.json +++ b/packages/docusaurus-plugin-client-redirects/package.json @@ -32,8 +32,8 @@ "@docusaurus/types": "3.6.3" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-content-blog/package.json b/packages/docusaurus-plugin-content-blog/package.json index 4ed76c8e4733..4f94e88dd6d6 100644 --- a/packages/docusaurus-plugin-content-blog/package.json +++ b/packages/docusaurus-plugin-content-blog/package.json @@ -52,8 +52,8 @@ }, "peerDependencies": { "@docusaurus/plugin-content-docs": "*", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index b0d964444f84..8c8d610b6bff 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -61,8 +61,8 @@ "shelljs": "^0.8.5" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-content-pages/package.json b/packages/docusaurus-plugin-content-pages/package.json index f8efc0331d73..1cf0d8c3701c 100644 --- a/packages/docusaurus-plugin-content-pages/package.json +++ b/packages/docusaurus-plugin-content-pages/package.json @@ -28,8 +28,8 @@ "webpack": "^5.88.1" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-debug/package.json b/packages/docusaurus-plugin-debug/package.json index 40c84b146811..fa6ab6bfad5e 100644 --- a/packages/docusaurus-plugin-debug/package.json +++ b/packages/docusaurus-plugin-debug/package.json @@ -28,8 +28,8 @@ "tslib": "^2.6.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-google-analytics/package.json b/packages/docusaurus-plugin-google-analytics/package.json index 5b90e5a123f1..95d99d074172 100644 --- a/packages/docusaurus-plugin-google-analytics/package.json +++ b/packages/docusaurus-plugin-google-analytics/package.json @@ -24,8 +24,8 @@ "tslib": "^2.6.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-google-gtag/package.json b/packages/docusaurus-plugin-google-gtag/package.json index 84e2752be3df..5a0525a6d682 100644 --- a/packages/docusaurus-plugin-google-gtag/package.json +++ b/packages/docusaurus-plugin-google-gtag/package.json @@ -25,8 +25,8 @@ "tslib": "^2.6.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-google-tag-manager/package.json b/packages/docusaurus-plugin-google-tag-manager/package.json index 2faaa9e043bf..a85a61c1208b 100644 --- a/packages/docusaurus-plugin-google-tag-manager/package.json +++ b/packages/docusaurus-plugin-google-tag-manager/package.json @@ -24,8 +24,8 @@ "tslib": "^2.6.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-ideal-image/package.json b/packages/docusaurus-plugin-ideal-image/package.json index 94ae2d1ed34e..bdb15d7cb8db 100644 --- a/packages/docusaurus-plugin-ideal-image/package.json +++ b/packages/docusaurus-plugin-ideal-image/package.json @@ -26,7 +26,7 @@ "@docusaurus/theme-translations": "3.6.3", "@docusaurus/types": "3.6.3", "@docusaurus/utils-validation": "3.6.3", - "@slorber/react-ideal-image": "^0.0.12", + "@slorber/react-ideal-image": "^0.0.14", "react-waypoint": "^10.3.0", "sharp": "^0.32.3", "tslib": "^2.6.0", @@ -38,8 +38,8 @@ }, "peerDependencies": { "jimp": "*", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "peerDependenciesMeta": { "jimp": { diff --git a/packages/docusaurus-plugin-pwa/package.json b/packages/docusaurus-plugin-pwa/package.json index 3a8a68f487b0..a109235a3d63 100644 --- a/packages/docusaurus-plugin-pwa/package.json +++ b/packages/docusaurus-plugin-pwa/package.json @@ -45,8 +45,8 @@ "fs-extra": "^11.1.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-rsdoctor/package.json b/packages/docusaurus-plugin-rsdoctor/package.json index 7b5f5e6073bd..6cba70524d48 100644 --- a/packages/docusaurus-plugin-rsdoctor/package.json +++ b/packages/docusaurus-plugin-rsdoctor/package.json @@ -26,8 +26,8 @@ "tslib": "^2.6.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-sitemap/package.json b/packages/docusaurus-plugin-sitemap/package.json index 9cea0a4b00db..d86a4a5f0eb1 100644 --- a/packages/docusaurus-plugin-sitemap/package.json +++ b/packages/docusaurus-plugin-sitemap/package.json @@ -32,8 +32,8 @@ "@total-typescript/shoehorn": "^0.1.2" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-svgr/package.json b/packages/docusaurus-plugin-svgr/package.json index c4af737e688f..a5d9f338d9b8 100644 --- a/packages/docusaurus-plugin-svgr/package.json +++ b/packages/docusaurus-plugin-svgr/package.json @@ -28,8 +28,8 @@ "webpack": "^5.88.1" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-plugin-vercel-analytics/package.json b/packages/docusaurus-plugin-vercel-analytics/package.json index 65c6e85387f0..f00a94d2a1bd 100644 --- a/packages/docusaurus-plugin-vercel-analytics/package.json +++ b/packages/docusaurus-plugin-vercel-analytics/package.json @@ -27,8 +27,8 @@ "tslib": "^2.6.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-preset-classic/package.json b/packages/docusaurus-preset-classic/package.json index 77736348bcfe..c2fa7d3212d6 100644 --- a/packages/docusaurus-preset-classic/package.json +++ b/packages/docusaurus-preset-classic/package.json @@ -34,8 +34,8 @@ "@docusaurus/types": "3.6.3" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-theme-classic/package.json b/packages/docusaurus-theme-classic/package.json index 849448cbcadf..9cf89e9be21e 100644 --- a/packages/docusaurus-theme-classic/package.json +++ b/packages/docusaurus-theme-classic/package.json @@ -56,8 +56,8 @@ "utility-types": "^3.10.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-theme-common/package.json b/packages/docusaurus-theme-common/package.json index 6bff8d544502..725f0d71012b 100644 --- a/packages/docusaurus-theme-common/package.json +++ b/packages/docusaurus-theme-common/package.json @@ -52,8 +52,8 @@ }, "peerDependencies": { "@docusaurus/plugin-content-docs": "*", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-theme-live-codeblock/package.json b/packages/docusaurus-theme-live-codeblock/package.json index adb317c148a2..80f7ecc2c70b 100644 --- a/packages/docusaurus-theme-live-codeblock/package.json +++ b/packages/docusaurus-theme-live-codeblock/package.json @@ -38,8 +38,8 @@ "@types/buble": "^0.20.1" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-theme-mermaid/package.json b/packages/docusaurus-theme-mermaid/package.json index 5904a63b25c5..efe14004b8af 100644 --- a/packages/docusaurus-theme-mermaid/package.json +++ b/packages/docusaurus-theme-mermaid/package.json @@ -45,8 +45,8 @@ "react-test-renderer": "^18.0.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-theme-search-algolia/package.json b/packages/docusaurus-theme-search-algolia/package.json index 7736e766e356..412e7d2a3fc6 100644 --- a/packages/docusaurus-theme-search-algolia/package.json +++ b/packages/docusaurus-theme-search-algolia/package.json @@ -54,8 +54,8 @@ "@docusaurus/module-type-aliases": "3.6.3" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus-types/package.json b/packages/docusaurus-types/package.json index d54d448916b3..4a5e06dfd95a 100644 --- a/packages/docusaurus-types/package.json +++ b/packages/docusaurus-types/package.json @@ -18,13 +18,13 @@ "@types/react": "*", "commander": "^5.1.0", "joi": "^17.9.2", - "react-helmet-async": "^1.3.0", + "react-helmet-async": "npm:@slorber/react-helmet-async@1.3.0", "utility-types": "^3.10.0", "webpack": "^5.95.0", "webpack-merge": "^5.9.0" }, "peerDependencies": { - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" } } diff --git a/packages/docusaurus/package.json b/packages/docusaurus/package.json index 6ec765a2e816..12667cd6f31e 100644 --- a/packages/docusaurus/package.json +++ b/packages/docusaurus/package.json @@ -60,7 +60,7 @@ "p-map": "^4.0.0", "prompts": "^2.4.2", "react-dev-utils": "^12.0.1", - "react-helmet-async": "^1.3.0", + "react-helmet-async": "npm:@slorber/react-helmet-async@1.3.0", "react-loadable": "npm:@docusaurus/react-loadable@6.0.0", "react-loadable-ssr-addon-v5-slorber": "^1.0.1", "react-router": "^5.3.4", @@ -94,8 +94,8 @@ }, "peerDependencies": { "@mdx-js/react": "^3.0.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "engines": { "node": ">=18.0" diff --git a/packages/docusaurus/src/webpack/base.ts b/packages/docusaurus/src/webpack/base.ts index 3ffda658fedd..4dce834d9075 100644 --- a/packages/docusaurus/src/webpack/base.ts +++ b/packages/docusaurus/src/webpack/base.ts @@ -35,14 +35,19 @@ const LibrariesToTranspileRegex = new RegExp( LibrariesToTranspile.map((libName) => `(node_modules/${libName})`).join('|'), ); -const ReactAliases: Record = process.env - .DOCUSAURUS_NO_REACT_ALIASES - ? {} - : { - react: path.dirname(require.resolve('react/package.json')), - 'react-dom': path.dirname(require.resolve('react-dom/package.json')), - '@mdx-js/react': path.dirname(require.resolve('@mdx-js/react')), - }; +function getReactAliases(siteDir: string): Record { + // Escape hatch + if (process.env.DOCUSAURUS_NO_REACT_ALIASES) { + return {}; + } + const resolveSitePkg = (id: string) => + require.resolve(id, {paths: [siteDir]}); + return { + react: path.dirname(resolveSitePkg('react/package.json')), + 'react-dom': path.dirname(resolveSitePkg('react-dom/package.json')), + '@mdx-js/react': path.dirname(resolveSitePkg('@mdx-js/react')), + }; +} export function excludeJS(modulePath: string): boolean { // Always transpile client dir @@ -186,7 +191,7 @@ export async function createBaseConfig({ process.cwd(), ], alias: { - ...ReactAliases, + ...getReactAliases(siteDir), '@site': siteDir, '@generated': generatedFilesDir, ...(await loadDocusaurusAliases()), diff --git a/project-words.txt b/project-words.txt index 9cef579226d0..a0f0822f61f0 100644 --- a/project-words.txt +++ b/project-words.txt @@ -91,7 +91,6 @@ Flightcontrol Flightcontrol's FOUC froms -funboxteam gabrielcsapo getcanary Gifs @@ -202,7 +201,6 @@ Nuxt opensearch opensearchdescription opensource -optimizt orama Orama orta @@ -283,7 +281,6 @@ Sebastien Sébastien sebastienlorber sensical -setaf setext setlocal SFNT @@ -299,7 +296,6 @@ solana Solana spâce stackblitz -stackblitzrc stackoverflow Stormkit Strikethrough diff --git a/website/package.json b/website/package.json index 64e001950322..933820842886 100644 --- a/website/package.json +++ b/website/package.json @@ -57,8 +57,8 @@ "fs-extra": "^11.1.1", "netlify-plugin-cache": "^1.0.3", "raw-loader": "^4.0.2", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "^19.0.0", + "react-dom": "^19.0.0", "react-lite-youtube-embed": "^2.3.52", "react-medium-image-zoom": "^5.1.6", "recma-mdx-displayname": "^0.4.1", diff --git a/yarn.lock b/yarn.lock index 98bfb6fffcf0..24a7352f64a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3352,10 +3352,10 @@ dependencies: "@sinonjs/commons" "^3.0.0" -"@slorber/react-ideal-image@^0.0.12": - version "0.0.12" - resolved "https://registry.yarnpkg.com/@slorber/react-ideal-image/-/react-ideal-image-0.0.12.tgz#5f867f9e10f2d82456568e8fd5bfb7673089c29c" - integrity sha512-u8KiDTEkMA7/KAeA5ywg/P7YG4zuKhWtswfVZDH8R8HXgQsFcHIYU2WaQnGuK/Du7Wdj90I+SdFmajSGFRvoKA== +"@slorber/react-ideal-image@^0.0.14": + version "0.0.14" + resolved "https://registry.yarnpkg.com/@slorber/react-ideal-image/-/react-ideal-image-0.0.14.tgz#35b0756c6f06ec60c4a2b5cae9dcf346500e1e8a" + integrity sha512-ULJ1VtNg+B5puJp4ZQzEnDqYyDT9erbABoQygmAovg35ltOymLMH8jXPuxJQBVskcmaG29bTZ+++hE/PAXRgxA== "@slorber/remark-comment@^1.0.0": version "1.0.0" @@ -15078,6 +15078,13 @@ react-dom@^18.0.0: loose-envify "^1.1.0" scheduler "^0.23.2" +react-dom@^19.0.0: + version "19.0.0" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-19.0.0.tgz#43446f1f01c65a4cd7f7588083e686a6726cfb57" + integrity sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ== + dependencies: + scheduler "^0.25.0" + react-error-boundary@^3.1.0: version "3.1.4" resolved "https://registry.yarnpkg.com/react-error-boundary/-/react-error-boundary-3.1.4.tgz#255db92b23197108757a888b01e5b729919abde0" @@ -15095,10 +15102,10 @@ react-fast-compare@^3.2.0: resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.2.tgz#929a97a532304ce9fee4bcae44234f1ce2c21d49" integrity sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ== -react-helmet-async@*, react-helmet-async@^1.3.0: +"react-helmet-async@npm:@slorber/react-helmet-async@*", "react-helmet-async@npm:@slorber/react-helmet-async@1.3.0": version "1.3.0" - resolved "https://registry.yarnpkg.com/react-helmet-async/-/react-helmet-async-1.3.0.tgz#7bd5bf8c5c69ea9f02f6083f14ce33ef545c222e" - integrity sha512-9jZ57/dAn9t3q6hneQS0wukqC2ENOBgMNVEhb/ZG9ZSxUetzVIw4iAmEU38IaVg3QGYauQPhSeUTuIUtFglWpg== + resolved "https://registry.yarnpkg.com/@slorber/react-helmet-async/-/react-helmet-async-1.3.0.tgz#11fbc6094605cf60aa04a28c17e0aab894b4ecff" + integrity sha512-e9/OK8VhwUSc67diWI8Rb3I0YgI9/SBQtnhe9aEuK6MhZm7ntZZimXgwXnd8W96YTmSOb9M4d8LwhRZyhWr/1A== dependencies: "@babel/runtime" "^7.12.5" invariant "^2.2.4" @@ -15232,6 +15239,11 @@ react@^18.0.0: dependencies: loose-envify "^1.1.0" +react@^19.0.0: + version "19.0.0" + resolved "https://registry.yarnpkg.com/react/-/react-19.0.0.tgz#6e1969251b9f108870aa4bff37a0ce9ddfaaabdd" + integrity sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ== + read-cmd-shim@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-3.0.0.tgz#62b8c638225c61e6cc607f8f4b779f3b8238f155" @@ -15994,6 +16006,11 @@ scheduler@^0.23.2: dependencies: loose-envify "^1.1.0" +scheduler@^0.25.0: + version "0.25.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.25.0.tgz#336cd9768e8cceebf52d3c80e3dcf5de23e7e015" + integrity sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA== + schema-dts@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/schema-dts/-/schema-dts-1.1.2.tgz#82ccf71b5dcb80065a1cc5941888507a4ce1e44b"