@docusaurus/core 4.0.0-canary-6964 → 4.0.0-canary-6966
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.
- package/lib/commands/start/utils.d.ts +5 -0
- package/lib/commands/start/utils.js +9 -2
- package/lib/commands/start/webpack.js +3 -14
- package/lib/webpack/utils/getHttpsConfig.d.ts +3 -2
- package/package.json +12 -12
- package/lib/commands/utils/legacy/evalSourceMapMiddleware.d.ts +0 -18
- package/lib/commands/utils/legacy/evalSourceMapMiddleware.js +0 -57
|
@@ -5,16 +5,21 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import _ from 'lodash';
|
|
8
|
+
import { type HttpsConfig } from '../../webpack/utils/getHttpsConfig';
|
|
8
9
|
import type { StartCLIOptions } from './start';
|
|
9
10
|
import type { LoadedPlugin, RouterType } from '@docusaurus/types';
|
|
10
11
|
export type OpenUrlContext = {
|
|
11
12
|
host: string;
|
|
12
13
|
port: number;
|
|
14
|
+
httpsConfig: HttpsConfig;
|
|
13
15
|
getOpenUrl: ({ baseUrl, router, }: {
|
|
14
16
|
baseUrl: string;
|
|
15
17
|
router: RouterType;
|
|
16
18
|
}) => string;
|
|
17
19
|
};
|
|
20
|
+
export declare function createOpenUrlContext({ cliOptions, }: {
|
|
21
|
+
cliOptions: StartCLIOptions;
|
|
22
|
+
}): Promise<OpenUrlContext>;
|
|
18
23
|
type StartParams = {
|
|
19
24
|
siteDirParam: string;
|
|
20
25
|
cliOptions: Partial<StartCLIOptions>;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createOpenUrlContext = createOpenUrlContext;
|
|
9
10
|
exports.createReloadableSite = createReloadableSite;
|
|
10
11
|
const tslib_1 = require("tslib");
|
|
11
12
|
const node_url_1 = tslib_1.__importDefault(require("node:url"));
|
|
@@ -14,6 +15,7 @@ const utils_1 = require("@docusaurus/utils");
|
|
|
14
15
|
const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
|
|
15
16
|
const fs_1 = require("@docusaurus/fs");
|
|
16
17
|
const getHostPort_1 = require("../../server/getHostPort");
|
|
18
|
+
const getHttpsConfig_1 = tslib_1.__importDefault(require("../../webpack/utils/getHttpsConfig"));
|
|
17
19
|
const site_1 = require("../../server/site");
|
|
18
20
|
const pluginsUtils_1 = require("../../server/plugins/pluginsUtils");
|
|
19
21
|
// This code was historically in CRA/react-dev-utils (deprecated in 2025)
|
|
@@ -32,7 +34,12 @@ function getOpenUrlOrigin(protocol, host, port) {
|
|
|
32
34
|
return localUrlForBrowser;
|
|
33
35
|
}
|
|
34
36
|
async function createOpenUrlContext({ cliOptions, }) {
|
|
35
|
-
const
|
|
37
|
+
const httpsConfig = await (0, getHttpsConfig_1.default)({
|
|
38
|
+
https: cliOptions.https,
|
|
39
|
+
sslCert: cliOptions.sslCert,
|
|
40
|
+
sslKey: cliOptions.sslKey,
|
|
41
|
+
});
|
|
42
|
+
const protocol = httpsConfig ? 'https' : 'http';
|
|
36
43
|
const { host, port } = await (0, getHostPort_1.getHostPort)(cliOptions);
|
|
37
44
|
if (port === null) {
|
|
38
45
|
return process.exit();
|
|
@@ -44,7 +51,7 @@ async function createOpenUrlContext({ cliOptions, }) {
|
|
|
44
51
|
baseUrl,
|
|
45
52
|
]);
|
|
46
53
|
};
|
|
47
|
-
return { host, port, getOpenUrl };
|
|
54
|
+
return { host, port, httpsConfig, getOpenUrl };
|
|
48
55
|
}
|
|
49
56
|
async function createLoadSiteParams({ siteDirParam, cliOptions, }) {
|
|
50
57
|
const siteDir = await (0, fs_1.realpath)(siteDirParam);
|
|
@@ -12,9 +12,7 @@ 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 evalSourceMapMiddleware_1 = tslib_1.__importDefault(require("../utils/legacy/evalSourceMapMiddleware"));
|
|
16
15
|
const watcher_1 = require("./watcher");
|
|
17
|
-
const getHttpsConfig_1 = tslib_1.__importDefault(require("../../webpack/utils/getHttpsConfig"));
|
|
18
16
|
const configure_1 = require("../../webpack/configure");
|
|
19
17
|
const client_1 = require("../../webpack/client");
|
|
20
18
|
// E2E_TEST=true docusaurus start
|
|
@@ -37,14 +35,9 @@ function registerWebpackE2ETestHook(compiler) {
|
|
|
37
35
|
}
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
|
-
|
|
38
|
+
function createDevServerConfig({ cliOptions, props, host, port, httpsConfig, }) {
|
|
41
39
|
const { baseUrl, siteDir, siteConfig } = props;
|
|
42
40
|
const pollingOptions = (0, watcher_1.createPollingOptions)(cliOptions);
|
|
43
|
-
const httpsConfig = await (0, getHttpsConfig_1.default)({
|
|
44
|
-
https: cliOptions.https,
|
|
45
|
-
sslCert: cliOptions.sslCert,
|
|
46
|
-
sslKey: cliOptions.sslKey,
|
|
47
|
-
});
|
|
48
41
|
// https://webpack.js.org/configuration/dev-server
|
|
49
42
|
return {
|
|
50
43
|
hot: cliOptions.hotOnly ? 'only' : true,
|
|
@@ -93,11 +86,6 @@ async function createDevServerConfig({ cliOptions, props, host, port, }) {
|
|
|
93
86
|
allowedHosts: 'all',
|
|
94
87
|
host,
|
|
95
88
|
port,
|
|
96
|
-
setupMiddlewares: (middlewares, devServer) => {
|
|
97
|
-
// This lets us fetch source contents from webpack for the error overlay.
|
|
98
|
-
middlewares.unshift((0, evalSourceMapMiddleware_1.default)(devServer));
|
|
99
|
-
return middlewares;
|
|
100
|
-
},
|
|
101
89
|
};
|
|
102
90
|
}
|
|
103
91
|
async function getStartClientConfig({ props, minify, poll, configureWebpackUtils, }) {
|
|
@@ -128,11 +116,12 @@ async function createWebpackDevServer({ props, cliOptions, openUrlContext, }) {
|
|
|
128
116
|
});
|
|
129
117
|
const compiler = props.currentBundler.instance(config);
|
|
130
118
|
registerWebpackE2ETestHook(compiler);
|
|
131
|
-
const defaultDevServerConfig =
|
|
119
|
+
const defaultDevServerConfig = createDevServerConfig({
|
|
132
120
|
cliOptions,
|
|
133
121
|
props,
|
|
134
122
|
host: openUrlContext.host,
|
|
135
123
|
port: openUrlContext.port,
|
|
124
|
+
httpsConfig: openUrlContext.httpsConfig,
|
|
136
125
|
});
|
|
137
126
|
// Allow plugin authors to customize/override devServer config
|
|
138
127
|
const devServerConfig = (0, webpack_merge_1.default)([defaultDevServerConfig, config.devServer].filter(Boolean));
|
|
@@ -9,8 +9,9 @@ type HttpsConfigOptions = {
|
|
|
9
9
|
sslCert: string;
|
|
10
10
|
sslKey: string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type HttpsConfig = boolean | {
|
|
13
13
|
cert: Buffer;
|
|
14
14
|
key: Buffer;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export default function getHttpsConfig(options?: Partial<HttpsConfigOptions>): Promise<HttpsConfig>;
|
|
16
17
|
export {};
|
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-6966",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@docusaurus/babel": "4.0.0-canary-
|
|
31
|
-
"@docusaurus/bundler": "4.0.0-canary-
|
|
32
|
-
"@docusaurus/fs": "4.0.0-canary-
|
|
33
|
-
"@docusaurus/glob": "4.0.0-canary-
|
|
34
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
35
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
36
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
37
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
38
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
30
|
+
"@docusaurus/babel": "4.0.0-canary-6966",
|
|
31
|
+
"@docusaurus/bundler": "4.0.0-canary-6966",
|
|
32
|
+
"@docusaurus/fs": "4.0.0-canary-6966",
|
|
33
|
+
"@docusaurus/glob": "4.0.0-canary-6966",
|
|
34
|
+
"@docusaurus/logger": "4.0.0-canary-6966",
|
|
35
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6966",
|
|
36
|
+
"@docusaurus/utils": "4.0.0-canary-6966",
|
|
37
|
+
"@docusaurus/utils-common": "4.0.0-canary-6966",
|
|
38
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6966",
|
|
39
39
|
"@rspack/core": "^2.2.3",
|
|
40
40
|
"@rspack/dev-server": "^2.2.1",
|
|
41
41
|
"boxen": "^9.0.0",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"webpack-merge": "^6.0.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
72
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
71
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6966",
|
|
72
|
+
"@docusaurus/types": "4.0.0-canary-6966",
|
|
73
73
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
74
74
|
"@types/escape-html": "^1.0.4",
|
|
75
75
|
"@types/history": "^4.7.11",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
export = createEvalSourceMapMiddleware;
|
|
8
|
-
/**
|
|
9
|
-
* Middleware responsible for retrieving a generated source
|
|
10
|
-
* Receives a webpack internal url: "webpack-internal:///<module-id>"
|
|
11
|
-
* Returns a generated source: "<source-text><sourceMappingURL><sourceURL>"
|
|
12
|
-
*
|
|
13
|
-
* Based on EvalSourceMapDevToolModuleTemplatePlugin.js
|
|
14
|
-
*
|
|
15
|
-
* @param {import("webpack-dev-server").default} server
|
|
16
|
-
* @returns {import("express").Handler}
|
|
17
|
-
*/
|
|
18
|
-
declare function createEvalSourceMapMiddleware(server: import("webpack-dev-server").default): import("express").Handler;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// TODO Legacy CRA react-dev-utils package code
|
|
9
|
-
// This code was in CRA/react-dev-utils (deprecated in 2025)
|
|
10
|
-
// We just copied the code as-is to remove a fat/useless dependency subtree
|
|
11
|
-
// See https://github.com/facebook/docusaurus/pull/10956
|
|
12
|
-
// See https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/evalSourceMapMiddleware.js
|
|
13
|
-
|
|
14
|
-
/* eslint-disable */
|
|
15
|
-
|
|
16
|
-
function base64SourceMap(source) {
|
|
17
|
-
const base64 = Buffer.from(JSON.stringify(source.map()), 'utf8').toString(
|
|
18
|
-
'base64',
|
|
19
|
-
);
|
|
20
|
-
return `data:application/json;charset=utf-8;base64,${base64}`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getSourceById(server, id) {
|
|
24
|
-
const module = Array.from(server._stats.compilation.modules).find(
|
|
25
|
-
(m) => server._stats.compilation.chunkGraph.getModuleId(m) == id,
|
|
26
|
-
);
|
|
27
|
-
return module.originalSource();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Middleware responsible for retrieving a generated source
|
|
32
|
-
* Receives a webpack internal url: "webpack-internal:///<module-id>"
|
|
33
|
-
* Returns a generated source: "<source-text><sourceMappingURL><sourceURL>"
|
|
34
|
-
*
|
|
35
|
-
* Based on EvalSourceMapDevToolModuleTemplatePlugin.js
|
|
36
|
-
*
|
|
37
|
-
* @param {import("webpack-dev-server").default} server
|
|
38
|
-
* @returns {import("express").Handler}
|
|
39
|
-
*/
|
|
40
|
-
module.exports = function createEvalSourceMapMiddleware(server) {
|
|
41
|
-
return function handleWebpackInternalMiddleware(req, res, next) {
|
|
42
|
-
if (req.url.startsWith('/__get-internal-source')) {
|
|
43
|
-
const fileName = req.query.fileName;
|
|
44
|
-
const id = fileName.match(/webpack-internal:\/\/\/(.+)/)[1];
|
|
45
|
-
if (!id || !server._stats) {
|
|
46
|
-
next();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const source = getSourceById(server, id);
|
|
50
|
-
const sourceMapURL = `//# sourceMappingURL=${base64SourceMap(source)}`;
|
|
51
|
-
const sourceURL = `//# sourceURL=webpack-internal:///${module.id}`;
|
|
52
|
-
res.end(`${source.source()}\n${sourceMapURL}\n${sourceURL}`);
|
|
53
|
-
} else {
|
|
54
|
-
next();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|