-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
170 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,8 @@ | |
"webpack": "npm:@rspack/[email protected]" | ||
}, | ||
"patchedDependencies": { | ||
"@docusaurus/[email protected]": "patches/@[email protected]" | ||
"@docusaurus/[email protected]": "patches/@[email protected]", | ||
"@docusaurus/[email protected]": "patches/@[email protected]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
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..c4b4f4364a36ac24ed4198726cb2326b9314c11d 100644 | ||
--- a/lib/webpack/base.js | ||
+++ b/lib/webpack/base.js | ||
@@ -15,6 +15,8 @@ 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,20 +198,12 @@ async function createBaseConfig({ props, isServer, minify, }) { | ||
}, | ||
], | ||
}, | ||
+ experiments: { | ||
+ css:false | ||
+ }, | ||
plugins: [ | ||
- new mini_css_extract_plugin_1.default({ | ||
- filename: isProd | ||
- ? 'assets/css/[name].[contenthash:8].css' | ||
- : '[name].css', | ||
- chunkFilename: isProd | ||
- ? 'assets/css/[name].[contenthash:8].css' | ||
- : '[name].css', | ||
- // Remove css order warnings if css imports are not sorted | ||
- // alphabetically. See https://github.com/webpack-contrib/mini-css-extract-plugin/pull/422 | ||
- // for more reasoning | ||
- ignoreOrder: true, | ||
- }), | ||
- ], | ||
+ new webpack.CssExtractRspackPlugin({}) | ||
+ ] | ||
}; | ||
} | ||
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, | ||
}, |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.