@docusaurus/core 3.1.0 → 3.2.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/docusaurus.mjs +10 -5
- package/lib/client/BrokenLinksContext.js +2 -2
- package/lib/client/exports/Link.js +10 -2
- package/lib/client/{serverRenderer.d.ts → renderToHtml.d.ts} +1 -1
- package/lib/client/{serverRenderer.js → renderToHtml.js} +1 -1
- package/lib/client/serverEntry.d.ts +3 -4
- package/lib/client/serverEntry.js +12 -113
- package/lib/client/theme-fallback/Error/index.js +22 -8
- package/lib/commands/build.d.ts +3 -3
- package/lib/commands/build.js +133 -112
- package/lib/commands/deploy.d.ts +2 -2
- package/lib/commands/deploy.js +3 -3
- package/lib/commands/external.js +2 -2
- package/lib/commands/serve.d.ts +2 -2
- package/lib/commands/serve.js +4 -4
- package/lib/commands/{start.d.ts → start/start.d.ts} +3 -3
- package/lib/commands/start/start.js +47 -0
- package/lib/commands/start/utils.d.ts +31 -0
- package/lib/commands/start/utils.js +87 -0
- package/lib/commands/start/watcher.d.ts +42 -0
- package/lib/commands/start/watcher.js +78 -0
- package/lib/commands/start/webpack.d.ts +15 -0
- package/lib/commands/start/webpack.js +133 -0
- package/lib/commands/swizzle/common.d.ts +1 -0
- package/lib/commands/swizzle/common.js +1 -0
- package/lib/commands/swizzle/context.js +2 -2
- package/lib/commands/swizzle/index.js +32 -3
- package/lib/commands/writeHeadingIds.js +2 -2
- package/lib/commands/writeTranslations.d.ts +2 -2
- package/lib/commands/writeTranslations.js +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/server/brokenLinks.js +126 -39
- package/lib/server/clientModules.d.ts +1 -1
- package/lib/server/clientModules.js +3 -3
- package/lib/server/codegen/codegen.d.ts +20 -0
- package/lib/server/codegen/codegen.js +65 -0
- package/lib/server/codegen/codegenRoutes.d.ts +49 -0
- package/lib/server/codegen/codegenRoutes.js +190 -0
- package/lib/server/configValidation.js +6 -4
- package/lib/server/getHostPort.js +4 -1
- package/lib/server/i18n.d.ts +2 -2
- package/lib/server/i18n.js +20 -2
- package/lib/server/plugins/actions.d.ts +19 -0
- package/lib/server/plugins/actions.js +62 -0
- package/lib/server/plugins/init.js +3 -3
- package/lib/server/plugins/plugins.d.ts +21 -0
- package/lib/server/plugins/plugins.js +188 -0
- package/lib/server/plugins/pluginsUtils.d.ts +16 -0
- package/lib/server/plugins/pluginsUtils.js +75 -0
- package/lib/server/plugins/routeConfig.d.ts +1 -1
- package/lib/server/plugins/routeConfig.js +4 -4
- package/lib/server/plugins/synthetic.d.ts +3 -3
- package/lib/server/plugins/synthetic.js +0 -2
- package/lib/server/routes.d.ts +3 -45
- package/lib/server/routes.js +21 -165
- package/lib/server/{index.d.ts → site.d.ts} +12 -5
- package/lib/server/site.js +164 -0
- package/lib/server/siteMetadata.d.ts +5 -4
- package/lib/server/siteMetadata.js +14 -10
- package/lib/server/translations/translations.d.ts +9 -2
- package/lib/server/translations/translations.js +21 -4
- package/lib/server/utils.d.ts +0 -2
- package/lib/server/utils.js +1 -9
- package/lib/ssg.d.ts +31 -0
- package/lib/ssg.js +167 -0
- package/lib/templates/templates.d.ts +28 -0
- package/lib/templates/templates.js +63 -0
- package/lib/utils.d.ts +9 -0
- package/lib/utils.js +78 -0
- package/lib/webpack/base.d.ts +5 -1
- package/lib/webpack/base.js +4 -6
- package/lib/webpack/client.d.ts +15 -1
- package/lib/webpack/client.js +78 -23
- package/lib/webpack/minification.d.ts +8 -0
- package/lib/webpack/minification.js +97 -0
- package/lib/webpack/server.d.ts +5 -3
- package/lib/webpack/server.js +41 -50
- package/lib/webpack/utils.d.ts +13 -4
- package/lib/webpack/utils.js +27 -83
- package/package.json +13 -11
- package/lib/commands/start.js +0 -212
- package/lib/server/index.js +0 -154
- package/lib/server/plugins/index.d.ts +0 -18
- package/lib/server/plugins/index.js +0 -106
- /package/lib/{webpack/templates/index.html.template.ejs → templates/dev.html.template.ejs} +0 -0
- /package/lib/{webpack/templates → templates}/ssr.html.template.d.ts +0 -0
- /package/lib/{webpack/templates → templates}/ssr.html.template.js +0 -0
package/lib/webpack/server.js
CHANGED
|
@@ -8,76 +8,67 @@
|
|
|
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 fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
12
13
|
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"));
|
|
15
14
|
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
15
|
+
const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
|
|
16
16
|
const base_1 = require("./base");
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const ssgPaths = routesPaths.map((str) => {
|
|
25
|
-
const ssgPath = baseUrl === '/' ? str : str.replace(new RegExp(`^${baseUrl}`), '/');
|
|
26
|
-
routesLocation[ssgPath] = str;
|
|
27
|
-
return ssgPath;
|
|
17
|
+
async function createServerConfig(params) {
|
|
18
|
+
const { props } = params;
|
|
19
|
+
const baseConfig = await (0, base_1.createBaseConfig)({
|
|
20
|
+
props,
|
|
21
|
+
isServer: true,
|
|
22
|
+
// Minification of server bundle reduces size but doubles bundle time :/
|
|
23
|
+
minify: false,
|
|
28
24
|
});
|
|
29
|
-
const
|
|
25
|
+
const outputFilename = 'server.bundle.js';
|
|
26
|
+
const serverBundlePath = path_1.default.join(props.outDir, outputFilename);
|
|
27
|
+
const config = (0, webpack_merge_1.default)(baseConfig, {
|
|
30
28
|
target: `node${utils_1.NODE_MAJOR_VERSION}.${utils_1.NODE_MINOR_VERSION}`,
|
|
31
29
|
entry: {
|
|
32
30
|
main: path_1.default.resolve(__dirname, '../client/serverEntry.js'),
|
|
33
31
|
},
|
|
34
32
|
output: {
|
|
35
|
-
filename:
|
|
33
|
+
filename: outputFilename,
|
|
36
34
|
libraryTarget: 'commonjs2',
|
|
37
35
|
// Workaround for Webpack 4 Bug (https://github.com/webpack/webpack/issues/6522)
|
|
38
36
|
globalObject: 'this',
|
|
39
37
|
},
|
|
40
38
|
plugins: [
|
|
41
|
-
// Wait until manifest from client bundle is generated
|
|
42
|
-
new WaitPlugin_1.default({
|
|
43
|
-
filepath: path_1.default.join(generatedFilesDir, 'client-manifest.json'),
|
|
44
|
-
}),
|
|
45
|
-
// Static site generator webpack plugin.
|
|
46
|
-
new static_site_generator_webpack_plugin_1.default({
|
|
47
|
-
entry: 'main',
|
|
48
|
-
locals: {
|
|
49
|
-
baseUrl,
|
|
50
|
-
generatedFilesDir,
|
|
51
|
-
routesLocation,
|
|
52
|
-
headTags,
|
|
53
|
-
preBodyTags,
|
|
54
|
-
postBodyTags,
|
|
55
|
-
onLinksCollected,
|
|
56
|
-
onHeadTagsCollected,
|
|
57
|
-
ssrTemplate: ssrTemplate ?? ssr_html_template_1.default,
|
|
58
|
-
noIndex,
|
|
59
|
-
DOCUSAURUS_VERSION: utils_1.DOCUSAURUS_VERSION,
|
|
60
|
-
},
|
|
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,
|
|
73
|
-
}),
|
|
74
39
|
// Show compilation progress bar.
|
|
75
40
|
new webpackbar_1.default({
|
|
76
41
|
name: 'Server',
|
|
77
42
|
color: 'yellow',
|
|
78
43
|
}),
|
|
79
|
-
|
|
44
|
+
await createStaticDirectoriesCopyPlugin(params),
|
|
45
|
+
].filter(Boolean),
|
|
80
46
|
});
|
|
81
|
-
return
|
|
47
|
+
return { config, serverBundlePath };
|
|
82
48
|
}
|
|
83
49
|
exports.default = createServerConfig;
|
|
50
|
+
async function createStaticDirectoriesCopyPlugin({ props }) {
|
|
51
|
+
const { outDir, siteDir, siteConfig: { staticDirectories: staticDirectoriesOption }, } = props;
|
|
52
|
+
// The staticDirectories option can contain empty directories, or non-existent
|
|
53
|
+
// directories (e.g. user deleted `static`). Instead of issuing an error, we
|
|
54
|
+
// just silently filter them out, because user could have never configured it
|
|
55
|
+
// in the first place (the default option should always "work").
|
|
56
|
+
const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
|
|
57
|
+
const staticDir = path_1.default.resolve(siteDir, dir);
|
|
58
|
+
if ((await fs_extra_1.default.pathExists(staticDir)) &&
|
|
59
|
+
(await fs_extra_1.default.readdir(staticDir)).length > 0) {
|
|
60
|
+
return staticDir;
|
|
61
|
+
}
|
|
62
|
+
return '';
|
|
63
|
+
}))).filter(Boolean);
|
|
64
|
+
if (staticDirectories.length === 0) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return new copy_webpack_plugin_1.default({
|
|
68
|
+
patterns: staticDirectories.map((dir) => ({
|
|
69
|
+
from: dir,
|
|
70
|
+
to: outDir,
|
|
71
|
+
toType: 'dir',
|
|
72
|
+
})),
|
|
73
|
+
});
|
|
74
|
+
}
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="node" />
|
|
8
|
-
import webpack, { type Configuration, type RuleSetRule
|
|
8
|
+
import webpack, { type Configuration, type RuleSetRule } from 'webpack';
|
|
9
9
|
import type { TransformOptions } from '@babel/core';
|
|
10
|
-
import type { Plugin } from '@docusaurus/types';
|
|
10
|
+
import type { Plugin, LoadedPlugin } from '@docusaurus/types';
|
|
11
11
|
export declare function formatStatsErrorMessage(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): string | undefined;
|
|
12
12
|
export declare function printStatsWarnings(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): void;
|
|
13
13
|
export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
|
|
@@ -33,15 +33,24 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function applyConfigureWebpack(configureWebpack: NonNullable<Plugin['configureWebpack']>, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
|
|
35
35
|
export declare function applyConfigurePostCss(configurePostCss: NonNullable<Plugin['configurePostCss']>, config: Configuration): Configuration;
|
|
36
|
+
export declare function executePluginsConfigurePostCss({ plugins, config, }: {
|
|
37
|
+
plugins: LoadedPlugin[];
|
|
38
|
+
config: Configuration;
|
|
39
|
+
}): Configuration;
|
|
40
|
+
export declare function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }: {
|
|
41
|
+
plugins: LoadedPlugin[];
|
|
42
|
+
config: Configuration;
|
|
43
|
+
isServer: boolean;
|
|
44
|
+
jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined;
|
|
45
|
+
}): Configuration;
|
|
36
46
|
declare global {
|
|
37
47
|
interface Error {
|
|
38
48
|
/** @see https://webpack.js.org/api/node/#error-handling */
|
|
39
49
|
details: unknown;
|
|
40
50
|
}
|
|
41
51
|
}
|
|
42
|
-
export declare function compile(config: Configuration[]): Promise<
|
|
52
|
+
export declare function compile(config: Configuration[]): Promise<webpack.MultiStats>;
|
|
43
53
|
export declare function getHttpsConfig(): Promise<boolean | {
|
|
44
54
|
cert: Buffer;
|
|
45
55
|
key: Buffer;
|
|
46
56
|
}>;
|
|
47
|
-
export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
|
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.
|
|
9
|
+
exports.getHttpsConfig = exports.compile = exports.executePluginsConfigureWebpack = exports.executePluginsConfigurePostCss = 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"));
|
|
@@ -16,8 +16,6 @@ const utils_1 = require("@docusaurus/utils");
|
|
|
16
16
|
const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
|
|
17
17
|
const webpack_merge_1 = require("webpack-merge");
|
|
18
18
|
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
19
|
-
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
20
|
-
const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
|
|
21
19
|
const formatWebpackMessages_1 = tslib_1.__importDefault(require("react-dev-utils/formatWebpackMessages"));
|
|
22
20
|
function formatStatsErrorMessage(statsJson) {
|
|
23
21
|
if (statsJson?.errors?.length) {
|
|
@@ -189,6 +187,31 @@ function applyConfigurePostCss(configurePostCss, config) {
|
|
|
189
187
|
return config;
|
|
190
188
|
}
|
|
191
189
|
exports.applyConfigurePostCss = applyConfigurePostCss;
|
|
190
|
+
// Plugin Lifecycle - configurePostCss()
|
|
191
|
+
function executePluginsConfigurePostCss({ plugins, config, }) {
|
|
192
|
+
let resultConfig = config;
|
|
193
|
+
plugins.forEach((plugin) => {
|
|
194
|
+
const { configurePostCss } = plugin;
|
|
195
|
+
if (configurePostCss) {
|
|
196
|
+
resultConfig = applyConfigurePostCss(configurePostCss.bind(plugin), resultConfig);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return resultConfig;
|
|
200
|
+
}
|
|
201
|
+
exports.executePluginsConfigurePostCss = executePluginsConfigurePostCss;
|
|
202
|
+
// Plugin Lifecycle - configureWebpack()
|
|
203
|
+
function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }) {
|
|
204
|
+
let resultConfig = config;
|
|
205
|
+
plugins.forEach((plugin) => {
|
|
206
|
+
const { configureWebpack } = plugin;
|
|
207
|
+
if (configureWebpack) {
|
|
208
|
+
resultConfig = applyConfigureWebpack(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
|
|
209
|
+
resultConfig, isServer, jsLoader, plugin.content);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
return resultConfig;
|
|
213
|
+
}
|
|
214
|
+
exports.executePluginsConfigureWebpack = executePluginsConfigureWebpack;
|
|
192
215
|
function compile(config) {
|
|
193
216
|
return new Promise((resolve, reject) => {
|
|
194
217
|
const compiler = (0, webpack_1.default)(config);
|
|
@@ -215,7 +238,7 @@ function compile(config) {
|
|
|
215
238
|
reject(errClose);
|
|
216
239
|
}
|
|
217
240
|
else {
|
|
218
|
-
resolve();
|
|
241
|
+
resolve(stats);
|
|
219
242
|
}
|
|
220
243
|
});
|
|
221
244
|
});
|
|
@@ -269,82 +292,3 @@ async function getHttpsConfig() {
|
|
|
269
292
|
return isHttps;
|
|
270
293
|
}
|
|
271
294
|
exports.getHttpsConfig = getHttpsConfig;
|
|
272
|
-
// See https://github.com/webpack-contrib/terser-webpack-plugin#parallel
|
|
273
|
-
function getTerserParallel() {
|
|
274
|
-
let terserParallel = true;
|
|
275
|
-
if (process.env.TERSER_PARALLEL === 'false') {
|
|
276
|
-
terserParallel = false;
|
|
277
|
-
}
|
|
278
|
-
else if (process.env.TERSER_PARALLEL &&
|
|
279
|
-
parseInt(process.env.TERSER_PARALLEL, 10) > 0) {
|
|
280
|
-
terserParallel = parseInt(process.env.TERSER_PARALLEL, 10);
|
|
281
|
-
}
|
|
282
|
-
return terserParallel;
|
|
283
|
-
}
|
|
284
|
-
function getMinimizer(useSimpleCssMinifier = false) {
|
|
285
|
-
const minimizer = [
|
|
286
|
-
new terser_webpack_plugin_1.default({
|
|
287
|
-
parallel: getTerserParallel(),
|
|
288
|
-
terserOptions: {
|
|
289
|
-
parse: {
|
|
290
|
-
// We want uglify-js to parse ecma 8 code. However, we don't want it
|
|
291
|
-
// to apply any minification steps that turns valid ecma 5 code
|
|
292
|
-
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
293
|
-
// sections only apply transformations that are ecma 5 safe
|
|
294
|
-
// https://github.com/facebook/create-react-app/pull/4234
|
|
295
|
-
ecma: 2020,
|
|
296
|
-
},
|
|
297
|
-
compress: {
|
|
298
|
-
ecma: 5,
|
|
299
|
-
},
|
|
300
|
-
mangle: {
|
|
301
|
-
safari10: true,
|
|
302
|
-
},
|
|
303
|
-
output: {
|
|
304
|
-
ecma: 5,
|
|
305
|
-
comments: false,
|
|
306
|
-
// Turned on because emoji and regex is not minified properly using
|
|
307
|
-
// default. See https://github.com/facebook/create-react-app/issues/2488
|
|
308
|
-
ascii_only: true,
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
}),
|
|
312
|
-
];
|
|
313
|
-
if (useSimpleCssMinifier) {
|
|
314
|
-
minimizer.push(new css_minimizer_webpack_plugin_1.default());
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
minimizer.push(
|
|
318
|
-
// Using the array syntax to add 2 minimizers
|
|
319
|
-
// see https://github.com/webpack-contrib/css-minimizer-webpack-plugin#array
|
|
320
|
-
new css_minimizer_webpack_plugin_1.default({
|
|
321
|
-
minimizerOptions: [
|
|
322
|
-
// CssNano options
|
|
323
|
-
{
|
|
324
|
-
preset: require.resolve('@docusaurus/cssnano-preset'),
|
|
325
|
-
},
|
|
326
|
-
// CleanCss options
|
|
327
|
-
{
|
|
328
|
-
inline: false,
|
|
329
|
-
level: {
|
|
330
|
-
1: {
|
|
331
|
-
all: false,
|
|
332
|
-
removeWhitespace: true,
|
|
333
|
-
},
|
|
334
|
-
2: {
|
|
335
|
-
all: true,
|
|
336
|
-
restructureRules: true,
|
|
337
|
-
removeUnusedAtRules: false,
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
],
|
|
342
|
-
minify: [
|
|
343
|
-
css_minimizer_webpack_plugin_1.default.cssnanoMinify,
|
|
344
|
-
css_minimizer_webpack_plugin_1.default.cleanCssMinify,
|
|
345
|
-
],
|
|
346
|
-
}));
|
|
347
|
-
}
|
|
348
|
-
return minimizer;
|
|
349
|
-
}
|
|
350
|
-
exports.getMinimizer = getMinimizer;
|
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": "3.
|
|
4
|
+
"version": "3.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,14 +43,13 @@
|
|
|
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": "3.
|
|
47
|
-
"@docusaurus/logger": "3.
|
|
48
|
-
"@docusaurus/mdx-loader": "3.
|
|
46
|
+
"@docusaurus/cssnano-preset": "3.2.0",
|
|
47
|
+
"@docusaurus/logger": "3.2.0",
|
|
48
|
+
"@docusaurus/mdx-loader": "3.2.0",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "3.
|
|
51
|
-
"@docusaurus/utils-common": "3.
|
|
52
|
-
"@docusaurus/utils-validation": "3.
|
|
53
|
-
"@slorber/static-site-generator-webpack-plugin": "^4.0.7",
|
|
50
|
+
"@docusaurus/utils": "3.2.0",
|
|
51
|
+
"@docusaurus/utils-common": "3.2.0",
|
|
52
|
+
"@docusaurus/utils-validation": "3.2.0",
|
|
54
53
|
"@svgr/webpack": "^6.5.1",
|
|
55
54
|
"autoprefixer": "^10.4.14",
|
|
56
55
|
"babel-loader": "^9.1.3",
|
|
@@ -71,6 +70,7 @@
|
|
|
71
70
|
"detect-port": "^1.5.1",
|
|
72
71
|
"escape-html": "^1.0.3",
|
|
73
72
|
"eta": "^2.2.0",
|
|
73
|
+
"eval": "^0.1.8",
|
|
74
74
|
"file-loader": "^6.2.0",
|
|
75
75
|
"fs-extra": "^11.1.1",
|
|
76
76
|
"html-minifier-terser": "^7.2.0",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"leven": "^3.1.0",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
81
|
"mini-css-extract-plugin": "^2.7.6",
|
|
82
|
+
"p-map": "^4.0.0",
|
|
82
83
|
"postcss": "^8.4.26",
|
|
83
84
|
"postcss-loader": "^7.3.3",
|
|
84
85
|
"prompts": "^2.4.2",
|
|
@@ -104,8 +105,9 @@
|
|
|
104
105
|
"webpackbar": "^5.0.2"
|
|
105
106
|
},
|
|
106
107
|
"devDependencies": {
|
|
107
|
-
"@docusaurus/module-type-aliases": "3.
|
|
108
|
-
"@docusaurus/types": "3.
|
|
108
|
+
"@docusaurus/module-type-aliases": "3.2.0",
|
|
109
|
+
"@docusaurus/types": "3.2.0",
|
|
110
|
+
"@total-typescript/shoehorn": "^0.1.2",
|
|
109
111
|
"@types/detect-port": "^1.3.3",
|
|
110
112
|
"@types/react-dom": "^18.2.7",
|
|
111
113
|
"@types/react-router-config": "^5.0.7",
|
|
@@ -124,5 +126,5 @@
|
|
|
124
126
|
"engines": {
|
|
125
127
|
"node": ">=18.0"
|
|
126
128
|
},
|
|
127
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "5af143651b26b39761361acd96e9c5be7ba0cb25"
|
|
128
130
|
}
|
package/lib/commands/start.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.start = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
14
|
-
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
|
-
const utils_1 = require("@docusaurus/utils");
|
|
16
|
-
const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
|
|
17
|
-
const html_webpack_plugin_1 = tslib_1.__importDefault(require("html-webpack-plugin"));
|
|
18
|
-
const openBrowser_1 = tslib_1.__importDefault(require("react-dev-utils/openBrowser"));
|
|
19
|
-
const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
|
|
20
|
-
const evalSourceMapMiddleware_1 = tslib_1.__importDefault(require("react-dev-utils/evalSourceMapMiddleware"));
|
|
21
|
-
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
22
|
-
const webpack_dev_server_1 = tslib_1.__importDefault(require("webpack-dev-server"));
|
|
23
|
-
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
24
|
-
const server_1 = require("../server");
|
|
25
|
-
const client_1 = tslib_1.__importDefault(require("../webpack/client"));
|
|
26
|
-
const utils_2 = require("../webpack/utils");
|
|
27
|
-
const getHostPort_1 = require("../server/getHostPort");
|
|
28
|
-
async function start(siteDirParam = '.', cliOptions = {}) {
|
|
29
|
-
// Temporary workaround to unlock the ability to translate the site config
|
|
30
|
-
// We'll remove it if a better official API can be designed
|
|
31
|
-
// See https://github.com/facebook/docusaurus/issues/4542
|
|
32
|
-
process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale;
|
|
33
|
-
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
34
|
-
logger_1.default.info('Starting the development server...');
|
|
35
|
-
function loadSite() {
|
|
36
|
-
return (0, server_1.load)({
|
|
37
|
-
siteDir,
|
|
38
|
-
config: cliOptions.config,
|
|
39
|
-
locale: cliOptions.locale,
|
|
40
|
-
localizePath: undefined, // Should this be configurable?
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
// Process all related files as a prop.
|
|
44
|
-
const props = await loadSite();
|
|
45
|
-
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
|
46
|
-
const { host, port } = await (0, getHostPort_1.getHostPort)(cliOptions);
|
|
47
|
-
if (port === null) {
|
|
48
|
-
process.exit();
|
|
49
|
-
}
|
|
50
|
-
const { baseUrl, headTags, preBodyTags, postBodyTags } = props;
|
|
51
|
-
const urls = (0, WebpackDevServerUtils_1.prepareUrls)(protocol, host, port);
|
|
52
|
-
const openUrl = (0, utils_1.normalizeUrl)([urls.localUrlForBrowser, baseUrl]);
|
|
53
|
-
logger_1.default.success `Docusaurus website is running at: url=${openUrl}`;
|
|
54
|
-
// Reload files processing.
|
|
55
|
-
const reload = lodash_1.default.debounce(() => {
|
|
56
|
-
loadSite()
|
|
57
|
-
.then(({ baseUrl: newBaseUrl }) => {
|
|
58
|
-
const newOpenUrl = (0, utils_1.normalizeUrl)([urls.localUrlForBrowser, newBaseUrl]);
|
|
59
|
-
if (newOpenUrl !== openUrl) {
|
|
60
|
-
logger_1.default.success `Docusaurus website is running at: url=${newOpenUrl}`;
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
.catch((err) => {
|
|
64
|
-
logger_1.default.error(err.stack);
|
|
65
|
-
});
|
|
66
|
-
}, 500);
|
|
67
|
-
const { siteConfig, plugins, localizationDir } = props;
|
|
68
|
-
const normalizeToSiteDir = (filepath) => {
|
|
69
|
-
if (filepath && path_1.default.isAbsolute(filepath)) {
|
|
70
|
-
return (0, utils_1.posixPath)(path_1.default.relative(siteDir, filepath));
|
|
71
|
-
}
|
|
72
|
-
return (0, utils_1.posixPath)(filepath);
|
|
73
|
-
};
|
|
74
|
-
const pluginPaths = plugins
|
|
75
|
-
.flatMap((plugin) => plugin.getPathsToWatch?.() ?? [])
|
|
76
|
-
.filter(Boolean)
|
|
77
|
-
.map(normalizeToSiteDir);
|
|
78
|
-
const pathsToWatch = [...pluginPaths, props.siteConfigPath, localizationDir];
|
|
79
|
-
const pollingOptions = {
|
|
80
|
-
usePolling: !!cliOptions.poll,
|
|
81
|
-
interval: Number.isInteger(cliOptions.poll)
|
|
82
|
-
? cliOptions.poll
|
|
83
|
-
: undefined,
|
|
84
|
-
};
|
|
85
|
-
const httpsConfig = await (0, utils_2.getHttpsConfig)();
|
|
86
|
-
const fsWatcher = chokidar_1.default.watch(pathsToWatch, {
|
|
87
|
-
cwd: siteDir,
|
|
88
|
-
ignoreInitial: true,
|
|
89
|
-
...{ pollingOptions },
|
|
90
|
-
});
|
|
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, false), {
|
|
93
|
-
watchOptions: {
|
|
94
|
-
ignored: /node_modules\/(?!@docusaurus)/,
|
|
95
|
-
poll: cliOptions.poll,
|
|
96
|
-
},
|
|
97
|
-
infrastructureLogging: {
|
|
98
|
-
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
|
|
99
|
-
level: 'warn',
|
|
100
|
-
},
|
|
101
|
-
plugins: [
|
|
102
|
-
// Generates an `index.html` file with the <script> injected.
|
|
103
|
-
new html_webpack_plugin_1.default({
|
|
104
|
-
template: path_1.default.join(__dirname, '../webpack/templates/index.html.template.ejs'),
|
|
105
|
-
// So we can define the position where the scripts are injected.
|
|
106
|
-
inject: false,
|
|
107
|
-
filename: 'index.html',
|
|
108
|
-
title: siteConfig.title,
|
|
109
|
-
headTags,
|
|
110
|
-
preBodyTags,
|
|
111
|
-
postBodyTags,
|
|
112
|
-
}),
|
|
113
|
-
],
|
|
114
|
-
});
|
|
115
|
-
// Plugin Lifecycle - configureWebpack and configurePostCss.
|
|
116
|
-
plugins.forEach((plugin) => {
|
|
117
|
-
const { configureWebpack, configurePostCss } = plugin;
|
|
118
|
-
if (configurePostCss) {
|
|
119
|
-
config = (0, utils_2.applyConfigurePostCss)(configurePostCss.bind(plugin), config);
|
|
120
|
-
}
|
|
121
|
-
if (configureWebpack) {
|
|
122
|
-
config = (0, utils_2.applyConfigureWebpack)(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
|
|
123
|
-
config, false, props.siteConfig.webpack?.jsLoader, plugin.content);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
const compiler = (0, webpack_1.default)(config);
|
|
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) {
|
|
135
|
-
if (stats.hasErrors()) {
|
|
136
|
-
logger_1.default.error('E2E_TEST: Project has compiler errors.');
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
|
-
logger_1.default.success('E2E_TEST: Project can compile.');
|
|
140
|
-
process.exit(0);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
// https://webpack.js.org/configuration/dev-server
|
|
144
|
-
const defaultDevServerConfig = {
|
|
145
|
-
hot: cliOptions.hotOnly ? 'only' : true,
|
|
146
|
-
liveReload: false,
|
|
147
|
-
client: {
|
|
148
|
-
progress: true,
|
|
149
|
-
overlay: {
|
|
150
|
-
warnings: false,
|
|
151
|
-
errors: true,
|
|
152
|
-
},
|
|
153
|
-
webSocketURL: {
|
|
154
|
-
hostname: '0.0.0.0',
|
|
155
|
-
port: 0,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
headers: {
|
|
159
|
-
'access-control-allow-origin': '*',
|
|
160
|
-
},
|
|
161
|
-
devMiddleware: {
|
|
162
|
-
publicPath: baseUrl,
|
|
163
|
-
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
|
|
164
|
-
stats: 'summary',
|
|
165
|
-
},
|
|
166
|
-
static: siteConfig.staticDirectories.map((dir) => ({
|
|
167
|
-
publicPath: baseUrl,
|
|
168
|
-
directory: path_1.default.resolve(siteDir, dir),
|
|
169
|
-
watch: {
|
|
170
|
-
// Useful options for our own monorepo using symlinks!
|
|
171
|
-
// See https://github.com/webpack/webpack/issues/11612#issuecomment-879259806
|
|
172
|
-
followSymlinks: true,
|
|
173
|
-
ignored: /node_modules\/(?!@docusaurus)/,
|
|
174
|
-
...{ pollingOptions },
|
|
175
|
-
},
|
|
176
|
-
})),
|
|
177
|
-
...(httpsConfig && {
|
|
178
|
-
server: typeof httpsConfig === 'object'
|
|
179
|
-
? {
|
|
180
|
-
type: 'https',
|
|
181
|
-
options: httpsConfig,
|
|
182
|
-
}
|
|
183
|
-
: 'https',
|
|
184
|
-
}),
|
|
185
|
-
historyApiFallback: {
|
|
186
|
-
rewrites: [{ from: /\/*/, to: baseUrl }],
|
|
187
|
-
},
|
|
188
|
-
allowedHosts: 'all',
|
|
189
|
-
host,
|
|
190
|
-
port,
|
|
191
|
-
setupMiddlewares: (middlewares, devServer) => {
|
|
192
|
-
// This lets us fetch source contents from webpack for the error overlay.
|
|
193
|
-
middlewares.unshift((0, evalSourceMapMiddleware_1.default)(devServer));
|
|
194
|
-
return middlewares;
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
// Allow plugin authors to customize/override devServer config
|
|
198
|
-
const devServerConfig = (0, webpack_merge_1.default)([defaultDevServerConfig, config.devServer].filter(Boolean));
|
|
199
|
-
const devServer = new webpack_dev_server_1.default(devServerConfig, compiler);
|
|
200
|
-
devServer.startCallback(() => {
|
|
201
|
-
if (cliOptions.open) {
|
|
202
|
-
(0, openBrowser_1.default)(openUrl);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
|
206
|
-
process.on(sig, () => {
|
|
207
|
-
devServer.stop();
|
|
208
|
-
process.exit();
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
exports.start = start;
|