@docusaurus/core 0.0.0-5913 → 0.0.0-5920
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/client/App.d.ts +1 -0
- package/lib/commands/serve.js +19 -4
- package/lib/server/configValidation.js +3 -3
- package/lib/ssg.d.ts +1 -0
- package/lib/webpack/base.js +2 -2
- package/lib/webpack/utils.d.ts +2 -2
- package/package.json +11 -12
package/lib/client/App.d.ts
CHANGED
|
@@ -4,6 +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
|
+
/// <reference types="@docusaurus/module-type-aliases" />
|
|
7
8
|
/// <reference types="react" />
|
|
8
9
|
import '@generated/client-modules';
|
|
9
10
|
export default function App(): JSX.Element;
|
package/lib/commands/serve.js
CHANGED
|
@@ -15,9 +15,16 @@ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
|
|
17
17
|
const openBrowser_1 = tslib_1.__importDefault(require("react-dev-utils/openBrowser"));
|
|
18
|
+
const utils_common_1 = require("@docusaurus/utils-common");
|
|
18
19
|
const config_1 = require("../server/config");
|
|
19
20
|
const build_1 = require("./build");
|
|
20
21
|
const getHostPort_1 = require("../server/getHostPort");
|
|
22
|
+
function redirect(res, location) {
|
|
23
|
+
res.writeHead(302, {
|
|
24
|
+
Location: location,
|
|
25
|
+
});
|
|
26
|
+
res.end();
|
|
27
|
+
}
|
|
21
28
|
async function serve(siteDirParam = '.', cliOptions = {}) {
|
|
22
29
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
23
30
|
const buildDir = cliOptions.dir ?? utils_1.DEFAULT_BUILD_DIR_NAME;
|
|
@@ -40,14 +47,22 @@ async function serve(siteDirParam = '.', cliOptions = {}) {
|
|
|
40
47
|
const server = http_1.default.createServer((req, res) => {
|
|
41
48
|
// Automatically redirect requests to /baseUrl/
|
|
42
49
|
if (!req.url?.startsWith(baseUrl)) {
|
|
43
|
-
res
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
redirect(res, baseUrl);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// We do the redirect ourselves for a good reason
|
|
54
|
+
// server-handler is annoying and won't include /baseUrl/ in redirects
|
|
55
|
+
const normalizedUrl = (0, utils_common_1.applyTrailingSlash)(req.url, { trailingSlash, baseUrl });
|
|
56
|
+
if (req.url !== normalizedUrl) {
|
|
57
|
+
redirect(res, normalizedUrl);
|
|
47
58
|
return;
|
|
48
59
|
}
|
|
49
60
|
// Remove baseUrl before calling serveHandler, because /baseUrl/ should
|
|
50
61
|
// serve /build/index.html, not /build/baseUrl/index.html (does not exist)
|
|
62
|
+
// Note server-handler is really annoying here:
|
|
63
|
+
// - no easy way to do rewrites such as "/baseUrl/:path" => "/:path"
|
|
64
|
+
// - no easy way to "reapply" the baseUrl to the redirect "Location" header
|
|
65
|
+
// See also https://github.com/facebook/docusaurus/pull/10090
|
|
51
66
|
req.url = req.url.replace(baseUrl, '/');
|
|
52
67
|
(0, serve_handler_1.default)(req, res, {
|
|
53
68
|
cleanUrls: true,
|
|
@@ -18,7 +18,7 @@ exports.DEFAULT_I18N_CONFIG = {
|
|
|
18
18
|
localeConfigs: {},
|
|
19
19
|
};
|
|
20
20
|
exports.DEFAULT_MARKDOWN_CONFIG = {
|
|
21
|
-
format: 'mdx',
|
|
21
|
+
format: 'mdx', // TODO change this to "detect" in Docusaurus v4?
|
|
22
22
|
mermaid: false,
|
|
23
23
|
preprocessor: undefined,
|
|
24
24
|
parseFrontMatter: utils_1.DEFAULT_PARSE_FRONT_MATTER,
|
|
@@ -35,7 +35,7 @@ exports.DEFAULT_MARKDOWN_CONFIG = {
|
|
|
35
35
|
exports.DEFAULT_CONFIG = {
|
|
36
36
|
i18n: exports.DEFAULT_I18N_CONFIG,
|
|
37
37
|
onBrokenLinks: 'throw',
|
|
38
|
-
onBrokenAnchors: 'warn',
|
|
38
|
+
onBrokenAnchors: 'warn', // TODO Docusaurus v4: change to throw
|
|
39
39
|
onBrokenMarkdownLinks: 'warn',
|
|
40
40
|
onDuplicateRoutes: 'warn',
|
|
41
41
|
plugins: [],
|
|
@@ -150,7 +150,7 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
|
150
150
|
favicon: utils_validation_1.Joi.string().optional(),
|
|
151
151
|
title: utils_validation_1.Joi.string().required(),
|
|
152
152
|
url: SiteUrlSchema,
|
|
153
|
-
trailingSlash: utils_validation_1.Joi.boolean(),
|
|
153
|
+
trailingSlash: utils_validation_1.Joi.boolean(), // No default value! undefined = retrocompatible legacy behavior!
|
|
154
154
|
i18n: I18N_CONFIG_SCHEMA,
|
|
155
155
|
onBrokenLinks: utils_validation_1.Joi.string()
|
|
156
156
|
.equal('ignore', 'log', 'warn', 'throw')
|
package/lib/ssg.d.ts
CHANGED
|
@@ -4,6 +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
|
+
/// <reference path="../src/deps.d.ts" />
|
|
7
8
|
import type { AppRenderer, SiteCollectedData } from './common';
|
|
8
9
|
import type { Manifest } from 'react-loadable-ssr-addon-v5-slorber';
|
|
9
10
|
import type { SSRTemplateCompiled } from './templates/templates';
|
package/lib/webpack/base.js
CHANGED
|
@@ -88,9 +88,9 @@ async function createBaseConfig({ props, isServer, minify, }) {
|
|
|
88
88
|
},
|
|
89
89
|
devtool: isProd ? undefined : 'eval-cheap-module-source-map',
|
|
90
90
|
resolve: {
|
|
91
|
-
unsafeCache: false,
|
|
91
|
+
unsafeCache: false, // Not enabled, does not seem to improve perf much
|
|
92
92
|
extensions: ['.wasm', '.mjs', '.js', '.jsx', '.ts', '.tsx', '.json'],
|
|
93
|
-
symlinks: true,
|
|
93
|
+
symlinks: true, // See https://github.com/facebook/docusaurus/issues/3272
|
|
94
94
|
roots: [
|
|
95
95
|
// Allow resolution of url("/fonts/xyz.ttf") by webpack
|
|
96
96
|
// See https://webpack.js.org/configuration/resolve/#resolveroots
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ export declare function getBabelOptions({ isServer, babelOptions, }?: {
|
|
|
18
18
|
isServer?: boolean;
|
|
19
19
|
babelOptions?: TransformOptions | string;
|
|
20
20
|
}): TransformOptions;
|
|
21
|
-
export declare const getCustomizableJSLoader: (jsLoader?:
|
|
21
|
+
export declare const getCustomizableJSLoader: (jsLoader?: 'babel' | ((isServer: boolean) => RuleSetRule)) => ({ isServer, babelOptions, }: {
|
|
22
22
|
isServer: boolean;
|
|
23
|
-
babelOptions?:
|
|
23
|
+
babelOptions?: TransformOptions | string;
|
|
24
24
|
}) => RuleSetRule;
|
|
25
25
|
/**
|
|
26
26
|
* Helper function to modify webpack config
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5920",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,12 @@
|
|
|
43
43
|
"@babel/runtime": "^7.22.6",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
45
45
|
"@babel/traverse": "^7.22.8",
|
|
46
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
47
|
-
"@docusaurus/logger": "0.0.0-
|
|
48
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
49
|
-
"@docusaurus/
|
|
50
|
-
"@docusaurus/utils": "0.0.0-
|
|
51
|
-
"@docusaurus/utils-
|
|
52
|
-
"@docusaurus/utils-validation": "0.0.0-5913",
|
|
46
|
+
"@docusaurus/cssnano-preset": "0.0.0-5920",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5920",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5920",
|
|
49
|
+
"@docusaurus/utils": "0.0.0-5920",
|
|
50
|
+
"@docusaurus/utils-common": "0.0.0-5920",
|
|
51
|
+
"@docusaurus/utils-validation": "0.0.0-5920",
|
|
53
52
|
"@svgr/webpack": "^6.5.1",
|
|
54
53
|
"autoprefixer": "^10.4.14",
|
|
55
54
|
"babel-loader": "^9.1.3",
|
|
@@ -85,7 +84,7 @@
|
|
|
85
84
|
"prompts": "^2.4.2",
|
|
86
85
|
"react-dev-utils": "^12.0.1",
|
|
87
86
|
"react-helmet-async": "^1.3.0",
|
|
88
|
-
"react-loadable": "npm:@docusaurus/react-loadable@
|
|
87
|
+
"react-loadable": "npm:@docusaurus/react-loadable@6.0.0",
|
|
89
88
|
"react-loadable-ssr-addon-v5-slorber": "^1.0.1",
|
|
90
89
|
"react-router": "^5.3.4",
|
|
91
90
|
"react-router-config": "^5.1.1",
|
|
@@ -105,8 +104,8 @@
|
|
|
105
104
|
"webpackbar": "^5.0.2"
|
|
106
105
|
},
|
|
107
106
|
"devDependencies": {
|
|
108
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
109
|
-
"@docusaurus/types": "0.0.0-
|
|
107
|
+
"@docusaurus/module-type-aliases": "0.0.0-5920",
|
|
108
|
+
"@docusaurus/types": "0.0.0-5920",
|
|
110
109
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
111
110
|
"@types/detect-port": "^1.3.3",
|
|
112
111
|
"@types/react-dom": "^18.2.7",
|
|
@@ -126,5 +125,5 @@
|
|
|
126
125
|
"engines": {
|
|
127
126
|
"node": ">=18.0"
|
|
128
127
|
},
|
|
129
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "2eb0d5b1dfb69922a0881ba63c7294c3efbb799d"
|
|
130
129
|
}
|