@docusaurus/core 2.0.0-beta.ff31de0ff → 2.0.1
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/README.md +1 -0
- package/bin/beforeCli.mjs +140 -0
- package/bin/docusaurus.mjs +223 -0
- package/lib/babel/preset.d.ts +8 -3
- package/lib/babel/preset.js +10 -8
- package/lib/client/App.d.ts +2 -3
- package/lib/client/App.js +31 -28
- package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +39 -0
- package/lib/client/LinksCollector.d.ts +3 -3
- package/lib/client/LinksCollector.js +8 -13
- package/lib/client/PendingNavigation.d.ts +17 -3
- package/lib/client/PendingNavigation.js +47 -72
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
- package/lib/client/SiteMetadataDefaults.js +21 -0
- package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
- package/lib/client/browserContext.js +22 -0
- package/lib/client/clientEntry.js +14 -9
- package/lib/client/docusaurus.d.ts +12 -6
- package/lib/client/docusaurus.js +30 -43
- package/lib/client/docusaurusContext.d.ts +12 -0
- package/lib/client/docusaurusContext.js +25 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -5
- package/lib/client/exports/BrowserOnly.js +14 -7
- package/lib/client/exports/ComponentCreator.d.ts +6 -2
- package/lib/client/exports/ComponentCreator.js +75 -42
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +37 -0
- package/lib/client/exports/ExecutionEnvironment.js +7 -8
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +20 -49
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +44 -38
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +14 -9
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/isInternalUrl.js +1 -1
- package/lib/client/exports/renderRoutes.d.ts +1 -2
- package/lib/client/exports/renderRoutes.js +1 -2
- package/lib/client/exports/router.d.ts +1 -1
- package/lib/client/exports/router.js +1 -1
- package/lib/client/exports/useBaseUrl.js +11 -14
- package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
- package/lib/client/exports/useDocusaurusContext.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +8 -15
- package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/exports/useRouteContext.d.ts +8 -0
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +19 -15
- package/lib/client/normalizeLocation.d.ts +2 -5
- package/lib/client/normalizeLocation.js +14 -10
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +12 -32
- package/lib/client/preload.d.ts +3 -4
- package/lib/client/preload.js +5 -12
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.d.ts +10 -0
- package/lib/client/serverEntry.js +109 -136
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +45 -0
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +2 -26
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +50 -116
- package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
- package/lib/client/theme-fallback/NotFound/index.js +19 -18
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -6
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +81 -64
- package/lib/commands/clear.d.ts +7 -1
- package/lib/commands/clear.js +34 -21
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +102 -81
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +9 -11
- package/lib/commands/serve.d.ts +8 -2
- package/lib/commands/serve.js +40 -20
- package/lib/commands/start.d.ts +9 -2
- package/lib/commands/start.js +111 -101
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +106 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +56 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +200 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +84 -0
- package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
- package/lib/commands/swizzle/context.js +24 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +119 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
- package/lib/commands/swizzle/tables.js +113 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +106 -0
- package/lib/commands/writeHeadingIds.d.ts +2 -6
- package/lib/commands/writeHeadingIds.js +22 -81
- package/lib/commands/writeTranslations.d.ts +4 -5
- package/lib/commands/writeTranslations.js +48 -28
- package/lib/index.d.ts +9 -9
- package/lib/index.js +14 -14
- package/lib/server/brokenLinks.d.ts +4 -17
- package/lib/server/brokenLinks.js +67 -56
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +29 -6
- package/lib/server/configValidation.d.ts +5 -3
- package/lib/server/configValidation.js +105 -44
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/server/getHostPort.js +79 -0
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +3 -13
- package/lib/server/i18n.js +21 -55
- package/lib/server/index.d.ts +28 -6
- package/lib/server/index.js +86 -173
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +10 -10
- package/lib/server/plugins/index.js +76 -128
- package/lib/server/plugins/init.d.ts +6 -9
- package/lib/server/plugins/init.js +44 -109
- package/lib/server/plugins/moduleShorthand.d.ts +9 -0
- package/lib/server/plugins/moduleShorthand.js +46 -0
- package/lib/server/plugins/pluginIds.d.ts +6 -2
- package/lib/server/plugins/pluginIds.js +12 -7
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/plugins/presets.js +49 -0
- package/lib/server/plugins/routeConfig.d.ts +11 -0
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +111 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +182 -95
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +16 -22
- package/lib/server/translations/translations.js +41 -73
- package/lib/server/translations/translationsExtractor.d.ts +10 -5
- package/lib/server/translations/translationsExtractor.js +158 -122
- package/lib/server/utils.d.ts +9 -3
- package/lib/server/utils.js +7 -9
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +3 -4
- package/lib/webpack/base.js +56 -58
- package/lib/webpack/client.d.ts +3 -3
- package/lib/webpack/client.js +12 -19
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
- package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
- package/lib/webpack/plugins/CleanWebpackPlugin.js +34 -18
- package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
- package/lib/webpack/plugins/LogPlugin.js +4 -5
- package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
- package/lib/webpack/plugins/WaitPlugin.js +1 -1
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +23 -8
- package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
- package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
- package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
- package/lib/webpack/utils.d.ts +16 -31
- package/lib/webpack/utils.js +63 -183
- package/package.json +83 -77
- package/bin/docusaurus.js +0 -326
- package/lib/.tsbuildinfo +0 -5682
- package/lib/choosePort.js +0 -105
- package/lib/client/.eslintrc.js +0 -29
- package/lib/client/.tsbuildinfo +0 -4127
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
- package/lib/client/client-lifecycles-dispatcher.js +0 -27
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/commands/commandUtils.d.ts +0 -3
- package/lib/commands/commandUtils.js +0 -21
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -245
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/server/client-modules/index.js +0 -14
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -38
- package/lib/server/html-tags/htmlTags.js +0 -39
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.d.ts +0 -9
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/presets/index.js +0 -48
- package/lib/server/themes/alias.d.ts +0 -8
- package/lib/server/themes/alias.js +0 -39
- package/lib/server/themes/index.d.ts +0 -8
- package/lib/server/themes/index.js +0 -35
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/__tests/index.test.js +0 -25
- package/lib/server/versions/index.d.ts +0 -10
- package/lib/server/versions/index.js +0 -50
- package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
- package/lib/webpack/sharedModuleAliases.d.ts +0 -10
- package/lib/webpack/sharedModuleAliases.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
|
@@ -7,6 +7,28 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
+
/**
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
* Copyright (c) 2015 John Agan
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in
|
|
20
|
+
* all copies or substantial portions of the Software.
|
|
21
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
* SOFTWARE.
|
|
28
|
+
*/
|
|
29
|
+
// Forked from https://github.com/johnagan/clean-webpack-plugin
|
|
30
|
+
// Modified to optimize performance for Docusaurus specific use case
|
|
31
|
+
// More context: https://github.com/facebook/docusaurus/pull/1839
|
|
10
32
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
33
|
const del_1 = require("del");
|
|
12
34
|
class CleanWebpackPlugin {
|
|
@@ -40,8 +62,7 @@ class CleanWebpackPlugin {
|
|
|
40
62
|
this.removeFiles = this.removeFiles.bind(this);
|
|
41
63
|
}
|
|
42
64
|
apply(compiler) {
|
|
43
|
-
if (!compiler.options.output
|
|
44
|
-
// eslint-disable-next-line no-console
|
|
65
|
+
if (!compiler.options.output.path) {
|
|
45
66
|
console.warn('clean-webpack-plugin: options.output.path not defined. Plugin disabled...');
|
|
46
67
|
return;
|
|
47
68
|
}
|
|
@@ -61,7 +82,8 @@ class CleanWebpackPlugin {
|
|
|
61
82
|
*
|
|
62
83
|
* Only happens once.
|
|
63
84
|
*
|
|
64
|
-
* Warning: It is recommended to initially clean your build directory outside
|
|
85
|
+
* Warning: It is recommended to initially clean your build directory outside
|
|
86
|
+
* of webpack to minimize unexpected behavior.
|
|
65
87
|
*/
|
|
66
88
|
handleInitial() {
|
|
67
89
|
if (this.initialClean) {
|
|
@@ -76,7 +98,6 @@ class CleanWebpackPlugin {
|
|
|
76
98
|
*/
|
|
77
99
|
if (stats.hasErrors()) {
|
|
78
100
|
if (this.verbose) {
|
|
79
|
-
// eslint-disable-next-line no-console
|
|
80
101
|
console.warn('clean-webpack-plugin: pausing due to webpack errors');
|
|
81
102
|
}
|
|
82
103
|
return;
|
|
@@ -87,18 +108,14 @@ class CleanWebpackPlugin {
|
|
|
87
108
|
const statsAssets = stats.toJson({
|
|
88
109
|
all: false,
|
|
89
110
|
assets: true,
|
|
90
|
-
}).assets
|
|
91
|
-
const assets = statsAssets.map((asset) =>
|
|
92
|
-
return asset.name;
|
|
93
|
-
});
|
|
111
|
+
}).assets ?? [];
|
|
112
|
+
const assets = statsAssets.map((asset) => asset.name);
|
|
94
113
|
/**
|
|
95
114
|
* Get all files that were in the previous build but not the current
|
|
96
115
|
*
|
|
97
116
|
* (relies on del's cwd: outputPath option)
|
|
98
117
|
*/
|
|
99
|
-
const staleFiles = this.currentAssets.filter((previousAsset) =>
|
|
100
|
-
return assets.includes(previousAsset) === false;
|
|
101
|
-
});
|
|
118
|
+
const staleFiles = this.currentAssets.filter((previousAsset) => !assets.includes(previousAsset));
|
|
102
119
|
/**
|
|
103
120
|
* Save assets for next compilation
|
|
104
121
|
*/
|
|
@@ -107,7 +124,7 @@ class CleanWebpackPlugin {
|
|
|
107
124
|
/**
|
|
108
125
|
* Remove unused webpack assets
|
|
109
126
|
*/
|
|
110
|
-
if (this.cleanStaleWebpackAssets
|
|
127
|
+
if (this.cleanStaleWebpackAssets && staleFiles.length !== 0) {
|
|
111
128
|
removePatterns.push(...staleFiles);
|
|
112
129
|
}
|
|
113
130
|
if (removePatterns.length !== 0) {
|
|
@@ -116,7 +133,7 @@ class CleanWebpackPlugin {
|
|
|
116
133
|
}
|
|
117
134
|
removeFiles(patterns) {
|
|
118
135
|
try {
|
|
119
|
-
const deleted = del_1.sync(patterns, {
|
|
136
|
+
const deleted = (0, del_1.sync)(patterns, {
|
|
120
137
|
force: false,
|
|
121
138
|
// Change context to build directory
|
|
122
139
|
cwd: this.outputPath,
|
|
@@ -135,18 +152,17 @@ class CleanWebpackPlugin {
|
|
|
135
152
|
* https://github.com/webpack/webpack/issues/1904
|
|
136
153
|
* https://github.com/johnagan/clean-webpack-plugin/issues/11
|
|
137
154
|
*/
|
|
138
|
-
// eslint-disable-next-line no-console
|
|
139
155
|
console.warn(`clean-webpack-plugin: removed ${filename}`);
|
|
140
156
|
});
|
|
141
157
|
}
|
|
142
158
|
}
|
|
143
|
-
catch (
|
|
144
|
-
const needsForce =
|
|
159
|
+
catch (err) {
|
|
160
|
+
const needsForce = err.message.includes('Cannot delete files/folders outside the current working directory.');
|
|
145
161
|
if (needsForce) {
|
|
146
|
-
const message = 'clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the
|
|
162
|
+
const message = 'clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the "dangerouslyAllowCleanPatternsOutsideProject" option.';
|
|
147
163
|
throw new Error(message);
|
|
148
164
|
}
|
|
149
|
-
throw
|
|
165
|
+
throw err;
|
|
150
166
|
}
|
|
151
167
|
}
|
|
152
168
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import WebpackBar from 'webpackbar';
|
|
8
|
-
import { Compiler } from 'webpack';
|
|
8
|
+
import type { Compiler } from 'webpack';
|
|
9
9
|
export default class LogPlugin extends WebpackBar {
|
|
10
10
|
apply(compiler: Compiler): void;
|
|
11
11
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
2
|
/**
|
|
5
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
4
|
*
|
|
7
5
|
* This source code is licensed under the MIT license found in the
|
|
8
6
|
* LICENSE file in the root directory of this source tree.
|
|
9
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
10
|
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
11
|
-
|
|
12
|
-
const formatWebpackMessages_1 = tslib_1.__importDefault(require("../react-dev-utils-webpack5/formatWebpackMessages"));
|
|
11
|
+
const formatWebpackMessages_1 = tslib_1.__importDefault(require("react-dev-utils/formatWebpackMessages"));
|
|
13
12
|
function showError(arr) {
|
|
14
13
|
console.log(`\n\n${arr.join('\n')}`);
|
|
15
14
|
}
|
|
@@ -23,7 +22,7 @@ class LogPlugin extends webpackbar_1.default {
|
|
|
23
22
|
// TODO do we really want to keep this legacy logic?
|
|
24
23
|
// let's wait and see how the react-dev-utils support Webpack5
|
|
25
24
|
// we probably want to print the error stacktraces here
|
|
26
|
-
const messages = formatWebpackMessages_1.default(errorsWarnings);
|
|
25
|
+
const messages = (0, formatWebpackMessages_1.default)(errorsWarnings);
|
|
27
26
|
if (messages.errors.length) {
|
|
28
27
|
showError(messages.errors);
|
|
29
28
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
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 { Compiler } from 'webpack';
|
|
8
|
-
|
|
7
|
+
import type { Compiler } from 'webpack';
|
|
8
|
+
declare type WaitPluginOptions = {
|
|
9
9
|
filepath: string;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
export default class WaitPlugin {
|
|
12
12
|
filepath: string;
|
|
13
13
|
constructor(options: WaitPluginOptions);
|
|
@@ -20,7 +20,7 @@ class WaitPlugin {
|
|
|
20
20
|
// To prevent 'waitFile' error on waiting non-existing directory
|
|
21
21
|
fs_extra_1.default.ensureDir(path_1.default.dirname(this.filepath), {}, () => {
|
|
22
22
|
// Wait until file exist
|
|
23
|
-
wait_on_1.default({
|
|
23
|
+
(0, wait_on_1.default)({
|
|
24
24
|
resources: [this.filepath],
|
|
25
25
|
interval: 300,
|
|
26
26
|
})
|
package/lib/webpack/server.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
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 {
|
|
8
|
-
import { Props } from '@docusaurus/types';
|
|
9
|
-
|
|
7
|
+
import { type Locals } from '@slorber/static-site-generator-webpack-plugin';
|
|
8
|
+
import type { Props } from '@docusaurus/types';
|
|
9
|
+
import type { Configuration } from 'webpack';
|
|
10
|
+
export default function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }: Pick<Locals, 'onLinksCollected' | 'onHeadTagsCollected'> & {
|
|
10
11
|
props: Props;
|
|
11
|
-
|
|
12
|
-
}): Configuration;
|
|
12
|
+
}): Promise<Configuration>;
|
package/lib/webpack/server.js
CHANGED
|
@@ -8,15 +8,17 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
-
const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@endiliey/static-site-generator-webpack-plugin"));
|
|
12
11
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
12
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
|
+
// Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
|
|
14
|
+
const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
|
|
13
15
|
const base_1 = require("./base");
|
|
14
16
|
const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
|
|
15
17
|
const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
|
|
16
|
-
const
|
|
17
|
-
function createServerConfig({ props, onLinksCollected
|
|
18
|
-
const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags,
|
|
19
|
-
const config = base_1.createBaseConfig(props, true);
|
|
18
|
+
const ssr_html_template_1 = tslib_1.__importDefault(require("./templates/ssr.html.template"));
|
|
19
|
+
async function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }) {
|
|
20
|
+
const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, siteConfig: { noIndex, trailingSlash, ssrTemplate }, } = props;
|
|
21
|
+
const config = await (0, base_1.createBaseConfig)(props, true);
|
|
20
22
|
const routesLocation = {};
|
|
21
23
|
// Array of paths to be rendered. Relative to output directory
|
|
22
24
|
const ssgPaths = routesPaths.map((str) => {
|
|
@@ -24,8 +26,8 @@ function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
|
24
26
|
routesLocation[ssgPath] = str;
|
|
25
27
|
return ssgPath;
|
|
26
28
|
});
|
|
27
|
-
const serverConfig = webpack_merge_1.default(config, {
|
|
28
|
-
target: `node${
|
|
29
|
+
const serverConfig = (0, webpack_merge_1.default)(config, {
|
|
30
|
+
target: `node${utils_1.NODE_MAJOR_VERSION}.${utils_1.NODE_MINOR_VERSION}`,
|
|
29
31
|
entry: {
|
|
30
32
|
main: path_1.default.resolve(__dirname, '../client/serverEntry.js'),
|
|
31
33
|
},
|
|
@@ -51,10 +53,23 @@ function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
|
51
53
|
preBodyTags,
|
|
52
54
|
postBodyTags,
|
|
53
55
|
onLinksCollected,
|
|
54
|
-
|
|
56
|
+
onHeadTagsCollected,
|
|
57
|
+
ssrTemplate: ssrTemplate ?? ssr_html_template_1.default,
|
|
55
58
|
noIndex,
|
|
59
|
+
DOCUSAURUS_VERSION: utils_1.DOCUSAURUS_VERSION,
|
|
56
60
|
},
|
|
57
61
|
paths: ssgPaths,
|
|
62
|
+
preferFoldersOutput: trailingSlash,
|
|
63
|
+
// When using "new URL('file.js', import.meta.url)", Webpack will emit
|
|
64
|
+
// __filename, and this plugin will throw. not sure the __filename value
|
|
65
|
+
// has any importance for this plugin, just using an empty string to
|
|
66
|
+
// avoid the error. See https://github.com/facebook/docusaurus/issues/4922
|
|
67
|
+
globals: { __filename: '' },
|
|
68
|
+
// Secret way to set SSR plugin concurrency option
|
|
69
|
+
// Waiting for feedback before documenting this officially?
|
|
70
|
+
concurrency: process.env.DOCUSAURUS_SSR_CONCURRENCY
|
|
71
|
+
? parseInt(process.env.DOCUSAURUS_SSR_CONCURRENCY, 10)
|
|
72
|
+
: undefined,
|
|
58
73
|
}),
|
|
59
74
|
// Show compilation progress bar.
|
|
60
75
|
new LogPlugin_1.default({
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
declare const _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta name=\"generator\" content=\"Docusaurus v<%= it.version %>\">\n <% if (it.noIndex) { %>\n <meta name=\"robots\" content=\"noindex, nofollow\" />\n <% } %>\n <%~ it.headTags %>\n <% it.metaAttributes.forEach((metaAttribute) => { %>\n <%~ metaAttribute %>\n <% }); %>\n <% it.stylesheets.forEach((stylesheet) => { %>\n <link rel=\"stylesheet\" href=\"<%= it.baseUrl %><%= stylesheet %>\" />\n <% }); %>\n <% it.scripts.forEach((script) => { %>\n <link rel=\"preload\" href=\"<%= it.baseUrl %><%= script %>\" as=\"script\">\n <% }); %>\n </head>\n <body <%~ it.bodyAttributes %>>\n <%~ it.preBodyTags %>\n <div id=\"__docusaurus\">\n <%~ it.appHtml %>\n </div>\n <% it.scripts.forEach((script) => { %>\n <script src=\"<%= it.baseUrl %><%= script %>\"></script>\n <% }); %>\n <%~ it.postBodyTags %>\n </body>\n</html>\n";
|
|
8
|
+
export default _default;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.default = `
|
|
9
10
|
<!DOCTYPE html>
|
|
10
11
|
<html <%~ it.htmlAttributes %>>
|
|
11
12
|
<head>
|
|
@@ -20,7 +21,7 @@ module.exports = `
|
|
|
20
21
|
<%~ metaAttribute %>
|
|
21
22
|
<% }); %>
|
|
22
23
|
<% it.stylesheets.forEach((stylesheet) => { %>
|
|
23
|
-
<link rel="stylesheet"
|
|
24
|
+
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
|
24
25
|
<% }); %>
|
|
25
26
|
<% it.scripts.forEach((script) => { %>
|
|
26
27
|
<link rel="preload" href="<%= it.baseUrl %><%= script %>" as="script">
|
|
@@ -32,7 +33,7 @@ module.exports = `
|
|
|
32
33
|
<%~ it.appHtml %>
|
|
33
34
|
</div>
|
|
34
35
|
<% it.scripts.forEach((script) => { %>
|
|
35
|
-
<script
|
|
36
|
+
<script src="<%= it.baseUrl %><%= script %>"></script>
|
|
36
37
|
<% }); %>
|
|
37
38
|
<%~ it.postBodyTags %>
|
|
38
39
|
</body>
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="node" />
|
|
8
|
-
import { Configuration, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
9
|
-
import { TransformOptions } from '@babel/core';
|
|
10
|
-
import {
|
|
11
|
-
export declare function getStyleLoaders(isServer: boolean,
|
|
8
|
+
import { type Configuration, type RuleSetRule, type WebpackPluginInstance } from 'webpack';
|
|
9
|
+
import type { TransformOptions } from '@babel/core';
|
|
10
|
+
import type { Plugin } from '@docusaurus/types';
|
|
11
|
+
export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
}): RuleSetRule[];
|
|
14
|
-
export declare function getCustomBabelConfigFilePath(siteDir: string): string | undefined
|
|
14
|
+
export declare function getCustomBabelConfigFilePath(siteDir: string): Promise<string | undefined>;
|
|
15
15
|
export declare function getBabelOptions({ isServer, babelOptions, }?: {
|
|
16
16
|
isServer?: boolean;
|
|
17
17
|
babelOptions?: TransformOptions | string;
|
|
@@ -26,35 +26,20 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
|
|
|
26
26
|
* @param config initial webpack config
|
|
27
27
|
* @param isServer indicates if this is a server webpack configuration
|
|
28
28
|
* @param jsLoader custom js loader config
|
|
29
|
+
* @param content content loaded by the plugin
|
|
29
30
|
* @returns final/ modified webpack config
|
|
30
31
|
*/
|
|
31
|
-
export declare function applyConfigureWebpack(configureWebpack:
|
|
32
|
-
export declare function applyConfigurePostCss(configurePostCss: NonNullable<
|
|
32
|
+
export declare function applyConfigureWebpack(configureWebpack: NonNullable<Plugin['configureWebpack']>, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
|
|
33
|
+
export declare function applyConfigurePostCss(configurePostCss: NonNullable<Plugin['configurePostCss']>, config: Configuration): Configuration;
|
|
34
|
+
declare global {
|
|
35
|
+
interface Error {
|
|
36
|
+
/** @see https://webpack.js.org/api/node/#error-handling */
|
|
37
|
+
details: unknown;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
33
40
|
export declare function compile(config: Configuration[]): Promise<void>;
|
|
34
|
-
declare
|
|
35
|
-
declare type FileLoaderUtils = {
|
|
36
|
-
loaders: {
|
|
37
|
-
file: (options: {
|
|
38
|
-
folder: AssetFolder;
|
|
39
|
-
}) => RuleSetRule;
|
|
40
|
-
url: (options: {
|
|
41
|
-
folder: AssetFolder;
|
|
42
|
-
}) => RuleSetRule;
|
|
43
|
-
inlineMarkdownImageFileLoader: string;
|
|
44
|
-
inlineMarkdownLinkFileLoader: string;
|
|
45
|
-
};
|
|
46
|
-
rules: {
|
|
47
|
-
images: () => RuleSetRule;
|
|
48
|
-
fonts: () => RuleSetRule;
|
|
49
|
-
media: () => RuleSetRule;
|
|
50
|
-
svg: () => RuleSetRule;
|
|
51
|
-
otherAssets: () => RuleSetRule;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
export declare function getFileLoaderUtils(): FileLoaderUtils;
|
|
55
|
-
export declare function getHttpsConfig(): boolean | {
|
|
41
|
+
export declare function getHttpsConfig(): Promise<boolean | {
|
|
56
42
|
cert: Buffer;
|
|
57
43
|
key: Buffer;
|
|
58
|
-
}
|
|
44
|
+
}>;
|
|
59
45
|
export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
|
|
60
|
-
export {};
|