@docusaurus/core 4.0.0-canary-6911 → 4.0.0-canary-6913
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { RspackDevServer } from '@docusaurus/bundler';
|
|
8
|
-
import WebpackDevServer from 'webpack-dev-server';
|
|
9
8
|
import type { StartCLIOptions } from './start';
|
|
10
9
|
import type { Props } from '@docusaurus/types';
|
|
10
|
+
import type WebpackDevServer from 'webpack-dev-server';
|
|
11
11
|
import type { OpenUrlContext } from './utils';
|
|
12
12
|
export declare function createWebpackDevServer({ props, cliOptions, openUrlContext, }: {
|
|
13
13
|
props: Props;
|
|
@@ -12,7 +12,6 @@ const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
|
12
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
13
13
|
const bundler_1 = require("@docusaurus/bundler");
|
|
14
14
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
|
-
const webpack_dev_server_1 = tslib_1.__importDefault(require("webpack-dev-server"));
|
|
16
15
|
const evalSourceMapMiddleware_1 = tslib_1.__importDefault(require("../utils/legacy/evalSourceMapMiddleware"));
|
|
17
16
|
const watcher_1 = require("./watcher");
|
|
18
17
|
const getHttpsConfig_1 = tslib_1.__importDefault(require("../../webpack/utils/getHttpsConfig"));
|
|
@@ -145,7 +144,9 @@ async function createWebpackDevServer({ props, cliOptions, openUrlContext, }) {
|
|
|
145
144
|
}
|
|
146
145
|
async function createDevServer({ devServerConfig, compiler, currentBundler, }) {
|
|
147
146
|
if (currentBundler.name === 'webpack') {
|
|
148
|
-
|
|
147
|
+
// Imported lazily, only when Webpack is used
|
|
148
|
+
const { default: WebpackDevServer } = await import('webpack-dev-server');
|
|
149
|
+
return new WebpackDevServer(devServerConfig, compiler);
|
|
149
150
|
}
|
|
150
151
|
// Docusaurus bundler configs are typed with Webpack types
|
|
151
152
|
return new bundler_1.RspackDevServer(devServerConfig, compiler);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import type { Compiler } from 'webpack';
|
|
8
8
|
export default class ChunkAssetPlugin {
|
|
9
9
|
apply(compiler: Compiler): void;
|
|
10
10
|
}
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const tslib_1 = require("tslib");
|
|
10
|
-
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
11
9
|
// Adds a custom Docusaurus Webpack runtime function `__webpack_require__.gca`
|
|
12
10
|
// gca = Get Chunk Asset, it converts a chunkName to a JS asset URL
|
|
13
11
|
// It is called in Core client/docusaurus.ts for chunk preloading/prefetching
|
|
@@ -16,7 +14,7 @@ const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
|
16
14
|
// The name of the custom Docusaurus Webpack runtime function
|
|
17
15
|
const DocusaurusGetChunkAssetFn = '__webpack_require__.gca';
|
|
18
16
|
const PluginName = 'Docusaurus-ChunkAssetPlugin';
|
|
19
|
-
function generateGetChunkAssetRuntimeCode(chunk) {
|
|
17
|
+
function generateGetChunkAssetRuntimeCode({ chunk, bundler, }) {
|
|
20
18
|
const chunkIdToName = chunk.getChunkMaps(false).name;
|
|
21
19
|
const chunkNameToId = Object.fromEntries(Object.entries(chunkIdToName).map(([chunkId, chunkName]) => [
|
|
22
20
|
chunkName,
|
|
@@ -30,10 +28,10 @@ function generateGetChunkAssetRuntimeCode(chunk) {
|
|
|
30
28
|
// getChunkScriptFilename = __webpack_require__.u
|
|
31
29
|
// Example: getChunkScriptFilename("814f3328") = "814f3328.03fcc178.js"
|
|
32
30
|
// https://github.com/webpack/webpack/blob/v5.94.0/lib/runtime/GetChunkFilenameRuntimeModule.js
|
|
33
|
-
getChunkScriptFilename, } =
|
|
31
|
+
getChunkScriptFilename, } = bundler.RuntimeGlobals;
|
|
34
32
|
const code = `// Docusaurus function to get chunk asset
|
|
35
33
|
${DocusaurusGetChunkAssetFn} = function(chunkId) { chunkId = ${JSON.stringify(chunkNameToId)}[chunkId]||chunkId; return ${publicPath} + ${getChunkScriptFilename}(chunkId); };`;
|
|
36
|
-
return
|
|
34
|
+
return bundler.Template.asString(code);
|
|
37
35
|
}
|
|
38
36
|
/*
|
|
39
37
|
Note: we previously used `MainTemplate.hooks.requireExtensions.tap()`
|
|
@@ -44,6 +42,9 @@ ${DocusaurusGetChunkAssetFn} = function(chunkId) { chunkId = ${JSON.stringify(ch
|
|
|
44
42
|
*/
|
|
45
43
|
class ChunkAssetPlugin {
|
|
46
44
|
apply(compiler) {
|
|
45
|
+
// Use the compiler's bundler instance (Webpack or Rspack)
|
|
46
|
+
// This avoids loading Webpack when using Rspack
|
|
47
|
+
const ChunkAssetRuntimeModule = createChunkAssetRuntimeModuleClass(compiler.webpack);
|
|
47
48
|
compiler.hooks.thisCompilation.tap(PluginName, (compilation) => {
|
|
48
49
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(PluginName, (chunk) => {
|
|
49
50
|
compilation.addRuntimeModule(chunk, new ChunkAssetRuntimeModule());
|
|
@@ -55,12 +56,14 @@ exports.default = ChunkAssetPlugin;
|
|
|
55
56
|
// Inspired by https://github.com/webpack/webpack/blob/v5.94.0/lib/runtime/CompatRuntimeModule.js
|
|
56
57
|
// See also https://rspack.dev/api/javascript-api/compilation#addruntimemodule
|
|
57
58
|
// See also https://rspack.dev/api/plugin-api/compilation-hooks#additionaltreeruntimerequirements
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
function createChunkAssetRuntimeModuleClass(bundler) {
|
|
60
|
+
return class ChunkAssetRuntimeModule extends bundler.RuntimeModule {
|
|
61
|
+
constructor() {
|
|
62
|
+
super('ChunkAssetRuntimeModule', bundler.RuntimeModule.STAGE_ATTACH);
|
|
63
|
+
this.fullHash = true;
|
|
64
|
+
}
|
|
65
|
+
generate() {
|
|
66
|
+
return generateGetChunkAssetRuntimeCode({ chunk: this.chunk, bundler });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
66
69
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "4.0.0-canary-
|
|
4
|
+
"version": "4.0.0-canary-6913",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docusaurus/babel": "4.0.0-canary-
|
|
37
|
-
"@docusaurus/bundler": "4.0.0-canary-
|
|
38
|
-
"@docusaurus/fs": "4.0.0-canary-
|
|
39
|
-
"@docusaurus/glob": "4.0.0-canary-
|
|
40
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
41
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
42
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
43
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
44
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
36
|
+
"@docusaurus/babel": "4.0.0-canary-6913",
|
|
37
|
+
"@docusaurus/bundler": "4.0.0-canary-6913",
|
|
38
|
+
"@docusaurus/fs": "4.0.0-canary-6913",
|
|
39
|
+
"@docusaurus/glob": "4.0.0-canary-6913",
|
|
40
|
+
"@docusaurus/logger": "4.0.0-canary-6913",
|
|
41
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6913",
|
|
42
|
+
"@docusaurus/utils": "4.0.0-canary-6913",
|
|
43
|
+
"@docusaurus/utils-common": "4.0.0-canary-6913",
|
|
44
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6913",
|
|
45
45
|
"@rspack/core": "^2.2.3",
|
|
46
46
|
"@rspack/dev-server": "^2.2.1",
|
|
47
47
|
"boxen": "^9.0.0",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"webpack-merge": "^6.0.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
78
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
77
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6913",
|
|
78
|
+
"@docusaurus/types": "4.0.0-canary-6913",
|
|
79
79
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
80
80
|
"@types/escape-html": "^1.0.4",
|
|
81
81
|
"@types/history": "^4.7.11",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": ">=24.21"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "4ac512f4ec13cf7626e2f099b8e076552a707b78"
|
|
100
100
|
}
|