@docusaurus/core 2.4.0 → 3.0.0-alpha.0
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/bin/beforeCli.mjs +31 -5
- package/bin/docusaurus.mjs +9 -1
- package/lib/babel/preset.js +6 -1
- package/lib/client/BaseUrlIssueBanner/index.d.ts +0 -7
- package/lib/client/BaseUrlIssueBanner/index.js +12 -22
- package/lib/client/BaseUrlIssueBanner/styles.module.css +1 -1
- package/lib/client/ClientLifecyclesDispatcher.js +2 -2
- package/lib/client/LinksCollector.d.ts +2 -2
- package/lib/client/PendingNavigation.d.ts +2 -2
- package/lib/client/clientEntry.js +27 -13
- package/lib/client/exports/ErrorBoundary.d.ts +1 -1
- package/lib/client/exports/Link.d.ts +1 -1
- package/lib/client/exports/Link.js +1 -1
- package/lib/client/exports/useIsomorphicLayoutEffect.d.ts +21 -0
- package/lib/client/exports/useIsomorphicLayoutEffect.js +24 -0
- package/lib/client/serverEntry.js +26 -18
- package/lib/{webpack/plugins/LogPlugin.d.ts → client/serverRenderer.d.ts} +2 -5
- package/lib/client/serverRenderer.js +61 -0
- package/lib/commands/build.d.ts +2 -1
- package/lib/commands/build.js +9 -3
- package/lib/commands/deploy.d.ts +1 -1
- package/lib/commands/serve.d.ts +1 -1
- package/lib/commands/start.d.ts +1 -1
- package/lib/commands/start.js +15 -5
- package/lib/commands/swizzle/actions.d.ts +2 -2
- package/lib/commands/swizzle/common.d.ts +3 -3
- package/lib/commands/swizzle/components.d.ts +1 -1
- package/lib/commands/writeTranslations.d.ts +1 -1
- package/lib/server/configValidation.js +19 -1
- package/lib/server/getHostPort.d.ts +1 -1
- package/lib/server/index.d.ts +1 -1
- package/lib/server/plugins/configs.d.ts +2 -2
- package/lib/server/plugins/routeConfig.js +3 -1
- package/lib/server/plugins/synthetic.js +1 -2
- package/lib/server/routes.d.ts +1 -1
- package/lib/server/routes.js +2 -18
- package/lib/server/translations/translations.d.ts +2 -2
- package/lib/server/translations/translationsExtractor.d.ts +1 -1
- package/lib/webpack/aliases/index.d.ts +1 -1
- package/lib/webpack/client.d.ts +1 -1
- package/lib/webpack/client.js +10 -4
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +1 -1
- package/lib/webpack/plugins/WaitPlugin.d.ts +1 -1
- package/lib/webpack/server.js +2 -2
- package/lib/webpack/templates/ssr.html.template.d.ts +1 -1
- package/lib/webpack/templates/ssr.html.template.js +2 -7
- package/lib/webpack/utils.d.ts +3 -1
- package/lib/webpack/utils.js +26 -8
- package/package.json +51 -51
- package/lib/webpack/plugins/LogPlugin.js +0 -33
package/lib/commands/start.js
CHANGED
|
@@ -89,7 +89,7 @@ async function start(siteDirParam = '.', cliOptions = {}) {
|
|
|
89
89
|
...{ pollingOptions },
|
|
90
90
|
});
|
|
91
91
|
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) => fsWatcher.on(event, reload));
|
|
92
|
-
let config = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify), {
|
|
92
|
+
let config = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify, false), {
|
|
93
93
|
watchOptions: {
|
|
94
94
|
ignored: /node_modules\/(?!@docusaurus)/,
|
|
95
95
|
poll: cliOptions.poll,
|
|
@@ -124,16 +124,22 @@ async function start(siteDirParam = '.', cliOptions = {}) {
|
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
const compiler = (0, webpack_1.default)(config);
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
compiler.hooks.done.tap('done', (stats) => {
|
|
128
|
+
const errorsWarnings = stats.toJson('errors-warnings');
|
|
129
|
+
const statsErrorMessage = (0, utils_2.formatStatsErrorMessage)(errorsWarnings);
|
|
130
|
+
if (statsErrorMessage) {
|
|
131
|
+
console.error(statsErrorMessage);
|
|
132
|
+
}
|
|
133
|
+
(0, utils_2.printStatsWarnings)(errorsWarnings);
|
|
134
|
+
if (process.env.E2E_TEST) {
|
|
129
135
|
if (stats.hasErrors()) {
|
|
130
136
|
logger_1.default.error('E2E_TEST: Project has compiler errors.');
|
|
131
137
|
process.exit(1);
|
|
132
138
|
}
|
|
133
139
|
logger_1.default.success('E2E_TEST: Project can compile.');
|
|
134
140
|
process.exit(0);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
137
143
|
// https://webpack.js.org/configuration/dev-server
|
|
138
144
|
const defaultDevServerConfig = {
|
|
139
145
|
hot: cliOptions.hotOnly ? 'only' : true,
|
|
@@ -144,6 +150,10 @@ async function start(siteDirParam = '.', cliOptions = {}) {
|
|
|
144
150
|
warnings: false,
|
|
145
151
|
errors: true,
|
|
146
152
|
},
|
|
153
|
+
webSocketURL: {
|
|
154
|
+
hostname: '0.0.0.0',
|
|
155
|
+
port: 0,
|
|
156
|
+
},
|
|
147
157
|
},
|
|
148
158
|
headers: {
|
|
149
159
|
'access-control-allow-origin': '*',
|
|
@@ -8,13 +8,13 @@ import type { SwizzleAction, SwizzleComponentConfig } from '@docusaurus/types';
|
|
|
8
8
|
import type { SwizzleCLIOptions } from './common';
|
|
9
9
|
export declare const SwizzleActions: SwizzleAction[];
|
|
10
10
|
export declare function getAction(componentConfig: SwizzleComponentConfig, options: Pick<SwizzleCLIOptions, 'wrap' | 'eject'>): Promise<SwizzleAction>;
|
|
11
|
-
export
|
|
11
|
+
export type ActionParams = {
|
|
12
12
|
siteDir: string;
|
|
13
13
|
themePath: string;
|
|
14
14
|
componentName: string;
|
|
15
15
|
typescript: boolean;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type ActionResult = {
|
|
18
18
|
createdFiles: string[];
|
|
19
19
|
};
|
|
20
20
|
export declare function eject({ siteDir, themePath, componentName, typescript, }: ActionParams): Promise<ActionResult>;
|
|
@@ -14,14 +14,14 @@ export declare function actionStatusColor(status: SwizzleActionStatus, str: stri
|
|
|
14
14
|
export declare function actionStatusSuffix(status: SwizzleActionStatus, options?: {
|
|
15
15
|
partiallySafe?: boolean;
|
|
16
16
|
}): string;
|
|
17
|
-
export
|
|
17
|
+
export type SwizzlePlugin = {
|
|
18
18
|
instance: InitializedPlugin;
|
|
19
19
|
plugin: NormalizedPluginConfig;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type SwizzleContext = {
|
|
22
22
|
plugins: SwizzlePlugin[];
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type SwizzleCLIOptions = {
|
|
25
25
|
typescript: boolean;
|
|
26
26
|
danger: boolean;
|
|
27
27
|
list: boolean;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { SwizzleAction, SwizzleActionStatus, SwizzleComponentConfig, SwizzleConfig } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export type ThemeComponents = {
|
|
9
9
|
themeName: string;
|
|
10
10
|
all: string[];
|
|
11
11
|
getConfig: (component: string) => SwizzleComponentConfig;
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type LoadContextOptions } from '../server';
|
|
8
8
|
import { type WriteTranslationsOptions } from '../server/translations/translations';
|
|
9
|
-
export
|
|
9
|
+
export type WriteTranslationsCLIOptions = Pick<LoadContextOptions, 'config' | 'locale'> & WriteTranslationsOptions;
|
|
10
10
|
export declare function writeTranslations(siteDirParam?: string, options?: Partial<WriteTranslationsCLIOptions>): Promise<void>;
|
|
@@ -37,6 +37,12 @@ exports.DEFAULT_CONFIG = {
|
|
|
37
37
|
staticDirectories: [utils_1.DEFAULT_STATIC_DIR_NAME],
|
|
38
38
|
markdown: {
|
|
39
39
|
mermaid: false,
|
|
40
|
+
preprocessor: undefined,
|
|
41
|
+
mdx1Compat: {
|
|
42
|
+
comments: true,
|
|
43
|
+
admonitions: true,
|
|
44
|
+
headingIds: true,
|
|
45
|
+
},
|
|
40
46
|
},
|
|
41
47
|
};
|
|
42
48
|
function createPluginSchema(theme) {
|
|
@@ -125,7 +131,10 @@ const SiteUrlSchema = utils_validation_1.Joi.string()
|
|
|
125
131
|
});
|
|
126
132
|
// TODO move to @docusaurus/utils-validation
|
|
127
133
|
exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
128
|
-
baseUrl: utils_validation_1.Joi
|
|
134
|
+
baseUrl: utils_validation_1.Joi
|
|
135
|
+
// Weird Joi trick needed, otherwise value '' is not normalized...
|
|
136
|
+
.alternatives()
|
|
137
|
+
.try(utils_validation_1.Joi.string().required().allow(''))
|
|
129
138
|
.required()
|
|
130
139
|
.custom((value) => (0, utils_1.addLeadingSlash)((0, utils_1.addTrailingSlash)(value))),
|
|
131
140
|
baseUrlIssueBanner: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.baseUrlIssueBanner),
|
|
@@ -202,6 +211,15 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
|
202
211
|
}).optional(),
|
|
203
212
|
markdown: utils_validation_1.Joi.object({
|
|
204
213
|
mermaid: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.markdown.mermaid),
|
|
214
|
+
preprocessor: utils_validation_1.Joi.function()
|
|
215
|
+
.arity(1)
|
|
216
|
+
.optional()
|
|
217
|
+
.default(() => exports.DEFAULT_CONFIG.markdown.preprocessor),
|
|
218
|
+
mdx1Compat: utils_validation_1.Joi.object({
|
|
219
|
+
comments: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.markdown.mdx1Compat.comments),
|
|
220
|
+
admonitions: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.markdown.mdx1Compat.admonitions),
|
|
221
|
+
headingIds: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.markdown.mdx1Compat.headingIds),
|
|
222
|
+
}).default(exports.DEFAULT_CONFIG.markdown.mdx1Compat),
|
|
205
223
|
}).default(exports.DEFAULT_CONFIG.markdown),
|
|
206
224
|
}).messages({
|
|
207
225
|
'docusaurus.configValidationWarning': 'Docusaurus config validation warning. Field {#label}: {#warningMessage}',
|
package/lib/server/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { LoadContext, Props } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export type LoadContextOptions = {
|
|
9
9
|
/** Usually the CWD; can be overridden with command argument. */
|
|
10
10
|
siteDir: string;
|
|
11
11
|
/** Custom output directory. Can be customized with `--out-dir` option */
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { LoadContext, PluginModule, PluginOptions } from '@docusaurus/types';
|
|
8
|
-
|
|
8
|
+
type ImportedPluginModule = PluginModule & {
|
|
9
9
|
default?: PluginModule;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type NormalizedPluginConfig = {
|
|
12
12
|
/**
|
|
13
13
|
* The default export of the plugin module, or alternatively, what's provided
|
|
14
14
|
* in the config file as inline plugins. Note that if a file is like:
|
|
@@ -48,7 +48,9 @@ function sortConfig(routeConfigs, baseUrl = '/') {
|
|
|
48
48
|
return a.path.localeCompare(b.path);
|
|
49
49
|
});
|
|
50
50
|
routeConfigs.forEach((routeConfig) => {
|
|
51
|
-
routeConfig.routes
|
|
51
|
+
if (routeConfig.routes) {
|
|
52
|
+
sortConfig(routeConfig.routes, baseUrl);
|
|
53
|
+
}
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
exports.sortConfig = sortConfig;
|
|
@@ -68,7 +68,7 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
|
68
68
|
version: { type: 'synthetic' },
|
|
69
69
|
// Synthetic, the path doesn't matter much
|
|
70
70
|
path: '.',
|
|
71
|
-
configureWebpack(config
|
|
71
|
+
configureWebpack(config) {
|
|
72
72
|
// We need the mdx fallback loader to exclude files that were already
|
|
73
73
|
// processed by content plugins mdx loaders. This works, but a bit
|
|
74
74
|
// hacky... Not sure there's a way to handle that differently in webpack
|
|
@@ -96,7 +96,6 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
|
96
96
|
test: /\.mdx?$/i,
|
|
97
97
|
exclude: getMDXFallbackExcludedPaths(),
|
|
98
98
|
use: [
|
|
99
|
-
getJSLoader({ isServer }),
|
|
100
99
|
{
|
|
101
100
|
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
102
101
|
options: mdxLoaderOptions,
|
package/lib/server/routes.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { RouteConfig, RouteChunkNames, ReportingSeverity } from '@docusaurus/types';
|
|
8
|
-
|
|
8
|
+
type LoadedRoutes = {
|
|
9
9
|
/** Serialized routes config that can be directly emitted into temp file. */
|
|
10
10
|
routesConfig: string;
|
|
11
11
|
/** @see {ChunkNames} */
|
package/lib/server/routes.js
CHANGED
|
@@ -74,24 +74,8 @@ ${indent(subroutesCodeStrings.join(',\n'))}
|
|
|
74
74
|
]`);
|
|
75
75
|
}
|
|
76
76
|
Object.entries(props).forEach(([propName, propValue]) => {
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
// Pre-sanitation to prevent injection
|
|
80
|
-
if (/[.,;:}/\s]/.test(key)) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
// If this key can be used in an expression like ({a:0}).a
|
|
85
|
-
// eslint-disable-next-line no-eval
|
|
86
|
-
eval(`({${key}:0}).${key}`);
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
})(propName);
|
|
93
|
-
// Escape quotes as well
|
|
94
|
-
const key = shouldQuote ? JSON.stringify(propName) : propName;
|
|
77
|
+
const isIdentifier = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(propName);
|
|
78
|
+
const key = isIdentifier ? propName : JSON.stringify(propName);
|
|
95
79
|
parts.push(`${key}: ${JSON.stringify(propValue)}`);
|
|
96
80
|
});
|
|
97
81
|
return `{
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { TranslationFileContent, TranslationFile, CodeTranslations, InitializedPlugin } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export type WriteTranslationsOptions = {
|
|
9
9
|
override?: boolean;
|
|
10
10
|
messagePrefix?: string;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type TranslationContext = {
|
|
13
13
|
localizationDir: string;
|
|
14
14
|
};
|
|
15
15
|
export declare function readCodeTranslationFileContent(context: TranslationContext): Promise<TranslationFileContent | undefined>;
|
|
@@ -8,7 +8,7 @@ import { type TransformOptions } from '@babel/core';
|
|
|
8
8
|
import type { InitializedPlugin, TranslationFileContent } from '@docusaurus/types';
|
|
9
9
|
export declare function globSourceCodeFilePaths(dirPaths: string[]): Promise<string[]>;
|
|
10
10
|
export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins: InitializedPlugin[], babelOptions: TransformOptions, extraSourceCodeFilePaths?: string[]): Promise<TranslationFileContent>;
|
|
11
|
-
|
|
11
|
+
type SourceCodeFileTranslations = {
|
|
12
12
|
sourceCodeFilePath: string;
|
|
13
13
|
translations: TranslationFileContent;
|
|
14
14
|
warnings: string[];
|
package/lib/webpack/client.d.ts
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Props } from '@docusaurus/types';
|
|
8
8
|
import type { Configuration } from 'webpack';
|
|
9
|
-
export default function createClientConfig(props: Props, minify?: boolean): Promise<Configuration>;
|
|
9
|
+
export default function createClientConfig(props: Props, minify?: boolean, hydrate?: boolean): Promise<Configuration>;
|
package/lib/webpack/client.js
CHANGED
|
@@ -10,10 +10,12 @@ const tslib_1 = require("tslib");
|
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
13
|
+
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
14
|
+
const webpack_1 = require("webpack");
|
|
13
15
|
const base_1 = require("./base");
|
|
14
16
|
const ChunkAssetPlugin_1 = tslib_1.__importDefault(require("./plugins/ChunkAssetPlugin"));
|
|
15
|
-
const
|
|
16
|
-
async function createClientConfig(props, minify = true) {
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
async function createClientConfig(props, minify = true, hydrate = true) {
|
|
17
19
|
const isBuilding = process.argv[2] === 'build';
|
|
18
20
|
const config = await (0, base_1.createBaseConfig)(props, false, minify);
|
|
19
21
|
const clientConfig = (0, webpack_merge_1.default)(config, {
|
|
@@ -27,9 +29,12 @@ async function createClientConfig(props, minify = true) {
|
|
|
27
29
|
runtimeChunk: true,
|
|
28
30
|
},
|
|
29
31
|
plugins: [
|
|
32
|
+
new webpack_1.DefinePlugin({
|
|
33
|
+
'process.env.HYDRATE_CLIENT_ENTRY': JSON.stringify(hydrate),
|
|
34
|
+
}),
|
|
30
35
|
new ChunkAssetPlugin_1.default(),
|
|
31
36
|
// Show compilation progress bar and build time.
|
|
32
|
-
new
|
|
37
|
+
new webpackbar_1.default({
|
|
33
38
|
name: 'Client',
|
|
34
39
|
}),
|
|
35
40
|
],
|
|
@@ -41,7 +46,8 @@ async function createClientConfig(props, minify = true) {
|
|
|
41
46
|
apply: (compiler) => {
|
|
42
47
|
compiler.hooks.done.tap('client:done', (stats) => {
|
|
43
48
|
if (stats.hasErrors()) {
|
|
44
|
-
|
|
49
|
+
const errorsWarnings = stats.toJson('errors-warnings');
|
|
50
|
+
logger_1.default.error(`Client bundle compiled with errors therefore further build is impossible.\n${(0, utils_1.formatStatsErrorMessage)(errorsWarnings)}`);
|
|
45
51
|
process.exit(1);
|
|
46
52
|
}
|
|
47
53
|
});
|
package/lib/webpack/server.js
CHANGED
|
@@ -12,9 +12,9 @@ const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
// Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
|
|
14
14
|
const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
|
|
15
|
+
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
15
16
|
const base_1 = require("./base");
|
|
16
17
|
const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
|
|
17
|
-
const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
|
|
18
18
|
const ssr_html_template_1 = tslib_1.__importDefault(require("./templates/ssr.html.template"));
|
|
19
19
|
async function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }) {
|
|
20
20
|
const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, siteConfig: { noIndex, trailingSlash, ssrTemplate }, } = props;
|
|
@@ -72,7 +72,7 @@ async function createServerConfig({ props, onLinksCollected, onHeadTagsCollected
|
|
|
72
72
|
: undefined,
|
|
73
73
|
}),
|
|
74
74
|
// Show compilation progress bar.
|
|
75
|
-
new
|
|
75
|
+
new webpackbar_1.default({
|
|
76
76
|
name: 'Server',
|
|
77
77
|
color: 'yellow',
|
|
78
78
|
}),
|
|
@@ -4,5 +4,5 @@
|
|
|
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
|
-
declare const _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"generator\" content=\"Docusaurus v<%= it.version %>\">\n <% it.metaAttributes.forEach((metaAttribute) => { %>\n <%~ metaAttribute %>\n <% }); %>\n <%~ it.headTags %>\n <% it.stylesheets.forEach((stylesheet) => { %>\n <link rel=\"stylesheet\" href=\"<%= it.baseUrl %><%= stylesheet %>\" />\n <% }); %>\n <% it.scripts.forEach((script) => { %>\n <
|
|
7
|
+
declare const _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"generator\" content=\"Docusaurus v<%= it.version %>\">\n <% it.metaAttributes.forEach((metaAttribute) => { %>\n <%~ metaAttribute %>\n <% }); %>\n <%~ it.headTags %>\n <% it.stylesheets.forEach((stylesheet) => { %>\n <link rel=\"stylesheet\" href=\"<%= it.baseUrl %><%= stylesheet %>\" />\n <% }); %>\n <% it.scripts.forEach((script) => { %>\n <script src=\"<%= it.baseUrl %><%= script %>\" defer></script>\n <% }); %>\n </head>\n <body <%~ it.bodyAttributes %>>\n <%~ it.preBodyTags %>\n <div id=\"__docusaurus\"><%~ it.appHtml %></div>\n <%~ it.postBodyTags %>\n </body>\n</html>\n";
|
|
8
8
|
export default _default;
|
|
@@ -20,17 +20,12 @@ exports.default = `
|
|
|
20
20
|
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
|
21
21
|
<% }); %>
|
|
22
22
|
<% it.scripts.forEach((script) => { %>
|
|
23
|
-
<
|
|
23
|
+
<script src="<%= it.baseUrl %><%= script %>" defer></script>
|
|
24
24
|
<% }); %>
|
|
25
25
|
</head>
|
|
26
26
|
<body <%~ it.bodyAttributes %>>
|
|
27
27
|
<%~ it.preBodyTags %>
|
|
28
|
-
<div id="__docusaurus">
|
|
29
|
-
<%~ it.appHtml %>
|
|
30
|
-
</div>
|
|
31
|
-
<% it.scripts.forEach((script) => { %>
|
|
32
|
-
<script src="<%= it.baseUrl %><%= script %>"></script>
|
|
33
|
-
<% }); %>
|
|
28
|
+
<div id="__docusaurus"><%~ it.appHtml %></div>
|
|
34
29
|
<%~ it.postBodyTags %>
|
|
35
30
|
</body>
|
|
36
31
|
</html>
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="node" />
|
|
8
|
-
import { type Configuration, type RuleSetRule, type WebpackPluginInstance } from 'webpack';
|
|
8
|
+
import webpack, { type Configuration, type RuleSetRule, type WebpackPluginInstance } from 'webpack';
|
|
9
9
|
import type { TransformOptions } from '@babel/core';
|
|
10
10
|
import type { Plugin } from '@docusaurus/types';
|
|
11
|
+
export declare function formatStatsErrorMessage(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): string | undefined;
|
|
12
|
+
export declare function printStatsWarnings(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): void;
|
|
11
13
|
export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
|
|
12
14
|
[key: string]: unknown;
|
|
13
15
|
}): RuleSetRule[];
|
package/lib/webpack/utils.js
CHANGED
|
@@ -6,7 +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.getMinimizer = exports.getHttpsConfig = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
|
|
9
|
+
exports.getMinimizer = exports.getHttpsConfig = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = exports.printStatsWarnings = exports.formatStatsErrorMessage = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -18,6 +18,28 @@ const webpack_merge_1 = require("webpack-merge");
|
|
|
18
18
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
19
19
|
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
20
20
|
const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
|
|
21
|
+
const formatWebpackMessages_1 = tslib_1.__importDefault(require("react-dev-utils/formatWebpackMessages"));
|
|
22
|
+
function formatStatsErrorMessage(statsJson) {
|
|
23
|
+
if (statsJson?.errors?.length) {
|
|
24
|
+
// TODO formatWebpackMessages does not print stack-traces
|
|
25
|
+
// Also the error causal chain is lost here
|
|
26
|
+
// We log the stacktrace inside serverEntry.tsx for now (not ideal)
|
|
27
|
+
const { errors } = (0, formatWebpackMessages_1.default)(statsJson);
|
|
28
|
+
return errors
|
|
29
|
+
.map((str) => logger_1.default.red(str))
|
|
30
|
+
.join(`\n\n${logger_1.default.yellow('--------------------------')}\n\n`);
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
exports.formatStatsErrorMessage = formatStatsErrorMessage;
|
|
35
|
+
function printStatsWarnings(statsJson) {
|
|
36
|
+
if (statsJson?.warnings?.length) {
|
|
37
|
+
statsJson.warnings?.forEach((warning) => {
|
|
38
|
+
logger_1.default.warn(warning);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.printStatsWarnings = printStatsWarnings;
|
|
21
43
|
// Utility method to get style loaders
|
|
22
44
|
function getStyleLoaders(isServer, cssOptionsArg = {}) {
|
|
23
45
|
const cssOptions = {
|
|
@@ -177,13 +199,10 @@ function compile(config) {
|
|
|
177
199
|
// Let plugins consume all the stats
|
|
178
200
|
const errorsWarnings = stats?.toJson('errors-warnings');
|
|
179
201
|
if (stats?.hasErrors()) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (errorsWarnings && stats?.hasWarnings()) {
|
|
183
|
-
errorsWarnings.warnings?.forEach((warning) => {
|
|
184
|
-
logger_1.default.warn(warning);
|
|
185
|
-
});
|
|
202
|
+
const statsErrorMessage = formatStatsErrorMessage(errorsWarnings);
|
|
203
|
+
reject(new Error(`Failed to compile due to Webpack errors.\n${statsErrorMessage}`));
|
|
186
204
|
}
|
|
205
|
+
printStatsWarnings(errorsWarnings);
|
|
187
206
|
// Webpack 5 requires calling close() so that persistent caching works
|
|
188
207
|
// See https://github.com/webpack/webpack.js.org/pull/4775
|
|
189
208
|
compiler.close((errClose) => {
|
|
@@ -273,7 +292,6 @@ function getMinimizer(useSimpleCssMinifier = false) {
|
|
|
273
292
|
},
|
|
274
293
|
compress: {
|
|
275
294
|
ecma: 5,
|
|
276
|
-
warnings: false,
|
|
277
295
|
},
|
|
278
296
|
mangle: {
|
|
279
297
|
safari10: true,
|
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
|
+
"version": "3.0.0-alpha.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,99 +33,99 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@babel/core": "^7.
|
|
37
|
-
"@babel/generator": "^7.
|
|
36
|
+
"@babel/core": "^7.20.12",
|
|
37
|
+
"@babel/generator": "^7.21.1",
|
|
38
38
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
39
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
40
|
-
"@babel/preset-env": "^7.
|
|
39
|
+
"@babel/plugin-transform-runtime": "^7.21.0",
|
|
40
|
+
"@babel/preset-env": "^7.20.2",
|
|
41
41
|
"@babel/preset-react": "^7.18.6",
|
|
42
|
-
"@babel/preset-typescript": "^7.
|
|
43
|
-
"@babel/runtime": "^7.
|
|
44
|
-
"@babel/runtime-corejs3": "^7.
|
|
45
|
-
"@babel/traverse": "^7.
|
|
46
|
-
"@docusaurus/cssnano-preset": "
|
|
47
|
-
"@docusaurus/logger": "
|
|
48
|
-
"@docusaurus/mdx-loader": "
|
|
42
|
+
"@babel/preset-typescript": "^7.21.0",
|
|
43
|
+
"@babel/runtime": "^7.21.0",
|
|
44
|
+
"@babel/runtime-corejs3": "^7.21.0",
|
|
45
|
+
"@babel/traverse": "^7.21.2",
|
|
46
|
+
"@docusaurus/cssnano-preset": "3.0.0-alpha.0",
|
|
47
|
+
"@docusaurus/logger": "3.0.0-alpha.0",
|
|
48
|
+
"@docusaurus/mdx-loader": "3.0.0-alpha.0",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "
|
|
51
|
-
"@docusaurus/utils-common": "
|
|
52
|
-
"@docusaurus/utils-validation": "
|
|
50
|
+
"@docusaurus/utils": "3.0.0-alpha.0",
|
|
51
|
+
"@docusaurus/utils-common": "3.0.0-alpha.0",
|
|
52
|
+
"@docusaurus/utils-validation": "3.0.0-alpha.0",
|
|
53
53
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.7",
|
|
54
|
-
"@svgr/webpack": "^6.
|
|
55
|
-
"autoprefixer": "^10.4.
|
|
56
|
-
"babel-loader": "^
|
|
54
|
+
"@svgr/webpack": "^6.5.1",
|
|
55
|
+
"autoprefixer": "^10.4.13",
|
|
56
|
+
"babel-loader": "^9.1.2",
|
|
57
57
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
58
58
|
"boxen": "^6.2.1",
|
|
59
59
|
"chalk": "^4.1.2",
|
|
60
60
|
"chokidar": "^3.5.3",
|
|
61
|
-
"clean-css": "^5.3.
|
|
62
|
-
"cli-table3": "^0.6.
|
|
61
|
+
"clean-css": "^5.3.2",
|
|
62
|
+
"cli-table3": "^0.6.3",
|
|
63
63
|
"combine-promises": "^1.1.0",
|
|
64
64
|
"commander": "^5.1.0",
|
|
65
65
|
"copy-webpack-plugin": "^11.0.0",
|
|
66
|
-
"core-js": "^3.
|
|
67
|
-
"css-loader": "^6.7.
|
|
68
|
-
"css-minimizer-webpack-plugin": "^4.
|
|
69
|
-
"cssnano": "^5.1.
|
|
66
|
+
"core-js": "^3.29.0",
|
|
67
|
+
"css-loader": "^6.7.3",
|
|
68
|
+
"css-minimizer-webpack-plugin": "^4.2.2",
|
|
69
|
+
"cssnano": "^5.1.15",
|
|
70
70
|
"del": "^6.1.1",
|
|
71
|
-
"detect-port": "^1.
|
|
71
|
+
"detect-port": "^1.5.1",
|
|
72
72
|
"escape-html": "^1.0.3",
|
|
73
|
-
"eta": "^2.0.
|
|
73
|
+
"eta": "^2.0.1",
|
|
74
74
|
"file-loader": "^6.2.0",
|
|
75
|
-
"fs-extra": "^
|
|
76
|
-
"html-minifier-terser": "^
|
|
75
|
+
"fs-extra": "^11.1.0",
|
|
76
|
+
"html-minifier-terser": "^7.1.0",
|
|
77
77
|
"html-tags": "^3.2.0",
|
|
78
78
|
"html-webpack-plugin": "^5.5.0",
|
|
79
79
|
"import-fresh": "^3.3.0",
|
|
80
80
|
"leven": "^3.1.0",
|
|
81
81
|
"lodash": "^4.17.21",
|
|
82
|
-
"mini-css-extract-plugin": "^2.
|
|
83
|
-
"postcss": "^8.4.
|
|
84
|
-
"postcss-loader": "^7.0.
|
|
82
|
+
"mini-css-extract-plugin": "^2.7.3",
|
|
83
|
+
"postcss": "^8.4.21",
|
|
84
|
+
"postcss-loader": "^7.0.2",
|
|
85
85
|
"prompts": "^2.4.2",
|
|
86
86
|
"react-dev-utils": "^12.0.1",
|
|
87
87
|
"react-helmet-async": "^1.3.0",
|
|
88
88
|
"react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
|
|
89
89
|
"react-loadable-ssr-addon-v5-slorber": "^1.0.1",
|
|
90
|
-
"react-router": "^5.3.
|
|
90
|
+
"react-router": "^5.3.4",
|
|
91
91
|
"react-router-config": "^5.1.1",
|
|
92
|
-
"react-router-dom": "^5.3.
|
|
92
|
+
"react-router-dom": "^5.3.4",
|
|
93
93
|
"rtl-detect": "^1.0.4",
|
|
94
|
-
"semver": "^7.3.
|
|
95
|
-
"serve-handler": "^6.1.
|
|
94
|
+
"semver": "^7.3.8",
|
|
95
|
+
"serve-handler": "^6.1.5",
|
|
96
96
|
"shelljs": "^0.8.5",
|
|
97
|
-
"terser-webpack-plugin": "^5.3.
|
|
98
|
-
"tslib": "^2.
|
|
99
|
-
"update-notifier": "^
|
|
97
|
+
"terser-webpack-plugin": "^5.3.7",
|
|
98
|
+
"tslib": "^2.5.0",
|
|
99
|
+
"update-notifier": "^6.0.2",
|
|
100
100
|
"url-loader": "^4.1.1",
|
|
101
|
-
"wait-on": "^
|
|
102
|
-
"webpack": "^5.
|
|
103
|
-
"webpack-bundle-analyzer": "^4.
|
|
104
|
-
"webpack-dev-server": "^4.
|
|
101
|
+
"wait-on": "^7.0.1",
|
|
102
|
+
"webpack": "^5.76.0",
|
|
103
|
+
"webpack-bundle-analyzer": "^4.8.0",
|
|
104
|
+
"webpack-dev-server": "^4.11.1",
|
|
105
105
|
"webpack-merge": "^5.8.0",
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "
|
|
110
|
-
"@docusaurus/types": "
|
|
109
|
+
"@docusaurus/module-type-aliases": "3.0.0-alpha.0",
|
|
110
|
+
"@docusaurus/types": "3.0.0-alpha.0",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
|
-
"@types/react-dom": "^18.0.
|
|
112
|
+
"@types/react-dom": "^18.0.11",
|
|
113
113
|
"@types/react-router-config": "^5.0.6",
|
|
114
114
|
"@types/rtl-detect": "^1.0.0",
|
|
115
115
|
"@types/serve-handler": "^6.1.1",
|
|
116
|
-
"@types/update-notifier": "^
|
|
116
|
+
"@types/update-notifier": "^6.0.2",
|
|
117
117
|
"@types/wait-on": "^5.3.1",
|
|
118
|
-
"@types/webpack-bundle-analyzer": "^4.
|
|
119
|
-
"react-test-renderer": "^
|
|
118
|
+
"@types/webpack-bundle-analyzer": "^4.6.0",
|
|
119
|
+
"react-test-renderer": "^18.0.0",
|
|
120
120
|
"tmp-promise": "^3.0.3",
|
|
121
121
|
"tree-node-cli": "^1.6.0"
|
|
122
122
|
},
|
|
123
123
|
"peerDependencies": {
|
|
124
|
-
"react": "^
|
|
125
|
-
"react-dom": "^
|
|
124
|
+
"react": "^18.0.0",
|
|
125
|
+
"react-dom": "^18.0.0"
|
|
126
126
|
},
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": ">=16.14"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "7327f7ff880ed97ad7855744e59c9c55d467a950"
|
|
131
131
|
}
|