From 66b2863de2dd469124cc2680593e1f41b929e512 Mon Sep 17 00:00:00 2001 From: hardfist Date: Tue, 6 Aug 2024 19:46:36 +0800 Subject: [PATCH] chore: patch @docusaurus/core --- package.json | 3 +- patches/@docusaurus__core@3.4.0.patch | 154 ++++++++++++++++++++++++++ pnpm-lock.yaml | 30 ++--- 3 files changed, 173 insertions(+), 14 deletions(-) create mode 100644 patches/@docusaurus__core@3.4.0.patch diff --git a/package.json b/package.json index 1e293ce..393af9e 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,8 @@ "webpack": "npm:@rspack/core@1.0.0-beta.2" }, "patchedDependencies": { - "@docusaurus/theme-classic@3.4.0": "patches/@docusaurus__theme-classic@3.4.0.patch" + "@docusaurus/theme-classic@3.4.0": "patches/@docusaurus__theme-classic@3.4.0.patch", + "@docusaurus/core@3.4.0": "patches/@docusaurus__core@3.4.0.patch" } } } diff --git a/patches/@docusaurus__core@3.4.0.patch b/patches/@docusaurus__core@3.4.0.patch new file mode 100644 index 0000000..f54ec54 --- /dev/null +++ b/patches/@docusaurus__core@3.4.0.patch @@ -0,0 +1,154 @@ +diff --git a/lib/client/clientEntry.js b/lib/client/clientEntry.js +index f1acc1804b3d0a7b33d7591c2d53c7d75130ef12..966a8cec375d2fe2d4e3b29d9fcaf7c83183b99e 100644 +--- a/lib/client/clientEntry.js ++++ b/lib/client/clientEntry.js +@@ -4,6 +4,11 @@ + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ ++var process = { ++ env:{ ++ HYDRATE_CLIENT_ENTRY:false ++ } ++}; + import React, { startTransition } from 'react'; + import ReactDOM from 'react-dom/client'; + import { HelmetProvider } from 'react-helmet-async'; +diff --git a/lib/client/docusaurus.js b/lib/client/docusaurus.js +index 0f105f5ed17aac0b942e855230454b0e53730052..1e17ee8eb35cbbbc4cb38a062a73e6128c74e862 100644 +--- a/lib/client/docusaurus.js ++++ b/lib/client/docusaurus.js +@@ -34,16 +34,16 @@ const prefetch = (routePath) => { + const chunkNamesNeeded = matches.flatMap((match) => getChunkNamesToLoad(match.route.path)); + // Prefetch all webpack chunk assets file needed. + return Promise.all(chunkNamesNeeded.map((chunkName) => { +- // "__webpack_require__.gca" is injected by ChunkAssetPlugin. Pass it +- // the name of the chunk you want to load and it will return its URL. +- // eslint-disable-next-line camelcase +- const chunkAsset = __webpack_require__.gca(chunkName); +- // In some cases, webpack might decide to optimize further, leading to +- // the chunk assets being merged to another chunk. In this case, we can +- // safely filter it out and don't need to load it. +- if (chunkAsset && !chunkAsset.includes('undefined')) { +- return prefetchHelper(chunkAsset); +- } ++ // // "__webpack_require__.gca" is injected by ChunkAssetPlugin. Pass it ++ // // the name of the chunk you want to load and it will return its URL. ++ // // eslint-disable-next-line camelcase ++ // const chunkAsset = __webpack_require__.gca(chunkName); ++ // // In some cases, webpack might decide to optimize further, leading to ++ // // the chunk assets being merged to another chunk. In this case, we can ++ // // safely filter it out and don't need to load it. ++ // if (chunkAsset && !chunkAsset.includes('undefined')) { ++ // return prefetchHelper(chunkAsset); ++ // } + return Promise.resolve(); + })); + }; +diff --git a/lib/webpack/base.js b/lib/webpack/base.js +index db4f893ea45f9e694361c6452f035673f14605df..954eabdf98a8cb557d40c9aed23dd28b043f9b36 100644 +--- a/lib/webpack/base.js ++++ b/lib/webpack/base.js +@@ -10,11 +10,13 @@ exports.createBaseConfig = exports.excludeJS = exports.clientDir = void 0; + const tslib_1 = require("tslib"); + const fs_extra_1 = tslib_1.__importDefault(require("fs-extra")); + const path_1 = tslib_1.__importDefault(require("path")); +-const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin")); ++const mini_css_extract_plugin = require('webpack').CssExtractRspackPlugin; + const utils_1 = require("@docusaurus/utils"); + const utils_2 = require("./utils"); + const minification_1 = require("./minification"); + const aliases_1 = require("./aliases"); ++const webpack = require('webpack'); ++ + const CSS_REGEX = /\.css$/i; + const CSS_MODULE_REGEX = /\.module\.css$/i; + exports.clientDir = path_1.default.join(__dirname, '..', 'client'); +@@ -196,8 +198,11 @@ async function createBaseConfig({ props, isServer, minify, }) { + }, + ], + }, ++ experiments: { ++ css:false ++ }, + plugins: [ +- new mini_css_extract_plugin_1.default({ ++ new mini_css_extract_plugin({ + filename: isProd + ? 'assets/css/[name].[contenthash:8].css' + : '[name].css', +@@ -209,7 +214,8 @@ async function createBaseConfig({ props, isServer, minify, }) { + // for more reasoning + ignoreOrder: true, + }), +- ], ++ ++ ] + }; + } + exports.createBaseConfig = createBaseConfig; +diff --git a/lib/webpack/client.js b/lib/webpack/client.js +index ff364813e24f527a90ad82fa097ef6ccd873828f..96600a111afd235794124f051756b6076d0732bd 100644 +--- a/lib/webpack/client.js ++++ b/lib/webpack/client.js +@@ -32,17 +32,7 @@ async function createBaseClientConfig({ props, hydrate, minify, }) { + // https://twitter.com/wSokra/status/969679223278505985 + runtimeChunk: true, + }, +- plugins: [ +- new webpack_1.default.DefinePlugin({ +- 'process.env.HYDRATE_CLIENT_ENTRY': JSON.stringify(hydrate), +- }), +- new ChunkAssetPlugin_1.default(), +- // Show compilation progress bar and build time. +- new webpackbar_1.default({ +- name: 'Client', +- }), +- await (0, StaticDirectoriesCopyPlugin_1.createStaticDirectoriesCopyPlugin)({ props }), +- ], ++ + }); + } + // client config when running "docusaurus start" +@@ -73,6 +63,7 @@ async function createStartClientConfig({ props, minify, poll, }) { + preBodyTags, + postBodyTags, + }), ++ + ], + }); + return { clientConfig }; +diff --git a/lib/webpack/plugins/ChunkAssetPlugin.js b/lib/webpack/plugins/ChunkAssetPlugin.js +index 4d896e310afb2fb4be10e703b2e734b0ea461cb3..940b924eb566591b6c9aad622e3c7f1d565f3383 100644 +--- a/lib/webpack/plugins/ChunkAssetPlugin.js ++++ b/lib/webpack/plugins/ChunkAssetPlugin.js +@@ -22,6 +22,7 @@ const pluginName = 'chunk-asset-plugin'; + */ + class ChunkAssetPlugin { + apply(compiler) { ++ return; + compiler.hooks.thisCompilation.tap(pluginName, ({ mainTemplate }) => { + mainTemplate.hooks.requireExtensions.tap(pluginName, (source, chunk) => { + const chunkIdToName = chunk.getChunkMaps(false).name; +diff --git a/lib/webpack/utils.js b/lib/webpack/utils.js +index 76491bd66a3fe334cc2fe67dde5fc144b0db63d0..ef02d73eb67243e1d99a991ecdaa9b00ba6cae5c 100644 +--- a/lib/webpack/utils.js ++++ b/lib/webpack/utils.js +@@ -54,7 +54,7 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) { + ] + : [ + { +- loader: mini_css_extract_plugin_1.default.loader, ++ loader: require('webpack').CssExtractRspackPlugin.loader, + options: { + // Don't emit CSS files for SSR (previously used null-loader) + // See https://github.com/webpack-contrib/mini-css-extract-plugin/issues/90#issuecomment-811991738 +@@ -69,7 +69,7 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) { + } + return [ + { +- loader: mini_css_extract_plugin_1.default.loader, ++ loader: require('webpack').CssExtractRspackPlugin.loader, + options: { + esModule: true, + }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9213898..aa66ec8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ overrides: webpack: npm:@rspack/core@1.0.0-beta.2 patchedDependencies: + '@docusaurus/core@3.4.0': + hash: kyf4wi5zszlzs6qbfjks2bcuwu + path: patches/@docusaurus__core@3.4.0.patch '@docusaurus/theme-classic@3.4.0': hash: xwsvemiwwscle7sdonkkd4r7be path: patches/@docusaurus__theme-classic@3.4.0.patch @@ -15,7 +18,7 @@ patchedDependencies: dependencies: '@docusaurus/core': specifier: 3.4.0 - version: 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + version: 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/preset-classic': specifier: 3.4.0 version: 3.4.0(@algolia/client-search@4.24.0)(@rspack/core@1.0.0-beta.2)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(search-insights@2.16.0)(typescript@5.5.4) @@ -1631,7 +1634,7 @@ packages: - '@algolia/client-search' dev: false - /@docusaurus/core@3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4): + /@docusaurus/core@3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4): resolution: {integrity: sha512-g+0wwmN2UJsBqy2fQRQ6fhXruoEa62JDeEa5d8IdTJlMoaDaEDfHh7WjwGRn4opuTQWpjAwP/fbcgyHKlE+64w==} engines: {node: '>=18.0'} hasBin: true @@ -1729,6 +1732,7 @@ packages: - vue-template-compiler - webpack-cli dev: false + patched: true /@docusaurus/cssnano-preset@3.4.0: resolution: {integrity: sha512-qwLFSz6v/pZHy/UP32IrprmH5ORce86BGtN0eBtG75PpzQJAzp9gefspox+s8IEOr0oZKuQ/nhzZ3xwyc3jYJQ==} @@ -1814,7 +1818,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/logger': 3.4.0 '@docusaurus/mdx-loader': 3.4.0(@docusaurus/types@3.4.0)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/types': 3.4.0(react-dom@18.3.1)(react@18.3.1) @@ -1860,7 +1864,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/logger': 3.4.0 '@docusaurus/mdx-loader': 3.4.0(@docusaurus/types@3.4.0)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/module-type-aliases': 3.4.0(react-dom@18.3.1)(react@18.3.1) @@ -1905,7 +1909,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/mdx-loader': 3.4.0(@docusaurus/types@3.4.0)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/types': 3.4.0(react-dom@18.3.1)(react@18.3.1) '@docusaurus/utils': 3.4.0(@docusaurus/types@3.4.0)(typescript@5.5.4) @@ -1942,7 +1946,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/types': 3.4.0(react-dom@18.3.1)(react@18.3.1) '@docusaurus/utils': 3.4.0(@docusaurus/types@3.4.0)(typescript@5.5.4) fs-extra: 11.2.0 @@ -1977,7 +1981,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/types': 3.4.0(react-dom@18.3.1)(react@18.3.1) '@docusaurus/utils-validation': 3.4.0(@docusaurus/types@3.4.0)(typescript@5.5.4) react: 18.3.1 @@ -2010,7 +2014,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/types': 3.4.0(react-dom@18.3.1)(react@18.3.1) '@docusaurus/utils-validation': 3.4.0(@docusaurus/types@3.4.0)(typescript@5.5.4) '@types/gtag.js': 0.0.12 @@ -2044,7 +2048,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/types': 3.4.0(react-dom@18.3.1)(react@18.3.1) '@docusaurus/utils-validation': 3.4.0(@docusaurus/types@3.4.0)(typescript@5.5.4) react: 18.3.1 @@ -2077,7 +2081,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/logger': 3.4.0 '@docusaurus/types': 3.4.0(react-dom@18.3.1)(react@18.3.1) '@docusaurus/utils': 3.4.0(@docusaurus/types@3.4.0)(typescript@5.5.4) @@ -2115,7 +2119,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/plugin-content-blog': 3.4.0(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/plugin-content-docs': 3.4.0(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/plugin-content-pages': 3.4.0(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) @@ -2168,7 +2172,7 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 dependencies: - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/mdx-loader': 3.4.0(@docusaurus/types@3.4.0)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/module-type-aliases': 3.4.0(react-dom@18.3.1)(react@18.3.1) '@docusaurus/plugin-content-blog': 3.4.0(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) @@ -2270,7 +2274,7 @@ packages: react-dom: ^18.0.0 dependencies: '@docsearch/react': 3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(search-insights@2.16.0) - '@docusaurus/core': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) + '@docusaurus/core': 3.4.0(patch_hash=kyf4wi5zszlzs6qbfjks2bcuwu)(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/logger': 3.4.0 '@docusaurus/plugin-content-docs': 3.4.0(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4) '@docusaurus/theme-common': 3.4.0(@docusaurus/types@3.4.0)(@rspack/core@1.0.0-beta.2)(react-dom@18.3.1)(react@18.3.1)(typescript@5.5.4)