@docusaurus/core 2.0.0-beta.16 → 2.0.0-beta.17

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 (55) hide show
  1. package/lib/babel/preset.js +2 -2
  2. package/lib/choosePort.js +4 -4
  3. package/lib/client/client-lifecycles-dispatcher.js +3 -3
  4. package/lib/client/docusaurus.js +2 -5
  5. package/lib/client/exports/ErrorBoundary.js +4 -5
  6. package/lib/client/exports/Interpolate.js +2 -2
  7. package/lib/client/exports/Link.js +2 -3
  8. package/lib/client/exports/Translate.js +1 -2
  9. package/lib/commands/build.js +12 -14
  10. package/lib/commands/clear.js +3 -3
  11. package/lib/commands/commandUtils.js +1 -1
  12. package/lib/commands/deploy.js +6 -6
  13. package/lib/commands/external.js +1 -1
  14. package/lib/commands/serve.js +7 -8
  15. package/lib/commands/start.js +13 -14
  16. package/lib/commands/swizzle/actions.js +4 -4
  17. package/lib/commands/swizzle/common.js +8 -9
  18. package/lib/commands/swizzle/components.js +7 -10
  19. package/lib/commands/swizzle/config.js +7 -4
  20. package/lib/commands/swizzle/context.js +1 -1
  21. package/lib/commands/swizzle/index.js +1 -1
  22. package/lib/commands/swizzle/prompts.js +2 -2
  23. package/lib/commands/swizzle/tables.js +3 -3
  24. package/lib/commands/swizzle/themes.js +6 -8
  25. package/lib/commands/writeHeadingIds.js +5 -5
  26. package/lib/commands/writeTranslations.js +4 -6
  27. package/lib/index.js +9 -9
  28. package/lib/server/brokenLinks.js +26 -12
  29. package/lib/server/client-modules/index.js +1 -1
  30. package/lib/server/config.js +2 -2
  31. package/lib/server/html-tags/htmlTags.js +3 -3
  32. package/lib/server/html-tags/index.js +1 -1
  33. package/lib/server/i18n.js +7 -6
  34. package/lib/server/index.js +16 -20
  35. package/lib/server/plugins/index.js +14 -19
  36. package/lib/server/plugins/init.js +12 -15
  37. package/lib/server/plugins/pluginIds.js +2 -2
  38. package/lib/server/presets/index.js +2 -3
  39. package/lib/server/routes.js +3 -5
  40. package/lib/server/themes/alias.js +3 -3
  41. package/lib/server/themes/index.js +2 -2
  42. package/lib/server/translations/translations.js +15 -22
  43. package/lib/server/translations/translationsExtractor.js +13 -15
  44. package/lib/server/utils.js +1 -1
  45. package/lib/server/versions/index.js +2 -2
  46. package/lib/webpack/base.js +4 -5
  47. package/lib/webpack/client.js +6 -7
  48. package/lib/webpack/plugins/CleanWebpackPlugin.js +1 -1
  49. package/lib/webpack/plugins/LogPlugin.js +2 -2
  50. package/lib/webpack/plugins/WaitPlugin.js +3 -3
  51. package/lib/webpack/server.js +5 -5
  52. package/lib/webpack/utils.js +16 -19
  53. package/package.json +11 -11
  54. package/lib/server/loadSetup.d.ts +0 -8
  55. package/lib/server/loadSetup.js +0 -25
@@ -8,12 +8,12 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationMessages = exports.localizePluginTranslationFile = exports.writePluginTranslations = exports.writeCodeTranslations = exports.readCodeTranslationFileContent = exports.getCodeTranslationsFilePath = exports.getTranslationsLocaleDirPath = exports.getTranslationsDirPath = exports.writeTranslationFileContent = exports.readTranslationFileContent = exports.ensureTranslationFileContent = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
14
  const utils_1 = require("@docusaurus/utils");
15
15
  const utils_validation_1 = require("@docusaurus/utils-validation");
16
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
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(),
@@ -45,22 +45,18 @@ async function readTranslationFileContent(filePath) {
45
45
  exports.readTranslationFileContent = readTranslationFileContent;
46
46
  function mergeTranslationFileContent({ existingContent = {}, newContent, options, }) {
47
47
  // Apply messagePrefix to all messages
48
- const newContentTransformed = lodash_1.default.mapValues(newContent, (value) => {
49
- var _a;
50
- return ({
51
- ...value,
52
- message: `${(_a = options.messagePrefix) !== null && _a !== void 0 ? _a : ''}${value.message}`,
53
- });
54
- });
48
+ const newContentTransformed = lodash_1.default.mapValues(newContent, (value) => ({
49
+ ...value,
50
+ message: `${options.messagePrefix ?? ''}${value.message}`,
51
+ }));
55
52
  const result = { ...existingContent };
56
53
  // We only add missing keys here, we don't delete existing ones
57
54
  Object.entries(newContentTransformed).forEach(([key, { message, description }]) => {
58
- var _a, _b;
59
55
  result[key] = {
60
56
  // If messages already exist, we don't override them (unless requested)
61
57
  message: options.override
62
58
  ? message
63
- : (_b = (_a = existingContent[key]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : message,
59
+ : existingContent[key]?.message ?? message,
64
60
  description, // description
65
61
  };
66
62
  });
@@ -69,7 +65,7 @@ function mergeTranslationFileContent({ existingContent = {}, newContent, options
69
65
  async function writeTranslationFileContent({ filePath, content: newContent, options = {}, }) {
70
66
  const existingContent = await readTranslationFileContent(filePath);
71
67
  // Warn about potential legacy keys
72
- const unknownKeys = lodash_1.default.difference(Object.keys(existingContent !== null && existingContent !== void 0 ? existingContent : {}), Object.keys(newContent));
68
+ const unknownKeys = lodash_1.default.difference(Object.keys(existingContent ?? {}), Object.keys(newContent));
73
69
  if (unknownKeys.length > 0) {
74
70
  logger_1.default.warn `Some translation keys looks unknown to us in file path=${filePath}.
75
71
  Maybe you should remove them? ${unknownKeys}`;
@@ -167,7 +163,7 @@ async function localizePluginTranslationFile({ siteDir, plugin, locale, translat
167
163
  }
168
164
  exports.localizePluginTranslationFile = localizePluginTranslationFile;
169
165
  async function getPluginsDefaultCodeTranslationMessages(plugins) {
170
- const pluginsMessages = await Promise.all(plugins.map((plugin) => { var _a, _b; return (_b = (_a = plugin.getDefaultCodeTranslationMessages) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : {}; }));
166
+ const pluginsMessages = await Promise.all(plugins.map((plugin) => plugin.getDefaultCodeTranslationMessages?.() ?? {}));
171
167
  return pluginsMessages.reduce((allMessages, pluginMessages) => ({ ...allMessages, ...pluginMessages }), {});
172
168
  }
173
169
  exports.getPluginsDefaultCodeTranslationMessages = getPluginsDefaultCodeTranslationMessages;
@@ -177,12 +173,9 @@ function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMe
177
173
  logger_1.default.warn `Unused default message codes found.
178
174
  Please report this Docusaurus issue. name=${unusedDefaultCodeMessages}`;
179
175
  }
180
- return lodash_1.default.mapValues(extractedCodeTranslations, (messageTranslation, messageId) => {
181
- var _a;
182
- return ({
183
- ...messageTranslation,
184
- message: (_a = defaultCodeMessages[messageId]) !== null && _a !== void 0 ? _a : messageTranslation.message,
185
- });
186
- });
176
+ return lodash_1.default.mapValues(extractedCodeTranslations, (messageTranslation, messageId) => ({
177
+ ...messageTranslation,
178
+ message: defaultCodeMessages[messageId] ?? messageTranslation.message,
179
+ }));
187
180
  }
188
181
  exports.applyDefaultCodeTranslations = applyDefaultCodeTranslations;
@@ -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 fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const traverse_1 = (0, tslib_1.__importDefault)(require("@babel/traverse"));
13
- const generator_1 = (0, tslib_1.__importDefault)(require("@babel/generator"));
14
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const traverse_1 = tslib_1.__importDefault(require("@babel/traverse"));
13
+ const generator_1 = tslib_1.__importDefault(require("@babel/generator"));
14
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
15
  const core_1 = require("@babel/core");
16
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
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
@@ -34,14 +34,13 @@ function getSiteSourceCodeFilePaths(siteDir) {
34
34
  return [path_1.default.join(siteDir, utils_1.SRC_DIR_NAME)];
35
35
  }
36
36
  function getPluginSourceCodeFilePaths(plugin) {
37
- var _a, _b, _c;
38
37
  // The getPathsToWatch() generally returns the js/jsx/ts/tsx/md/mdx file paths
39
38
  // We can use this method as well to know which folders we should try to
40
39
  // extract translations from. Hacky/implicit, but do we want to introduce a
41
40
  // new lifecycle method just for that???
42
- const codePaths = (_b = (_a = plugin.getPathsToWatch) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : [];
41
+ const codePaths = plugin.getPathsToWatch?.() ?? [];
43
42
  // We also include theme code
44
- const themePath = (_c = plugin.getThemePath) === null || _c === void 0 ? void 0 : _c.call(plugin);
43
+ const themePath = plugin.getThemePath?.();
45
44
  if (themePath) {
46
45
  codePaths.push(themePath);
47
46
  }
@@ -119,8 +118,7 @@ https://github.com/pugjs/babel-walk
119
118
  */
120
119
  function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
121
120
  function sourceWarningPart(node) {
122
- var _a;
123
- return `File: ${sourceCodeFilePath} at line ${(_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line}
121
+ return `File: ${sourceCodeFilePath} at line ${node.loc?.start.line}
124
122
  Full code: ${(0, generator_1.default)(node).code}`;
125
123
  }
126
124
  const translations = {};
@@ -142,8 +140,8 @@ Full code: ${(0, generator_1.default)(node).code}`;
142
140
  .node.name === 'translate' ||
143
141
  specifier.get('imported')
144
142
  .node.value === 'translate'));
145
- translateComponentName = defaultImport === null || defaultImport === void 0 ? void 0 : defaultImport.get('local').node.name;
146
- translateFunctionName = callbackImport === null || callbackImport === void 0 ? void 0 : callbackImport.get('local').node.name;
143
+ translateComponentName = defaultImport?.get('local').node.name;
144
+ translateFunctionName = callbackImport?.get('local').node.name;
147
145
  },
148
146
  });
149
147
  (0, traverse_1.default)(ast, {
@@ -213,7 +211,7 @@ ${sourceWarningPart(path.node)}`);
213
211
  message = isJSXText
214
212
  ? singleChildren.node.value.trim().replace(/\s+/g, ' ')
215
213
  : singleChildren.get('expression').evaluate().value;
216
- translations[id !== null && id !== void 0 ? id : message] = {
214
+ translations[id ?? message] = {
217
215
  message,
218
216
  ...(description && { description }),
219
217
  };
@@ -237,8 +235,8 @@ ${sourceWarningPart(path.node)}`);
237
235
  if (firstArgEvaluated.confident &&
238
236
  typeof firstArgEvaluated.value === 'object') {
239
237
  const { message, id, description } = firstArgEvaluated.value;
240
- translations[id !== null && id !== void 0 ? id : message] = {
241
- message: message !== null && message !== void 0 ? message : id,
238
+ translations[id ?? message] = {
239
+ message: message ?? id,
242
240
  ...(description && { description }),
243
241
  };
244
242
  }
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.safeGlobby = exports.getAllFinalRoutes = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  // Recursively get the final routes (routes with no subroutes)
14
14
  function getAllFinalRoutes(routeConfig) {
@@ -8,8 +8,8 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getPluginVersion = exports.getPackageJsonVersion = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const path_1 = tslib_1.__importDefault(require("path"));
13
13
  async function getPackageJsonVersion(packageJsonPath) {
14
14
  if (await fs_extra_1.default.pathExists(packageJsonPath)) {
15
15
  // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
@@ -8,9 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createBaseConfig = exports.getDocusaurusAliases = exports.excludeJS = exports.clientDir = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const mini_css_extract_plugin_1 = (0, tslib_1.__importDefault)(require("mini-css-extract-plugin"));
13
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
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
+ const path_1 = tslib_1.__importDefault(require("path"));
14
14
  const utils_1 = require("./utils");
15
15
  const themes_1 = require("../server/themes");
16
16
  const utils_2 = require("@docusaurus/utils");
@@ -47,7 +47,6 @@ async function getDocusaurusAliases() {
47
47
  }
48
48
  exports.getDocusaurusAliases = getDocusaurusAliases;
49
49
  async function createBaseConfig(props, isServer, minify = true) {
50
- var _a;
51
50
  const { outDir, siteDir, siteConfig, siteConfigPath, baseUrl, generatedFilesDir, routesPaths, siteMetadata, plugins, } = props;
52
51
  const totalPages = routesPaths.length;
53
52
  const isProd = process.env.NODE_ENV === 'production';
@@ -185,7 +184,7 @@ async function createBaseConfig(props, isServer, minify = true) {
185
184
  test: /\.[jt]sx?$/i,
186
185
  exclude: excludeJS,
187
186
  use: [
188
- (0, utils_1.getCustomizableJSLoader)((_a = siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader)({
187
+ (0, utils_1.getCustomizableJSLoader)(siteConfig.webpack?.jsLoader)({
189
188
  isServer,
190
189
  babelOptions: await (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
191
190
  }),
@@ -7,14 +7,13 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
10
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
13
13
  const base_1 = require("./base");
14
- const ChunkAssetPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/ChunkAssetPlugin"));
15
- const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
14
+ const ChunkAssetPlugin_1 = tslib_1.__importDefault(require("./plugins/ChunkAssetPlugin"));
15
+ const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
16
16
  async function createClientConfig(props, minify = true) {
17
- var _a;
18
17
  const isBuilding = process.argv[2] === 'build';
19
18
  const config = await (0, base_1.createBaseConfig)(props, false, minify);
20
19
  const clientConfig = (0, webpack_merge_1.default)(config, {
@@ -38,7 +37,7 @@ async function createClientConfig(props, minify = true) {
38
37
  // When building, include the plugin to force terminate building if errors
39
38
  // happened in the client bundle.
40
39
  if (isBuilding) {
41
- (_a = clientConfig.plugins) === null || _a === void 0 ? void 0 : _a.push({
40
+ clientConfig.plugins?.push({
42
41
  apply: (compiler) => {
43
42
  compiler.hooks.done.tap('client:done', (stats) => {
44
43
  if (stats.hasErrors()) {
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
10
+ const path_1 = tslib_1.__importDefault(require("path"));
11
11
  const del_1 = require("del");
12
12
  class CleanWebpackPlugin {
13
13
  constructor(options = {}) {
@@ -7,8 +7,8 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const webpackbar_1 = (0, tslib_1.__importDefault)(require("webpackbar"));
11
- const formatWebpackMessages_1 = (0, tslib_1.__importDefault)(require("react-dev-utils/formatWebpackMessages"));
10
+ const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
11
+ const formatWebpackMessages_1 = tslib_1.__importDefault(require("react-dev-utils/formatWebpackMessages"));
12
12
  function showError(arr) {
13
13
  console.log(`\n\n${arr.join('\n')}`);
14
14
  }
@@ -7,9 +7,9 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const wait_on_1 = (0, tslib_1.__importDefault)(require("wait-on"));
10
+ const path_1 = tslib_1.__importDefault(require("path"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const wait_on_1 = tslib_1.__importDefault(require("wait-on"));
13
13
  class WaitPlugin {
14
14
  constructor(options) {
15
15
  this.filepath = options.filepath;
@@ -7,14 +7,14 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
- const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
10
+ const path_1 = tslib_1.__importDefault(require("path"));
11
+ const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
12
12
  const base_1 = require("./base");
13
- const WaitPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/WaitPlugin"));
14
- const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
13
+ const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
14
+ const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  // Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
17
- const static_site_generator_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("@slorber/static-site-generator-webpack-plugin"));
17
+ const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
18
18
  async function createServerConfig({ props, onLinksCollected = () => { }, }) {
19
19
  const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, ssrTemplate, siteConfig: { noIndex, trailingSlash }, } = props;
20
20
  const config = await (0, base_1.createBaseConfig)(props, true);
@@ -8,15 +8,15 @@
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 = (0, tslib_1.__importDefault)(require("mini-css-extract-plugin"));
11
+ const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
12
12
  const webpack_merge_1 = require("webpack-merge");
13
- const webpack_1 = (0, tslib_1.__importDefault)(require("webpack"));
14
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
15
- const terser_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("terser-webpack-plugin"));
16
- const css_minimizer_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("css-minimizer-webpack-plugin"));
17
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
18
- const crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
19
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
13
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
14
+ 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
+ const path_1 = tslib_1.__importDefault(require("path"));
18
+ const crypto_1 = tslib_1.__importDefault(require("crypto"));
19
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
20
20
  const utils_1 = require("@docusaurus/utils");
21
21
  // Utility method to get style loaders
22
22
  function getStyleLoaders(isServer, cssOptionsArg = {}) {
@@ -95,7 +95,7 @@ function getBabelOptions({ isServer, babelOptions, } = {}) {
95
95
  };
96
96
  }
97
97
  return {
98
- ...(babelOptions !== null && babelOptions !== void 0 ? babelOptions : { presets: [require.resolve('../babel/preset')] }),
98
+ ...(babelOptions ?? { presets: [require.resolve('../babel/preset')] }),
99
99
  babelrc: false,
100
100
  configFile: false,
101
101
  caller: { name: isServer ? 'server' : 'client' },
@@ -132,7 +132,7 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
132
132
  if (typeof configureWebpack === 'function') {
133
133
  const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content);
134
134
  if (res && typeof res === 'object') {
135
- const customizeRules = mergeStrategy !== null && mergeStrategy !== void 0 ? mergeStrategy : {};
135
+ const customizeRules = mergeStrategy ?? {};
136
136
  return (0, webpack_merge_1.mergeWithCustomize)({
137
137
  customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
138
138
  customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
@@ -143,11 +143,9 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
143
143
  }
144
144
  exports.applyConfigureWebpack = applyConfigureWebpack;
145
145
  function applyConfigurePostCss(configurePostCss, config) {
146
- var _a, _b;
147
146
  // not ideal heuristic but good enough for our use-case?
148
147
  function isPostCssLoader(loader) {
149
- var _a, _b;
150
- return !!((_b = (_a = loader) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.postcssOptions);
148
+ return !!loader?.options?.postcssOptions;
151
149
  }
152
150
  // Does not handle all edge cases, but good enough for now
153
151
  function overridePostCssOptions(entry) {
@@ -163,7 +161,7 @@ function applyConfigurePostCss(configurePostCss, config) {
163
161
  .forEach((rule) => overridePostCssOptions(rule));
164
162
  }
165
163
  }
166
- (_b = (_a = config.module) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach((rule) => overridePostCssOptions(rule));
164
+ config.module?.rules?.forEach((rule) => overridePostCssOptions(rule));
167
165
  return config;
168
166
  }
169
167
  exports.applyConfigurePostCss = applyConfigurePostCss;
@@ -171,7 +169,6 @@ function compile(config) {
171
169
  return new Promise((resolve, reject) => {
172
170
  const compiler = (0, webpack_1.default)(config);
173
171
  compiler.run((err, stats) => {
174
- var _a;
175
172
  if (err) {
176
173
  logger_1.default.error(err.stack || err);
177
174
  // @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
@@ -182,12 +179,12 @@ function compile(config) {
182
179
  reject(err);
183
180
  }
184
181
  // let plugins consume all the stats
185
- const errorsWarnings = stats === null || stats === void 0 ? void 0 : stats.toJson('errors-warnings');
186
- if (stats === null || stats === void 0 ? void 0 : stats.hasErrors()) {
182
+ const errorsWarnings = stats?.toJson('errors-warnings');
183
+ if (stats?.hasErrors()) {
187
184
  reject(new Error('Failed to compile with errors.'));
188
185
  }
189
- if (errorsWarnings && (stats === null || stats === void 0 ? void 0 : stats.hasWarnings())) {
190
- (_a = errorsWarnings.warnings) === null || _a === void 0 ? void 0 : _a.forEach((warning) => {
186
+ if (errorsWarnings && stats?.hasWarnings()) {
187
+ errorsWarnings.warnings?.forEach((warning) => {
191
188
  logger_1.default.warn(warning);
192
189
  });
193
190
  }
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.16",
4
+ "version": "2.0.0-beta.17",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.2",
42
42
  "@babel/runtime-corejs3": "^7.17.2",
43
43
  "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "2.0.0-beta.16",
45
- "@docusaurus/logger": "2.0.0-beta.16",
46
- "@docusaurus/mdx-loader": "2.0.0-beta.16",
44
+ "@docusaurus/cssnano-preset": "2.0.0-beta.17",
45
+ "@docusaurus/logger": "2.0.0-beta.17",
46
+ "@docusaurus/mdx-loader": "2.0.0-beta.17",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "2.0.0-beta.16",
49
- "@docusaurus/utils-common": "2.0.0-beta.16",
50
- "@docusaurus/utils-validation": "2.0.0-beta.16",
48
+ "@docusaurus/utils": "2.0.0-beta.17",
49
+ "@docusaurus/utils-common": "2.0.0-beta.17",
50
+ "@docusaurus/utils-validation": "2.0.0-beta.17",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.1",
52
52
  "@svgr/webpack": "^6.2.1",
53
53
  "autoprefixer": "^10.4.2",
@@ -79,7 +79,7 @@
79
79
  "lodash": "^4.17.21",
80
80
  "mini-css-extract-plugin": "^2.5.3",
81
81
  "nprogress": "^0.2.0",
82
- "postcss": "^8.4.6",
82
+ "postcss": "^8.4.7",
83
83
  "postcss-loader": "^6.2.1",
84
84
  "prompts": "^2.4.2",
85
85
  "react-dev-utils": "^12.0.0",
@@ -106,8 +106,8 @@
106
106
  "webpackbar": "^5.0.2"
107
107
  },
108
108
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "2.0.0-beta.16",
110
- "@docusaurus/types": "2.0.0-beta.16",
109
+ "@docusaurus/module-type-aliases": "2.0.0-beta.17",
110
+ "@docusaurus/types": "2.0.0-beta.17",
111
111
  "@types/detect-port": "^1.3.2",
112
112
  "@types/nprogress": "^0.2.0",
113
113
  "@types/react-dom": "^17.0.11",
@@ -128,5 +128,5 @@
128
128
  "engines": {
129
129
  "node": ">=14"
130
130
  },
131
- "gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
131
+ "gitHead": "0032c0b0480083227af2e1b4da2d3ee6ce992403"
132
132
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import type { Props } from '@docusaurus/types';
8
- export default function loadSetup(name: string): Promise<Props>;
@@ -1,25 +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
- const tslib_1 = require("tslib");
10
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
- const index_1 = require("./index");
12
- // Helper methods to setup dummy/fake projects.
13
- async function loadSetup(name) {
14
- const fixtures = path_1.default.join(__dirname, '__tests__', '__fixtures__');
15
- const simpleSite = path_1.default.join(fixtures, 'simple-site');
16
- const customSite = path_1.default.join(fixtures, 'custom-site');
17
- switch (name) {
18
- case 'custom':
19
- return (0, index_1.load)(customSite);
20
- case 'simple':
21
- default:
22
- return (0, index_1.load)(simpleSite);
23
- }
24
- }
25
- exports.default = loadSetup;