@docusaurus/core 2.0.0-beta.20 → 2.0.0-beta.21

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.
Files changed (66) hide show
  1. package/bin/beforeCli.mjs +6 -4
  2. package/bin/docusaurus.mjs +9 -1
  3. package/lib/babel/preset.js +2 -1
  4. package/lib/client/App.js +5 -5
  5. package/lib/client/ClientLifecyclesDispatcher.js +1 -1
  6. package/lib/client/PendingNavigation.js +3 -1
  7. package/lib/client/SiteMetadataDefaults.js +4 -2
  8. package/lib/client/docusaurus.d.ts +1 -1
  9. package/lib/client/docusaurus.js +1 -1
  10. package/lib/client/exports/ComponentCreator.d.ts +5 -0
  11. package/lib/client/exports/ComponentCreator.js +14 -7
  12. package/lib/client/exports/ErrorBoundary.js +8 -7
  13. package/lib/client/exports/Link.d.ts +1 -1
  14. package/lib/client/exports/Link.js +1 -1
  15. package/lib/client/exports/isInternalUrl.js +1 -1
  16. package/lib/client/exports/useGlobalData.js +0 -3
  17. package/lib/client/prefetch.js +2 -2
  18. package/lib/client/preload.js +1 -3
  19. package/lib/client/serverEntry.js +23 -12
  20. package/lib/client/theme-fallback/Error/index.js +2 -2
  21. package/lib/client/theme-fallback/Loading/index.js +1 -1
  22. package/lib/client/theme-fallback/NotFound/index.js +1 -1
  23. package/lib/commands/build.js +9 -9
  24. package/lib/commands/deploy.js +13 -13
  25. package/lib/commands/serve.d.ts +2 -1
  26. package/lib/commands/serve.js +10 -5
  27. package/lib/commands/start.d.ts +1 -0
  28. package/lib/commands/start.js +6 -6
  29. package/lib/commands/swizzle/actions.js +6 -8
  30. package/lib/commands/swizzle/common.js +1 -1
  31. package/lib/commands/swizzle/components.js +1 -1
  32. package/lib/commands/swizzle/config.js +9 -8
  33. package/lib/commands/swizzle/prompts.js +8 -8
  34. package/lib/commands/swizzle/tables.js +1 -1
  35. package/lib/commands/swizzle/themes.js +3 -3
  36. package/lib/commands/writeHeadingIds.d.ts +1 -1
  37. package/lib/commands/writeHeadingIds.js +1 -1
  38. package/lib/server/brokenLinks.js +4 -4
  39. package/lib/server/config.js +17 -2
  40. package/lib/server/configValidation.d.ts +3 -3
  41. package/lib/server/configValidation.js +6 -5
  42. package/lib/server/getHostPort.js +3 -3
  43. package/lib/server/htmlTags.js +1 -1
  44. package/lib/server/i18n.js +1 -1
  45. package/lib/server/index.js +3 -3
  46. package/lib/server/plugins/configs.js +2 -2
  47. package/lib/server/plugins/index.js +3 -3
  48. package/lib/server/plugins/init.js +4 -4
  49. package/lib/server/plugins/routeConfig.d.ts +1 -1
  50. package/lib/server/plugins/routeConfig.js +2 -2
  51. package/lib/server/plugins/synthetic.js +1 -1
  52. package/lib/server/routes.js +2 -2
  53. package/lib/server/siteMetadata.js +1 -1
  54. package/lib/server/translations/translations.js +1 -1
  55. package/lib/server/translations/translationsExtractor.js +9 -11
  56. package/lib/server/utils.d.ts +1 -1
  57. package/lib/webpack/aliases/index.js +1 -1
  58. package/lib/webpack/base.js +11 -11
  59. package/lib/webpack/client.d.ts +1 -1
  60. package/lib/webpack/client.js +1 -1
  61. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +0 -19
  62. package/lib/webpack/plugins/CleanWebpackPlugin.js +26 -4
  63. package/lib/webpack/server.d.ts +2 -2
  64. package/lib/webpack/server.js +3 -3
  65. package/lib/webpack/utils.js +15 -17
  66. package/package.json +39 -36
@@ -8,9 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadRoutes = exports.handleDuplicateRoutes = exports.genChunkName = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const utils_1 = require("@docusaurus/utils");
12
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
11
  const querystring_1 = tslib_1.__importDefault(require("querystring"));
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
+ const utils_1 = require("@docusaurus/utils");
14
14
  const utils_2 = require("./utils");
15
15
  /** Indents every line of `str` by one level. */
16
16
  function indent(str) {
@@ -8,10 +8,10 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadSiteMetadata = exports.getPluginVersion = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const utils_1 = require("@docusaurus/utils");
12
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
12
  const path_1 = tslib_1.__importDefault(require("path"));
14
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const utils_1 = require("@docusaurus/utils");
15
15
  async function getPackageJsonVersion(packageJsonPath) {
16
16
  if (await fs_extra_1.default.pathExists(packageJsonPath)) {
17
17
  // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
@@ -11,9 +11,9 @@ const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
13
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
15
  const utils_1 = require("@docusaurus/utils");
15
16
  const utils_validation_1 = require("@docusaurus/utils-validation");
16
- const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
17
17
  const TranslationFileContentSchema = utils_validation_1.Joi.object()
18
18
  .pattern(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
19
19
  message: utils_validation_1.Joi.string().allow('').required(),
@@ -8,12 +8,12 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.extractSourceCodeFileTranslations = exports.extractAllSourceCodeFileTranslations = exports.extractSiteSourceCodeTranslations = exports.globSourceCodeFilePaths = void 0;
10
10
  const tslib_1 = require("tslib");
11
+ const path_1 = tslib_1.__importDefault(require("path"));
11
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
14
  const traverse_1 = tslib_1.__importDefault(require("@babel/traverse"));
13
15
  const generator_1 = tslib_1.__importDefault(require("@babel/generator"));
14
- const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
16
  const core_1 = require("@babel/core");
16
- const path_1 = tslib_1.__importDefault(require("path"));
17
17
  const utils_1 = require("@docusaurus/utils");
18
18
  const utils_2 = require("../utils");
19
19
  // We only support extracting source code translations from these kind of files
@@ -99,7 +99,7 @@ async function extractSourceCodeFileTranslations(sourceCodeFilePath, babelOption
99
99
  // See https://twitter.com/NicoloRibaudo/status/1321130735605002243
100
100
  filename: sourceCodeFilePath,
101
101
  });
102
- const translations = await extractSourceCodeAstTranslations(ast, sourceCodeFilePath);
102
+ const translations = extractSourceCodeAstTranslations(ast, sourceCodeFilePath);
103
103
  return translations;
104
104
  }
105
105
  catch (err) {
@@ -118,7 +118,7 @@ https://github.com/pugjs/babel-walk
118
118
  */
119
119
  function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
120
120
  function sourceWarningPart(node) {
121
- return `File: ${sourceCodeFilePath} at line ${node.loc?.start.line}
121
+ return `File: ${sourceCodeFilePath} at line ${node.loc?.start.line ?? '?'}
122
122
  Full code: ${(0, generator_1.default)(node).code}`;
123
123
  }
124
124
  const translations = {};
@@ -157,9 +157,7 @@ Full code: ${(0, generator_1.default)(node).code}`;
157
157
  const attributePath = path
158
158
  .get('openingElement.attributes')
159
159
  .find((attr) => attr.isJSXAttribute() &&
160
- attr
161
- .get('name')
162
- .isJSXIdentifier({ name: propName }));
160
+ attr.get('name').isJSXIdentifier({ name: propName }));
163
161
  if (attributePath) {
164
162
  const attributeValue = attributePath.get('value');
165
163
  const attributeValueEvaluated = attributeValue.isJSXExpressionContainer()
@@ -209,7 +207,7 @@ ${sourceWarningPart(path.node)}`);
209
207
  if (isJSXText || isJSXExpressionContainer) {
210
208
  message = isJSXText
211
209
  ? singleChildren.node.value.trim().replace(/\s+/g, ' ')
212
- : singleChildren.get('expression').evaluate().value;
210
+ : String(singleChildren.get('expression').evaluate().value);
213
211
  translations[id ?? message] = {
214
212
  message,
215
213
  ...(description && { description }),
@@ -234,9 +232,9 @@ ${sourceWarningPart(path.node)}`);
234
232
  if (firstArgEvaluated.confident &&
235
233
  typeof firstArgEvaluated.value === 'object') {
236
234
  const { message, id, description } = firstArgEvaluated.value;
237
- translations[id ?? message] = {
238
- message: message ?? id,
239
- ...(description && { description }),
235
+ translations[String(id ?? message)] = {
236
+ message: String(message ?? id),
237
+ ...(Boolean(description) && { description: String(description) }),
240
238
  };
241
239
  }
242
240
  else {
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import type { RouteConfig } from '@docusaurus/types';
8
7
  import { Globby } from '@docusaurus/utils';
8
+ import type { RouteConfig } from '@docusaurus/types';
9
9
  export declare function getAllFinalRoutes(routeConfig: RouteConfig[]): RouteConfig[];
10
10
  export declare function safeGlobby(patterns: string[], options?: Globby.GlobbyOptions): Promise<string[]>;
@@ -10,8 +10,8 @@ exports.loadDocusaurusAliases = exports.loadThemeAliases = exports.createAliases
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"));
13
- const utils_1 = require("@docusaurus/utils");
14
13
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
+ const utils_1 = require("@docusaurus/utils");
15
15
  const ThemeFallbackDir = path_1.default.join(__dirname, '../../client/theme-fallback');
16
16
  /**
17
17
  * Order of Webpack aliases is important because one alias can shadow another.
@@ -9,11 +9,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createBaseConfig = exports.excludeJS = exports.clientDir = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
- const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
13
12
  const path_1 = tslib_1.__importDefault(require("path"));
14
- const utils_1 = require("./utils");
13
+ const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
14
+ const utils_1 = require("@docusaurus/utils");
15
+ const utils_2 = require("./utils");
15
16
  const aliases_1 = require("./aliases");
16
- const utils_2 = require("@docusaurus/utils");
17
17
  const CSS_REGEX = /\.css$/i;
18
18
  const CSS_MODULE_REGEX = /\.module\.css$/i;
19
19
  exports.clientDir = path_1.default.join(__dirname, '..', 'client');
@@ -27,7 +27,7 @@ function excludeJS(modulePath) {
27
27
  return false;
28
28
  }
29
29
  // Don't transpile node_modules except any docusaurus npm package
30
- return (/node_modules/.test(modulePath) &&
30
+ return (modulePath.includes('node_modules') &&
31
31
  !/docusaurus(?:(?!node_modules).)*\.jsx?$/.test(modulePath) &&
32
32
  !LibrariesToTranspileRegex.test(modulePath));
33
33
  }
@@ -38,7 +38,7 @@ async function createBaseConfig(props, isServer, minify = true) {
38
38
  const isProd = process.env.NODE_ENV === 'production';
39
39
  const minimizeEnabled = minify && isProd && !isServer;
40
40
  const useSimpleCssMinifier = process.env.USE_SIMPLE_CSS_MINIFIER === 'true';
41
- const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
41
+ const fileLoaderUtils = (0, utils_1.getFileLoaderUtils)();
42
42
  const name = isServer ? 'server' : 'client';
43
43
  const mode = isProd ? 'production' : 'development';
44
44
  const themeAliases = await (0, aliases_1.loadThemeAliases)({ siteDir, plugins });
@@ -57,7 +57,7 @@ async function createBaseConfig(props, isServer, minify = true) {
57
57
  // Webpack does not evict the cache correctly on alias/swizzle change,
58
58
  // so we force eviction.
59
59
  // See https://github.com/webpack/webpack/issues/13627
60
- (0, utils_2.md5Hash)(JSON.stringify(themeAliases)),
60
+ (0, utils_1.md5Hash)(JSON.stringify(themeAliases)),
61
61
  ].join('-'),
62
62
  // When one of those modules/dependencies change (including transitive
63
63
  // deps), cache is invalidated
@@ -125,7 +125,7 @@ async function createBaseConfig(props, isServer, minify = true) {
125
125
  // used for static site generation
126
126
  minimize: minimizeEnabled,
127
127
  minimizer: minimizeEnabled
128
- ? (0, utils_1.getMinimizer)(useSimpleCssMinifier)
128
+ ? (0, utils_2.getMinimizer)(useSimpleCssMinifier)
129
129
  : undefined,
130
130
  splitChunks: isServer
131
131
  ? false
@@ -167,16 +167,16 @@ async function createBaseConfig(props, isServer, minify = true) {
167
167
  test: /\.[jt]sx?$/i,
168
168
  exclude: excludeJS,
169
169
  use: [
170
- (0, utils_1.getCustomizableJSLoader)(siteConfig.webpack?.jsLoader)({
170
+ (0, utils_2.getCustomizableJSLoader)(siteConfig.webpack?.jsLoader)({
171
171
  isServer,
172
- babelOptions: await (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
172
+ babelOptions: await (0, utils_2.getCustomBabelConfigFilePath)(siteDir),
173
173
  }),
174
174
  ],
175
175
  },
176
176
  {
177
177
  test: CSS_REGEX,
178
178
  exclude: CSS_MODULE_REGEX,
179
- use: (0, utils_1.getStyleLoaders)(isServer, {
179
+ use: (0, utils_2.getStyleLoaders)(isServer, {
180
180
  importLoaders: 1,
181
181
  sourceMap: !isProd,
182
182
  }),
@@ -185,7 +185,7 @@ async function createBaseConfig(props, isServer, minify = true) {
185
185
  // using the extension .module.css
186
186
  {
187
187
  test: CSS_MODULE_REGEX,
188
- use: (0, utils_1.getStyleLoaders)(isServer, {
188
+ use: (0, utils_2.getStyleLoaders)(isServer, {
189
189
  modules: {
190
190
  localIdentName: isProd
191
191
  ? `[local]_[contenthash:base64:4]`
@@ -4,6 +4,6 @@
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 type { Configuration } from 'webpack';
8
7
  import type { Props } from '@docusaurus/types';
8
+ import type { Configuration } from 'webpack';
9
9
  export default function createClientConfig(props: Props, minify?: boolean): Promise<Configuration>;
@@ -7,8 +7,8 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
10
  const path_1 = tslib_1.__importDefault(require("path"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
12
  const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
13
13
  const base_1 = require("./base");
14
14
  const ChunkAssetPlugin_1 = tslib_1.__importDefault(require("./plugins/ChunkAssetPlugin"));
@@ -4,25 +4,6 @@
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
- /**
8
- * The MIT License (MIT)
9
- * Copyright (c) 2015 John Agan
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- * The above copyright notice and this permission notice shall be included in
17
- * all copies or substantial portions of the Software.
18
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
- * SOFTWARE.
25
- */
26
7
  import type { Compiler, Stats } from 'webpack';
27
8
  export declare type Options = {
28
9
  /**
@@ -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,7 +62,7 @@ class CleanWebpackPlugin {
40
62
  this.removeFiles = this.removeFiles.bind(this);
41
63
  }
42
64
  apply(compiler) {
43
- if (!compiler.options.output || !compiler.options.output.path) {
65
+ if (!compiler.options.output.path) {
44
66
  console.warn('clean-webpack-plugin: options.output.path not defined. Plugin disabled...');
45
67
  return;
46
68
  }
@@ -93,7 +115,7 @@ class CleanWebpackPlugin {
93
115
  *
94
116
  * (relies on del's cwd: outputPath option)
95
117
  */
96
- const staleFiles = this.currentAssets.filter((previousAsset) => assets.includes(previousAsset) === false);
118
+ const staleFiles = this.currentAssets.filter((previousAsset) => !assets.includes(previousAsset));
97
119
  /**
98
120
  * Save assets for next compilation
99
121
  */
@@ -102,7 +124,7 @@ class CleanWebpackPlugin {
102
124
  /**
103
125
  * Remove unused webpack assets
104
126
  */
105
- if (this.cleanStaleWebpackAssets === true && staleFiles.length !== 0) {
127
+ if (this.cleanStaleWebpackAssets && staleFiles.length !== 0) {
106
128
  removePatterns.push(...staleFiles);
107
129
  }
108
130
  if (removePatterns.length !== 0) {
@@ -135,7 +157,7 @@ class CleanWebpackPlugin {
135
157
  }
136
158
  }
137
159
  catch (err) {
138
- const needsForce = /Cannot delete files\/folders outside the current working directory\./.test(err.message);
160
+ const needsForce = err.message.includes('Cannot delete files/folders outside the current working directory.');
139
161
  if (needsForce) {
140
162
  const message = 'clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the "dangerouslyAllowCleanPatternsOutsideProject" option.';
141
163
  throw new Error(message);
@@ -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 type { Configuration } from 'webpack';
8
- import type { 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
10
  export default function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }: Pick<Locals, 'onLinksCollected' | 'onHeadTagsCollected'> & {
11
11
  props: Props;
12
12
  }): Promise<Configuration>;
@@ -9,13 +9,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const path_1 = tslib_1.__importDefault(require("path"));
11
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"));
12
15
  const base_1 = require("./base");
13
16
  const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
14
17
  const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
15
- const utils_1 = require("@docusaurus/utils");
16
18
  const ssr_html_template_1 = tslib_1.__importDefault(require("./templates/ssr.html.template"));
17
- // Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
18
- const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
19
19
  async function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }) {
20
20
  const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, siteConfig: { noIndex, trailingSlash, ssrTemplate }, } = props;
21
21
  const config = await (0, base_1.createBaseConfig)(props, true);
@@ -8,16 +8,16 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getMinimizer = exports.getHttpsConfig = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
12
- const webpack_merge_1 = require("webpack-merge");
13
- const webpack_1 = tslib_1.__importDefault(require("webpack"));
14
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
- const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
16
- const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
17
12
  const path_1 = tslib_1.__importDefault(require("path"));
18
13
  const crypto_1 = tslib_1.__importDefault(require("crypto"));
19
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
20
15
  const utils_1 = require("@docusaurus/utils");
16
+ const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
17
+ const webpack_merge_1 = require("webpack-merge");
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
21
  // Utility method to get style loaders
22
22
  function getStyleLoaders(isServer, cssOptionsArg = {}) {
23
23
  const cssOptions = {
@@ -131,13 +131,11 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
131
131
  };
132
132
  if (typeof configureWebpack === 'function') {
133
133
  const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content) ?? {};
134
- if (res && typeof res === 'object') {
135
- const customizeRules = mergeStrategy ?? {};
136
- return (0, webpack_merge_1.mergeWithCustomize)({
137
- customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
138
- customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
139
- })(config, res);
140
- }
134
+ const customizeRules = mergeStrategy ?? {};
135
+ return (0, webpack_merge_1.mergeWithCustomize)({
136
+ customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
137
+ customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
138
+ })(config, res);
141
139
  }
142
140
  return config;
143
141
  }
@@ -170,7 +168,7 @@ function compile(config) {
170
168
  const compiler = (0, webpack_1.default)(config);
171
169
  compiler.run((err, stats) => {
172
170
  if (err) {
173
- logger_1.default.error(err.stack || err);
171
+ logger_1.default.error(err.stack ?? err);
174
172
  if (err.details) {
175
173
  logger_1.default.error(err.details);
176
174
  }
@@ -210,16 +208,16 @@ function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
210
208
  encrypted = crypto_1.default.publicEncrypt(cert, Buffer.from('test'));
211
209
  }
212
210
  catch (err) {
213
- throw new Error(`The certificate ${crtFile} is invalid.
214
- ${err}`);
211
+ logger_1.default.error `The certificate path=${crtFile} is invalid.`;
212
+ throw err;
215
213
  }
216
214
  try {
217
215
  // privateDecrypt will throw an error with an invalid key
218
216
  crypto_1.default.privateDecrypt(key, encrypted);
219
217
  }
220
218
  catch (err) {
221
- throw new Error(`The certificate key ${keyFile} is invalid.
222
- ${err}`);
219
+ logger_1.default.error `The certificate key path=${keyFile} is invalid.`;
220
+ throw err;
223
221
  }
224
222
  }
225
223
  // Read file and throw an error if it doesn't exist
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": "2.0.0-beta.20",
4
+ "version": "2.0.0-beta.21",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -24,47 +24,50 @@
24
24
  "docusaurus": "bin/docusaurus.mjs"
25
25
  },
26
26
  "scripts": {
27
- "build": "tsc -p tsconfig.server.json && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs",
28
- "watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc -p tsconfig.server.json --watch\" \"tsc -p tsconfig.client.json --watch\""
27
+ "build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js",
28
+ "watch": "run-p -c copy:watch build:watch",
29
+ "build:watch": "tsc --build --watch",
30
+ "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
29
31
  },
30
32
  "bugs": {
31
33
  "url": "https://github.com/facebook/docusaurus/issues"
32
34
  },
33
35
  "dependencies": {
34
- "@babel/core": "^7.17.10",
35
- "@babel/generator": "^7.17.10",
36
+ "@babel/core": "^7.18.2",
37
+ "@babel/generator": "^7.18.2",
36
38
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
37
- "@babel/plugin-transform-runtime": "^7.17.10",
38
- "@babel/preset-env": "^7.17.10",
39
- "@babel/preset-react": "^7.16.7",
40
- "@babel/preset-typescript": "^7.16.7",
41
- "@babel/runtime": "^7.17.9",
42
- "@babel/runtime-corejs3": "^7.17.9",
43
- "@babel/traverse": "^7.17.10",
44
- "@docusaurus/cssnano-preset": "2.0.0-beta.20",
45
- "@docusaurus/logger": "2.0.0-beta.20",
46
- "@docusaurus/mdx-loader": "2.0.0-beta.20",
39
+ "@babel/plugin-transform-runtime": "^7.18.2",
40
+ "@babel/preset-env": "^7.18.2",
41
+ "@babel/preset-react": "^7.17.12",
42
+ "@babel/preset-typescript": "^7.17.12",
43
+ "@babel/runtime": "^7.18.3",
44
+ "@babel/runtime-corejs3": "^7.18.3",
45
+ "@babel/traverse": "^7.18.2",
46
+ "@docusaurus/cssnano-preset": "2.0.0-beta.21",
47
+ "@docusaurus/logger": "2.0.0-beta.21",
48
+ "@docusaurus/mdx-loader": "2.0.0-beta.21",
47
49
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "2.0.0-beta.20",
49
- "@docusaurus/utils-common": "2.0.0-beta.20",
50
- "@docusaurus/utils-validation": "2.0.0-beta.20",
50
+ "@docusaurus/utils": "2.0.0-beta.21",
51
+ "@docusaurus/utils-common": "2.0.0-beta.21",
52
+ "@docusaurus/utils-validation": "2.0.0-beta.21",
51
53
  "@slorber/static-site-generator-webpack-plugin": "^4.0.4",
52
54
  "@svgr/webpack": "^6.2.1",
53
- "autoprefixer": "^10.4.5",
55
+ "autoprefixer": "^10.4.7",
54
56
  "babel-loader": "^8.2.5",
55
- "babel-plugin-dynamic-import-node": "2.3.0",
57
+ "babel-plugin-dynamic-import-node": "^2.3.3",
56
58
  "boxen": "^6.2.1",
59
+ "chalk": "^4.1.2",
57
60
  "chokidar": "^3.5.3",
58
61
  "clean-css": "^5.3.0",
59
62
  "cli-table3": "^0.6.2",
60
63
  "combine-promises": "^1.1.0",
61
64
  "commander": "^5.1.0",
62
- "copy-webpack-plugin": "^10.2.4",
63
- "core-js": "^3.22.3",
65
+ "copy-webpack-plugin": "^11.0.0",
66
+ "core-js": "^3.22.7",
64
67
  "css-loader": "^6.7.1",
65
- "css-minimizer-webpack-plugin": "^3.4.1",
66
- "cssnano": "^5.1.7",
67
- "del": "^6.0.0",
68
+ "css-minimizer-webpack-plugin": "^4.0.0",
69
+ "cssnano": "^5.1.9",
70
+ "del": "^6.1.1",
68
71
  "detect-port": "^1.3.0",
69
72
  "escape-html": "^1.0.3",
70
73
  "eta": "^1.12.3",
@@ -77,16 +80,16 @@
77
80
  "leven": "^3.1.0",
78
81
  "lodash": "^4.17.21",
79
82
  "mini-css-extract-plugin": "^2.6.0",
80
- "postcss": "^8.4.13",
81
- "postcss-loader": "^6.2.1",
83
+ "postcss": "^8.4.14",
84
+ "postcss-loader": "^7.0.0",
82
85
  "prompts": "^2.4.2",
83
86
  "react-dev-utils": "^12.0.1",
84
87
  "react-helmet-async": "^1.3.0",
85
88
  "react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
86
89
  "react-loadable-ssr-addon-v5-slorber": "^1.0.1",
87
- "react-router": "^5.2.0",
90
+ "react-router": "^5.3.3",
88
91
  "react-router-config": "^5.1.1",
89
- "react-router-dom": "^5.2.0",
92
+ "react-router-dom": "^5.3.3",
90
93
  "remark-admonitions": "^1.2.1",
91
94
  "rtl-detect": "^1.0.4",
92
95
  "semver": "^7.3.7",
@@ -97,17 +100,17 @@
97
100
  "update-notifier": "^5.1.0",
98
101
  "url-loader": "^4.1.1",
99
102
  "wait-on": "^6.0.1",
100
- "webpack": "^5.72.0",
103
+ "webpack": "^5.72.1",
101
104
  "webpack-bundle-analyzer": "^4.5.0",
102
- "webpack-dev-server": "^4.8.1",
105
+ "webpack-dev-server": "^4.9.0",
103
106
  "webpack-merge": "^5.8.0",
104
107
  "webpackbar": "^5.0.2"
105
108
  },
106
109
  "devDependencies": {
107
- "@docusaurus/module-type-aliases": "2.0.0-beta.20",
108
- "@docusaurus/types": "2.0.0-beta.20",
110
+ "@docusaurus/module-type-aliases": "2.0.0-beta.21",
111
+ "@docusaurus/types": "2.0.0-beta.21",
109
112
  "@types/detect-port": "^1.3.2",
110
- "@types/react-dom": "^18.0.3",
113
+ "@types/react-dom": "^18.0.5",
111
114
  "@types/react-router-config": "^5.0.6",
112
115
  "@types/rtl-detect": "^1.0.0",
113
116
  "@types/serve-handler": "^6.1.1",
@@ -123,7 +126,7 @@
123
126
  "react-dom": "^16.8.4 || ^17.0.0"
124
127
  },
125
128
  "engines": {
126
- "node": ">=14"
129
+ "node": ">=16.14"
127
130
  },
128
- "gitHead": "ed5cdba401a5948e187e927039b142a0decc702d"
131
+ "gitHead": "69ac49fc6909517f13615ee40290c4bd00c39df4"
129
132
  }