@docusaurus/core 2.0.0-beta.15d451942 → 2.0.0-beta.18

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 (200) hide show
  1. package/bin/beforeCli.mjs +133 -0
  2. package/bin/docusaurus.mjs +279 -0
  3. package/lib/babel/preset.d.ts +8 -3
  4. package/lib/babel/preset.js +8 -7
  5. package/lib/choosePort.js +31 -43
  6. package/lib/client/.eslintrc.js +0 -1
  7. package/lib/client/App.d.ts +1 -2
  8. package/lib/client/App.js +23 -24
  9. package/lib/client/LinksCollector.d.ts +3 -3
  10. package/lib/client/LinksCollector.js +7 -11
  11. package/lib/client/PendingNavigation.d.ts +24 -1
  12. package/lib/client/PendingNavigation.js +5 -7
  13. package/lib/{webpack/sharedModuleAliases.d.ts → client/SiteMetadataDefaults.d.ts} +2 -4
  14. package/lib/client/SiteMetadataDefaults.js +19 -0
  15. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.d.ts +13 -0
  16. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +15 -10
  17. package/lib/client/browserContext.d.ts +11 -0
  18. package/lib/client/browserContext.js +22 -0
  19. package/lib/client/client-lifecycles-dispatcher.d.ts +2 -5
  20. package/lib/client/client-lifecycles-dispatcher.js +6 -10
  21. package/lib/client/clientEntry.js +13 -7
  22. package/lib/client/docusaurus.d.ts +6 -0
  23. package/lib/client/docusaurus.js +16 -25
  24. package/lib/client/docusaurusContext.d.ts +12 -0
  25. package/lib/client/docusaurusContext.js +25 -0
  26. package/lib/client/exports/BrowserOnly.d.ts +2 -3
  27. package/lib/client/exports/BrowserOnly.js +14 -7
  28. package/lib/client/exports/ComponentCreator.d.ts +1 -2
  29. package/lib/client/exports/ComponentCreator.js +40 -19
  30. package/lib/client/exports/ErrorBoundary.d.ts +18 -0
  31. package/lib/client/exports/ErrorBoundary.js +35 -0
  32. package/lib/client/exports/Head.d.ts +2 -3
  33. package/lib/client/exports/Head.js +3 -4
  34. package/lib/client/exports/Interpolate.d.ts +2 -2
  35. package/lib/client/exports/Interpolate.js +20 -26
  36. package/lib/client/exports/Link.d.ts +11 -5
  37. package/lib/client/exports/Link.js +31 -20
  38. package/lib/client/exports/Translate.d.ts +1 -1
  39. package/lib/client/exports/Translate.js +14 -9
  40. package/lib/client/exports/constants.js +1 -11
  41. package/lib/client/exports/isInternalUrl.js +1 -1
  42. package/lib/client/exports/renderRoutes.d.ts +1 -2
  43. package/lib/client/exports/renderRoutes.js +1 -2
  44. package/lib/client/exports/router.d.ts +1 -1
  45. package/lib/client/exports/router.js +1 -1
  46. package/lib/client/exports/useBaseUrl.js +8 -5
  47. package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
  48. package/lib/client/exports/useDocusaurusContext.js +3 -9
  49. package/lib/client/exports/useGlobalData.d.ts +4 -3
  50. package/lib/client/exports/useGlobalData.js +4 -8
  51. package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
  52. package/lib/client/exports/useIsBrowser.js +11 -0
  53. package/lib/{server/loadSetup.d.ts → client/exports/useRouteContext.d.ts} +2 -3
  54. package/lib/client/exports/useRouteContext.js +15 -0
  55. package/lib/client/flat.d.ts +4 -2
  56. package/lib/client/flat.js +9 -13
  57. package/lib/client/normalizeLocation.d.ts +2 -5
  58. package/lib/client/normalizeLocation.js +2 -7
  59. package/lib/client/nprogress.css +2 -2
  60. package/lib/client/prefetch.d.ts +1 -2
  61. package/lib/client/prefetch.js +4 -6
  62. package/lib/client/preload.d.ts +3 -2
  63. package/lib/client/preload.js +5 -10
  64. package/lib/client/routeContext.d.ts +13 -0
  65. package/lib/client/routeContext.js +31 -0
  66. package/lib/client/serverEntry.d.ts +10 -0
  67. package/lib/client/serverEntry.js +90 -142
  68. package/lib/client/theme-fallback/Error/index.d.ts +10 -0
  69. package/lib/client/theme-fallback/Error/index.js +43 -0
  70. package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
  71. package/lib/client/theme-fallback/Layout/index.js +2 -26
  72. package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
  73. package/lib/client/theme-fallback/Loading/index.js +47 -115
  74. package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
  75. package/lib/client/theme-fallback/NotFound/index.js +17 -18
  76. package/lib/client/theme-fallback/Root/index.d.ts +10 -0
  77. package/lib/client/theme-fallback/Root/index.js +2 -6
  78. package/lib/client/theme-fallback/SiteMetadata/index.d.ts +8 -0
  79. package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
  80. package/lib/commands/build.d.ts +1 -1
  81. package/lib/commands/build.js +50 -54
  82. package/lib/commands/clear.d.ts +6 -0
  83. package/lib/commands/clear.js +30 -19
  84. package/lib/commands/commandUtils.d.ts +7 -1
  85. package/lib/commands/commandUtils.js +7 -7
  86. package/lib/commands/deploy.d.ts +1 -1
  87. package/lib/commands/deploy.js +83 -66
  88. package/lib/commands/external.d.ts +2 -2
  89. package/lib/commands/external.js +4 -8
  90. package/lib/commands/serve.d.ts +1 -1
  91. package/lib/commands/serve.js +25 -12
  92. package/lib/commands/start.d.ts +1 -1
  93. package/lib/commands/start.js +96 -87
  94. package/lib/commands/swizzle/actions.d.ts +23 -0
  95. package/lib/commands/swizzle/actions.js +101 -0
  96. package/lib/commands/swizzle/common.d.ts +33 -0
  97. package/lib/commands/swizzle/common.js +56 -0
  98. package/lib/commands/swizzle/components.d.ts +29 -0
  99. package/lib/commands/swizzle/components.js +162 -0
  100. package/lib/commands/swizzle/config.d.ts +10 -0
  101. package/lib/commands/swizzle/config.js +80 -0
  102. package/lib/commands/swizzle/context.d.ts +8 -0
  103. package/lib/commands/swizzle/context.js +28 -0
  104. package/lib/commands/swizzle/index.d.ts +8 -0
  105. package/lib/commands/swizzle/index.js +115 -0
  106. package/lib/commands/swizzle/prompts.d.ts +12 -0
  107. package/lib/commands/swizzle/prompts.js +110 -0
  108. package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
  109. package/lib/commands/swizzle/tables.js +113 -0
  110. package/lib/commands/swizzle/themes.d.ts +20 -0
  111. package/lib/commands/swizzle/themes.js +106 -0
  112. package/lib/commands/writeHeadingIds.d.ts +2 -6
  113. package/lib/commands/writeHeadingIds.js +19 -76
  114. package/lib/commands/writeTranslations.d.ts +2 -2
  115. package/lib/commands/writeTranslations.js +37 -17
  116. package/lib/index.d.ts +10 -9
  117. package/lib/index.js +20 -19
  118. package/lib/server/brokenLinks.d.ts +4 -17
  119. package/lib/server/brokenLinks.js +64 -52
  120. package/lib/server/client-modules/index.d.ts +2 -2
  121. package/lib/server/client-modules/index.js +4 -3
  122. package/lib/server/config.d.ts +2 -2
  123. package/lib/server/config.js +8 -5
  124. package/lib/server/configValidation.d.ts +4 -2
  125. package/lib/server/configValidation.js +93 -37
  126. package/lib/server/duplicateRoutes.d.ts +1 -3
  127. package/lib/server/duplicateRoutes.js +17 -13
  128. package/lib/server/html-tags/htmlTags.js +7 -8
  129. package/lib/server/html-tags/index.d.ts +2 -3
  130. package/lib/server/html-tags/index.js +3 -4
  131. package/lib/server/i18n.d.ts +2 -3
  132. package/lib/server/i18n.js +27 -48
  133. package/lib/server/index.d.ts +9 -2
  134. package/lib/server/index.js +175 -96
  135. package/lib/server/moduleShorthand.d.ts +9 -0
  136. package/lib/server/moduleShorthand.js +46 -0
  137. package/lib/server/plugins/applyRouteTrailingSlash.d.ts +9 -0
  138. package/lib/server/plugins/applyRouteTrailingSlash.js +19 -0
  139. package/lib/server/plugins/index.d.ts +4 -5
  140. package/lib/server/plugins/index.js +69 -45
  141. package/lib/server/plugins/init.d.ts +15 -5
  142. package/lib/server/plugins/init.js +68 -81
  143. package/lib/server/plugins/pluginIds.d.ts +2 -2
  144. package/lib/server/plugins/pluginIds.js +8 -5
  145. package/lib/server/presets/index.d.ts +3 -3
  146. package/lib/server/presets/index.js +16 -23
  147. package/lib/server/routes.d.ts +3 -5
  148. package/lib/server/routes.js +68 -36
  149. package/lib/server/themes/alias.d.ts +3 -2
  150. package/lib/server/themes/alias.js +24 -13
  151. package/lib/server/themes/index.d.ts +6 -2
  152. package/lib/server/themes/index.js +36 -24
  153. package/lib/server/translations/translations.d.ts +21 -17
  154. package/lib/server/translations/translations.js +33 -54
  155. package/lib/server/translations/translationsExtractor.d.ts +12 -5
  156. package/lib/server/translations/translationsExtractor.js +159 -121
  157. package/lib/server/utils.d.ts +9 -3
  158. package/lib/server/utils.js +7 -9
  159. package/lib/server/versions/index.d.ts +3 -4
  160. package/lib/server/versions/index.js +22 -24
  161. package/lib/webpack/base.d.ts +6 -4
  162. package/lib/webpack/base.js +51 -36
  163. package/lib/webpack/client.d.ts +3 -3
  164. package/lib/webpack/client.js +12 -19
  165. package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
  166. package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
  167. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -6
  168. package/lib/webpack/plugins/CleanWebpackPlugin.js +10 -16
  169. package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
  170. package/lib/webpack/plugins/LogPlugin.js +4 -5
  171. package/lib/webpack/plugins/WaitPlugin.d.ts +1 -1
  172. package/lib/webpack/plugins/WaitPlugin.js +1 -1
  173. package/lib/webpack/server.d.ts +3 -3
  174. package/lib/webpack/server.js +14 -7
  175. package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
  176. package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
  177. package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
  178. package/lib/webpack/utils.d.ts +15 -30
  179. package/lib/webpack/utils.js +57 -175
  180. package/package.json +77 -70
  181. package/bin/docusaurus.js +0 -326
  182. package/lib/.tsbuildinfo +0 -5732
  183. package/lib/client/.tsbuildinfo +0 -4171
  184. package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
  185. package/lib/commands/buildRemoteBranchUrl.js +0 -27
  186. package/lib/commands/swizzle.d.ts +0 -9
  187. package/lib/commands/swizzle.js +0 -245
  188. package/lib/constants.d.ts +0 -18
  189. package/lib/constants.js +0 -23
  190. package/lib/server/loadSetup.js +0 -25
  191. package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
  192. package/lib/server/versions/__fixtures__/package.json +0 -3
  193. package/lib/server/versions/__tests/index.test.js +0 -25
  194. package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
  195. package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
  196. package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
  197. package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
  198. package/lib/webpack/sharedModuleAliases.js +0 -18
  199. package/tsconfig.client.json +0 -13
  200. package/tsconfig.json +0 -13
@@ -7,32 +7,31 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const lodash_1 = require("lodash");
11
10
  const html_tags_1 = tslib_1.__importDefault(require("html-tags"));
12
11
  const void_1 = tslib_1.__importDefault(require("html-tags/void"));
12
+ const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
13
13
  function assertIsHtmlTagObject(val) {
14
- if (!lodash_1.isPlainObject(val)) {
15
- throw new Error(`"${val}" is not a valid HTML tag object`);
14
+ if (typeof val !== 'object' || !val) {
15
+ throw new Error(`"${val}" is not a valid HTML tag object.`);
16
16
  }
17
- // @ts-expect-error: If tagName doesn't exist, it will throw.
18
17
  if (typeof val.tagName !== 'string') {
19
- throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string`);
18
+ throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string.`);
20
19
  }
21
20
  }
22
21
  function htmlTagObjectToString(tagDefinition) {
23
22
  assertIsHtmlTagObject(tagDefinition);
24
23
  if (html_tags_1.default.indexOf(tagDefinition.tagName) === -1) {
25
- throw new Error(`Error loading ${JSON.stringify(tagDefinition)}, "${tagDefinition.tagName}" is not a valid HTML tags`);
24
+ throw new Error(`Error loading ${JSON.stringify(tagDefinition)}, "${tagDefinition.tagName}" is not a valid HTML tags.`);
26
25
  }
27
26
  const isVoidTag = void_1.default.indexOf(tagDefinition.tagName) !== -1;
28
- const tagAttributes = tagDefinition.attributes || {};
27
+ const tagAttributes = tagDefinition.attributes ?? {};
29
28
  const attributes = Object.keys(tagAttributes)
30
29
  .filter((attributeName) => tagAttributes[attributeName] !== false)
31
30
  .map((attributeName) => {
32
31
  if (tagAttributes[attributeName] === true) {
33
32
  return attributeName;
34
33
  }
35
- return `${attributeName}="${tagAttributes[attributeName]}"`;
34
+ return `${attributeName}="${(0, escape_html_1.default)(tagAttributes[attributeName])}"`;
36
35
  });
37
36
  return `<${[tagDefinition.tagName].concat(attributes).join(' ')}>${(!isVoidTag && tagDefinition.innerHTML) || ''}${isVoidTag ? '' : `</${tagDefinition.tagName}>`}`;
38
37
  }
@@ -4,6 +4,5 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { Plugin, InjectedHtmlTags, HtmlTags } from '@docusaurus/types';
8
- export declare function createHtmlTagsString(tags: HtmlTags): string;
9
- export declare function loadHtmlTags(plugins: Plugin<unknown>[]): InjectedHtmlTags;
7
+ import type { InjectedHtmlTags, LoadedPlugin } from '@docusaurus/types';
8
+ export declare function loadHtmlTags(plugins: LoadedPlugin[]): InjectedHtmlTags;
@@ -6,22 +6,21 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.loadHtmlTags = exports.createHtmlTagsString = void 0;
9
+ exports.loadHtmlTags = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const htmlTags_1 = tslib_1.__importDefault(require("./htmlTags"));
12
12
  function toString(val) {
13
- return typeof val === 'string' ? val : htmlTags_1.default(val);
13
+ return typeof val === 'string' ? val : (0, htmlTags_1.default)(val);
14
14
  }
15
15
  function createHtmlTagsString(tags) {
16
16
  return Array.isArray(tags) ? tags.map(toString).join('\n') : toString(tags);
17
17
  }
18
- exports.createHtmlTagsString = createHtmlTagsString;
19
18
  function loadHtmlTags(plugins) {
20
19
  const htmlTags = plugins.reduce((acc, plugin) => {
21
20
  if (!plugin.injectHtmlTags) {
22
21
  return acc;
23
22
  }
24
- const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags() || {};
23
+ const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content }) ?? {};
25
24
  return {
26
25
  headTags: headTags
27
26
  ? `${acc.headTags}\n${createHtmlTagsString(headTags)}`
@@ -4,10 +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 { I18n, DocusaurusConfig, I18nLocaleConfig } from '@docusaurus/types';
7
+ import type { I18n, DocusaurusConfig, I18nLocaleConfig } from '@docusaurus/types';
8
8
  export declare function getDefaultLocaleConfig(locale: string): I18nLocaleConfig;
9
- export declare function shouldWarnAboutNodeVersion(version: number, locales: string[]): boolean;
10
- export declare function loadI18n(config: DocusaurusConfig, options?: {
9
+ export declare function loadI18n(config: DocusaurusConfig, options: {
11
10
  locale?: string;
12
11
  }): Promise<I18n>;
13
12
  export declare function localizePath({ pathType, path: originalPath, i18n, options, }: {
@@ -1,58 +1,46 @@
1
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
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localizePath = exports.loadI18n = exports.shouldWarnAboutNodeVersion = exports.getDefaultLocaleConfig = void 0;
9
+ exports.localizePath = exports.loadI18n = exports.getDefaultLocaleConfig = void 0;
4
10
  const tslib_1 = require("tslib");
5
11
  const path_1 = tslib_1.__importDefault(require("path"));
6
12
  const utils_1 = require("@docusaurus/utils");
7
13
  const rtl_detect_1 = require("rtl-detect");
8
- const constants_1 = require("../constants");
9
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
14
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
10
15
  function getDefaultLocaleLabel(locale) {
11
- // Intl.DisplayNames is ES2021 - Node14+
12
- // https://v8.dev/features/intl-displaynames
13
- // @ts-expect-error: wait for TS support of ES2021 feature
14
- if (typeof Intl.DisplayNames !== 'undefined') {
15
- // @ts-expect-error: wait for TS support of ES2021 feature
16
- return new Intl.DisplayNames([locale], { type: 'language' }).of(locale);
17
- }
18
- return locale;
16
+ const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
17
+ return (languageName.charAt(0).toLocaleUpperCase(locale) + languageName.substring(1));
19
18
  }
20
19
  function getDefaultLocaleConfig(locale) {
21
20
  return {
22
21
  label: getDefaultLocaleLabel(locale),
23
- direction: rtl_detect_1.getLangDir(locale),
22
+ direction: (0, rtl_detect_1.getLangDir)(locale),
23
+ htmlLang: locale,
24
24
  };
25
25
  }
26
26
  exports.getDefaultLocaleConfig = getDefaultLocaleConfig;
27
- function shouldWarnAboutNodeVersion(version, locales) {
28
- const isOnlyEnglish = locales.length === 1 && locales.includes('en');
29
- const isOlderNodeVersion = version < 14;
30
- return isOlderNodeVersion && !isOnlyEnglish;
31
- }
32
- exports.shouldWarnAboutNodeVersion = shouldWarnAboutNodeVersion;
33
- async function loadI18n(config, options = {}) {
34
- var _a;
27
+ async function loadI18n(config, options) {
35
28
  const { i18n: i18nConfig } = config;
36
- const currentLocale = (_a = options.locale) !== null && _a !== void 0 ? _a : i18nConfig.defaultLocale;
29
+ const currentLocale = options.locale ?? i18nConfig.defaultLocale;
37
30
  if (!i18nConfig.locales.includes(currentLocale)) {
38
- console.warn(chalk_1.default.yellow(`The locale=${currentLocale} was not found in your site configuration: config.i18n.locales=[${i18nConfig.locales.join(',')}]
39
- Note: Docusaurus only support running one locale at a time.`));
31
+ logger_1.default.warn `The locale name=${currentLocale} was not found in your site configuration: Available locales are: ${i18nConfig.locales}
32
+ Note: Docusaurus only support running one locale at a time.`;
40
33
  }
41
34
  const locales = i18nConfig.locales.includes(currentLocale)
42
35
  ? i18nConfig.locales
43
36
  : i18nConfig.locales.concat(currentLocale);
44
- if (shouldWarnAboutNodeVersion(constants_1.NODE_MAJOR_VERSION, locales)) {
45
- console.warn(chalk_1.default.yellow(`To use Docusaurus i18n, it is strongly advised to use NodeJS >= 14 (instead of ${constants_1.NODE_MAJOR_VERSION})`));
46
- }
47
37
  function getLocaleConfig(locale) {
48
38
  return {
49
39
  ...getDefaultLocaleConfig(locale),
50
40
  ...i18nConfig.localeConfigs[locale],
51
41
  };
52
42
  }
53
- const localeConfigs = locales.reduce((acc, locale) => {
54
- return { ...acc, [locale]: getLocaleConfig(locale) };
55
- }, {});
43
+ const localeConfigs = locales.reduce((acc, locale) => ({ ...acc, [locale]: getLocaleConfig(locale) }), {});
56
44
  return {
57
45
  defaultLocale: i18nConfig.defaultLocale,
58
46
  locales,
@@ -62,26 +50,17 @@ Note: Docusaurus only support running one locale at a time.`));
62
50
  }
63
51
  exports.loadI18n = loadI18n;
64
52
  function localizePath({ pathType, path: originalPath, i18n, options = {}, }) {
65
- const shouldLocalizePath = typeof options.localizePath === 'undefined'
66
- ? // By default, we don't localize the path of defaultLocale
67
- i18n.currentLocale !== i18n.defaultLocale
68
- : options.localizePath;
69
- if (shouldLocalizePath) {
70
- // FS paths need special care, for Windows support
71
- if (pathType === 'fs') {
72
- return path_1.default.join(originalPath, path_1.default.sep, i18n.currentLocale, path_1.default.sep);
73
- }
74
- // Url paths
75
- else if (pathType === 'url') {
76
- return utils_1.normalizeUrl([originalPath, '/', i18n.currentLocale, '/']);
77
- }
78
- // should never happen
79
- else {
80
- throw new Error(`unhandled pathType=${pathType}`);
81
- }
82
- }
83
- else {
53
+ const shouldLocalizePath =
54
+ // By default, we don't localize the path of defaultLocale
55
+ options.localizePath ?? i18n.currentLocale !== i18n.defaultLocale;
56
+ if (!shouldLocalizePath) {
84
57
  return originalPath;
85
58
  }
59
+ // FS paths need special care, for Windows support
60
+ if (pathType === 'fs') {
61
+ return path_1.default.join(originalPath, i18n.currentLocale);
62
+ }
63
+ // Url paths; add a trailing slash so it's a valid base URL
64
+ return (0, utils_1.normalizeUrl)([originalPath, i18n.currentLocale, '/']);
86
65
  }
87
66
  exports.localizePath = localizePath;
@@ -4,13 +4,20 @@
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 { LoadContext, PluginConfig, Props } from '@docusaurus/types';
7
+ import type { DocusaurusConfig, LoadContext, PluginConfig, Props } from '@docusaurus/types';
8
8
  export declare type LoadContextOptions = {
9
9
  customOutDir?: string;
10
10
  customConfigFilePath?: string;
11
11
  locale?: string;
12
12
  localizePath?: boolean;
13
13
  };
14
+ export declare function loadSiteConfig({ siteDir, customConfigFilePath, }: {
15
+ siteDir: string;
16
+ customConfigFilePath?: string;
17
+ }): Promise<{
18
+ siteConfig: DocusaurusConfig;
19
+ siteConfigPath: string;
20
+ }>;
14
21
  export declare function loadContext(siteDir: string, options?: LoadContextOptions): Promise<LoadContext>;
15
- export declare function loadPluginConfigs(context: LoadContext): PluginConfig[];
22
+ export declare function loadPluginConfigs(context: LoadContext): Promise<PluginConfig[]>;
16
23
  export declare function load(siteDir: string, options?: LoadContextOptions): Promise<Props>;
@@ -6,60 +6,61 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.load = exports.loadPluginConfigs = exports.loadContext = void 0;
9
+ exports.load = exports.loadPluginConfigs = exports.loadContext = exports.loadSiteConfig = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_1 = require("@docusaurus/utils");
12
- const path_1 = tslib_1.__importStar(require("path"));
13
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
14
- const ssr_html_template_1 = tslib_1.__importDefault(require("../client/templates/ssr.html.template"));
15
- const constants_1 = require("../constants");
12
+ const path_1 = tslib_1.__importDefault(require("path"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const ssr_html_template_1 = tslib_1.__importDefault(require("../webpack/templates/ssr.html.template"));
16
15
  const client_modules_1 = tslib_1.__importDefault(require("./client-modules"));
17
16
  const config_1 = tslib_1.__importDefault(require("./config"));
18
17
  const plugins_1 = require("./plugins");
19
18
  const presets_1 = tslib_1.__importDefault(require("./presets"));
20
19
  const routes_1 = tslib_1.__importDefault(require("./routes"));
21
- const themes_1 = tslib_1.__importDefault(require("./themes"));
22
20
  const html_tags_1 = require("./html-tags");
23
21
  const versions_1 = require("./versions");
24
22
  const duplicateRoutes_1 = require("./duplicateRoutes");
25
23
  const i18n_1 = require("./i18n");
26
24
  const translations_1 = require("./translations/translations");
27
- const lodash_1 = require("lodash");
25
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
26
+ const remark_admonitions_1 = tslib_1.__importDefault(require("remark-admonitions"));
27
+ const module_1 = require("module");
28
+ const moduleShorthand_1 = require("./moduleShorthand");
29
+ async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
30
+ const siteConfigPath = path_1.default.resolve(siteDir, customConfigFilePath ?? utils_1.DEFAULT_CONFIG_FILE_NAME);
31
+ const siteConfig = await (0, config_1.default)(siteConfigPath);
32
+ return { siteConfig, siteConfigPath };
33
+ }
34
+ exports.loadSiteConfig = loadSiteConfig;
28
35
  async function loadContext(siteDir, options = {}) {
29
- var _a;
30
36
  const { customOutDir, locale, customConfigFilePath } = options;
31
- const generatedFilesDir = path_1.default.isAbsolute(constants_1.GENERATED_FILES_DIR_NAME)
32
- ? constants_1.GENERATED_FILES_DIR_NAME
33
- : path_1.default.resolve(siteDir, constants_1.GENERATED_FILES_DIR_NAME);
34
- const siteConfigPathUnresolved = customConfigFilePath !== null && customConfigFilePath !== void 0 ? customConfigFilePath : constants_1.DEFAULT_CONFIG_FILE_NAME;
35
- const siteConfigPath = path_1.default.isAbsolute(siteConfigPathUnresolved)
36
- ? siteConfigPathUnresolved
37
- : path_1.default.resolve(siteDir, siteConfigPathUnresolved);
38
- const initialSiteConfig = config_1.default(siteConfigPath);
37
+ const generatedFilesDir = path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
38
+ const { siteConfig: initialSiteConfig, siteConfigPath } = await loadSiteConfig({
39
+ siteDir,
40
+ customConfigFilePath,
41
+ });
39
42
  const { ssrTemplate } = initialSiteConfig;
40
- const baseOutDir = customOutDir
41
- ? path_1.default.resolve(customOutDir)
42
- : path_1.default.resolve(siteDir, constants_1.DEFAULT_BUILD_DIR_NAME);
43
- const i18n = await i18n_1.loadI18n(initialSiteConfig, { locale });
44
- const baseUrl = i18n_1.localizePath({
43
+ const baseOutDir = path_1.default.resolve(siteDir, customOutDir ?? utils_1.DEFAULT_BUILD_DIR_NAME);
44
+ const i18n = await (0, i18n_1.loadI18n)(initialSiteConfig, { locale });
45
+ const baseUrl = (0, i18n_1.localizePath)({
45
46
  path: initialSiteConfig.baseUrl,
46
47
  i18n,
47
48
  options,
48
49
  pathType: 'url',
49
50
  });
50
- const outDir = i18n_1.localizePath({
51
+ const outDir = (0, i18n_1.localizePath)({
51
52
  path: baseOutDir,
52
53
  i18n,
53
54
  options,
54
55
  pathType: 'fs',
55
56
  });
56
57
  const siteConfig = { ...initialSiteConfig, baseUrl };
57
- const codeTranslationFileContent = (_a = (await translations_1.readCodeTranslationFileContent({
58
+ const codeTranslationFileContent = (await (0, translations_1.readCodeTranslationFileContent)({
58
59
  siteDir,
59
60
  locale: i18n.currentLocale,
60
- }))) !== null && _a !== void 0 ? _a : {};
61
+ })) ?? {};
61
62
  // We only need key->message for code translations
62
- const codeTranslations = lodash_1.mapValues(codeTranslationFileContent, (value) => value.message);
63
+ const codeTranslations = lodash_1.default.mapValues(codeTranslationFileContent, (value) => value.message);
63
64
  return {
64
65
  siteDir,
65
66
  generatedFilesDir,
@@ -68,62 +69,57 @@ async function loadContext(siteDir, options = {}) {
68
69
  outDir,
69
70
  baseUrl,
70
71
  i18n,
71
- ssrTemplate,
72
+ ssrTemplate: ssrTemplate ?? ssr_html_template_1.default,
72
73
  codeTranslations,
73
74
  };
74
75
  }
75
76
  exports.loadContext = loadContext;
76
- function loadPluginConfigs(context) {
77
- const { plugins: presetPlugins, themes: presetThemes } = presets_1.default(context);
78
- const { siteConfig } = context;
77
+ async function loadPluginConfigs(context) {
78
+ let { plugins: presetPlugins, themes: presetThemes } = await (0, presets_1.default)(context);
79
+ const { siteConfig, siteConfigPath } = context;
80
+ const require = (0, module_1.createRequire)(siteConfigPath);
81
+ function normalizeShorthand(pluginConfig, pluginType) {
82
+ if (typeof pluginConfig === 'string') {
83
+ return (0, moduleShorthand_1.resolveModuleName)(pluginConfig, require, pluginType);
84
+ }
85
+ else if (Array.isArray(pluginConfig) &&
86
+ typeof pluginConfig[0] === 'string') {
87
+ return [
88
+ (0, moduleShorthand_1.resolveModuleName)(pluginConfig[0], require, pluginType),
89
+ pluginConfig[1] ?? {},
90
+ ];
91
+ }
92
+ return pluginConfig;
93
+ }
94
+ presetPlugins = presetPlugins.map((plugin) => normalizeShorthand(plugin, 'plugin'));
95
+ presetThemes = presetThemes.map((theme) => normalizeShorthand(theme, 'theme'));
96
+ const standalonePlugins = siteConfig.plugins.map((plugin) => normalizeShorthand(plugin, 'plugin'));
97
+ const standaloneThemes = siteConfig.themes.map((theme) => normalizeShorthand(theme, 'theme'));
79
98
  return [
80
99
  ...presetPlugins,
81
100
  ...presetThemes,
82
101
  // Site config should be the highest priority.
83
- ...(siteConfig.plugins || []),
84
- ...(siteConfig.themes || []),
102
+ ...standalonePlugins,
103
+ ...standaloneThemes,
85
104
  ];
86
105
  }
87
106
  exports.loadPluginConfigs = loadPluginConfigs;
88
- async function load(siteDir, options = {}) {
89
- // Context.
90
- const context = await loadContext(siteDir, options);
91
- const { generatedFilesDir, siteConfig, siteConfigPath, outDir, baseUrl, i18n, ssrTemplate, codeTranslations, } = context;
92
- // Plugins.
93
- const pluginConfigs = loadPluginConfigs(context);
94
- const { plugins, pluginsRouteConfigs, globalData, themeConfigTranslated, } = await plugins_1.loadPlugins({
95
- pluginConfigs,
96
- context,
97
- });
98
- // Side-effect to replace the untranslated themeConfig by the translated one
99
- context.siteConfig.themeConfig = themeConfigTranslated;
100
- duplicateRoutes_1.handleDuplicateRoutes(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
101
- // Site config must be generated after plugins
102
- // We want the generated config to have been normalized by the plugins!
103
- const genSiteConfig = utils_1.generate(generatedFilesDir, constants_1.DEFAULT_CONFIG_FILE_NAME, `export default ${JSON.stringify(siteConfig, null, 2)};`);
104
- // Themes.
105
- const fallbackTheme = path_1.default.resolve(__dirname, '../client/theme-fallback');
106
- const pluginThemes = plugins
107
- .map((plugin) => plugin.getThemePath && plugin.getThemePath())
108
- .filter((x) => Boolean(x));
109
- const userTheme = path_1.default.resolve(siteDir, constants_1.THEME_PATH);
110
- const alias = themes_1.default([fallbackTheme, ...pluginThemes], [userTheme]);
111
- // Make a fake plugin to:
112
- // - Resolve aliased theme components
113
- // - Inject scripts/stylesheets
114
- const { stylesheets = [], scripts = [], clientModules: siteConfigClientModules = [], } = siteConfig;
115
- plugins.push({
107
+ // Make a fake plugin to:
108
+ // - Resolve aliased theme components
109
+ // - Inject scripts/stylesheets
110
+ function createBootstrapPlugin({ siteDir, siteConfig, }) {
111
+ const { stylesheets, scripts, clientModules: siteConfigClientModules, } = siteConfig;
112
+ return {
116
113
  name: 'docusaurus-bootstrap-plugin',
117
- options: {},
114
+ content: null,
115
+ options: {
116
+ id: 'default',
117
+ },
118
118
  version: { type: 'synthetic' },
119
+ path: siteDir,
119
120
  getClientModules() {
120
121
  return siteConfigClientModules;
121
122
  },
122
- configureWebpack: () => ({
123
- resolve: {
124
- alias,
125
- },
126
- }),
127
123
  injectHtmlTags: () => {
128
124
  const stylesheetsTags = stylesheets.map((source) => typeof source === 'string'
129
125
  ? `<link rel="stylesheet" href="${source}">`
@@ -135,11 +131,10 @@ async function load(siteDir, options = {}) {
135
131
  },
136
132
  });
137
133
  const scriptsTags = scripts.map((source) => typeof source === 'string'
138
- ? `<script type="text/javascript" src="${source}"></script>`
134
+ ? `<script src="${source}"></script>`
139
135
  : {
140
136
  tagName: 'script',
141
137
  attributes: {
142
- type: 'text/javascript',
143
138
  ...source,
144
139
  },
145
140
  });
@@ -147,39 +142,120 @@ async function load(siteDir, options = {}) {
147
142
  headTags: [...stylesheetsTags, ...scriptsTags],
148
143
  };
149
144
  },
150
- });
145
+ };
146
+ }
147
+ /**
148
+ * Configure Webpack fallback mdx loader for md/mdx files out of content-plugin
149
+ * folders. Adds a "fallback" mdx loader for mdx files that are not processed by
150
+ * content plugins. This allows to do things such as importing repo/README.md as
151
+ * a partial from another doc. Not ideal solution, but good enough for now
152
+ */
153
+ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
154
+ return {
155
+ name: 'docusaurus-mdx-fallback-plugin',
156
+ content: null,
157
+ options: {
158
+ id: 'default',
159
+ },
160
+ version: { type: 'synthetic' },
161
+ // Synthetic, the path doesn't matter much
162
+ path: '.',
163
+ configureWebpack(config, isServer, { getJSLoader }) {
164
+ // We need the mdx fallback loader to exclude files that were already
165
+ // processed by content plugins mdx loaders. This works, but a bit
166
+ // hacky... Not sure there's a way to handle that differently in webpack
167
+ function getMDXFallbackExcludedPaths() {
168
+ const rules = config?.module?.rules;
169
+ return rules.flatMap((rule) => {
170
+ const isMDXRule = rule.test instanceof RegExp && rule.test.test('x.mdx');
171
+ return isMDXRule ? rule.include : [];
172
+ });
173
+ }
174
+ return {
175
+ module: {
176
+ rules: [
177
+ {
178
+ test: /\.mdx?$/i,
179
+ exclude: getMDXFallbackExcludedPaths(),
180
+ use: [
181
+ getJSLoader({ isServer }),
182
+ {
183
+ loader: require.resolve('@docusaurus/mdx-loader'),
184
+ options: {
185
+ staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
186
+ siteDir,
187
+ isMDXPartial: () => true,
188
+ isMDXPartialFrontMatterWarningDisabled: true,
189
+ remarkPlugins: [remark_admonitions_1.default],
190
+ },
191
+ },
192
+ ],
193
+ },
194
+ ],
195
+ },
196
+ };
197
+ },
198
+ };
199
+ }
200
+ async function load(siteDir, options = {}) {
201
+ // Context.
202
+ const context = await loadContext(siteDir, options);
203
+ const { generatedFilesDir, siteConfig, siteConfigPath, outDir, baseUrl, i18n, ssrTemplate, codeTranslations, } = context;
204
+ // Plugins.
205
+ const pluginConfigs = await loadPluginConfigs(context);
206
+ const { plugins, pluginsRouteConfigs, globalData, themeConfigTranslated } = await (0, plugins_1.loadPlugins)({ pluginConfigs, context });
207
+ // Side-effect to replace the untranslated themeConfig by the translated one
208
+ context.siteConfig.themeConfig = themeConfigTranslated;
209
+ (0, duplicateRoutes_1.handleDuplicateRoutes)(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
210
+ const genWarning = (0, utils_1.generate)(generatedFilesDir, 'DONT-EDIT-THIS-FOLDER', `This folder stores temp files that Docusaurus' client bundler accesses.
211
+
212
+ DO NOT hand-modify files in this folder because they will be overwritten in the
213
+ next build. You can clear all build artifacts (including this folder) with the
214
+ \`docusaurus clear\` command.
215
+ `);
216
+ // Site config must be generated after plugins
217
+ // We want the generated config to have been normalized by the plugins!
218
+ const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, utils_1.DEFAULT_CONFIG_FILE_NAME, `/*
219
+ * AUTOGENERATED - DON'T EDIT
220
+ * Your edits in this file will be overwritten in the next build!
221
+ * Modify the docusaurus.config.js file at your site's root instead.
222
+ */
223
+ export default ${JSON.stringify(siteConfig, null, 2)};
224
+ `);
225
+ plugins.push(createBootstrapPlugin({ siteDir, siteConfig }), createMDXFallbackPlugin({ siteDir, siteConfig }));
151
226
  // Load client modules.
152
- const clientModules = client_modules_1.default(plugins);
153
- const genClientModules = utils_1.generate(generatedFilesDir, 'client-modules.js', `export default [\n${clientModules
227
+ const clientModules = (0, client_modules_1.default)(plugins);
228
+ const genClientModules = (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [
229
+ ${clientModules
154
230
  // import() is async so we use require() because client modules can have
155
231
  // CSS and the order matters for loading CSS.
156
- // We need to JSON.stringify so that if its on windows, backslash are escaped.
157
- .map((module) => ` require(${JSON.stringify(module)}),`)
158
- .join('\n')}\n];\n`);
232
+ .map((module) => ` require('${(0, utils_1.escapePath)(module)}'),`)
233
+ .join('\n')}
234
+ ];
235
+ `);
159
236
  // Load extra head & body html tags.
160
- const { headTags, preBodyTags, postBodyTags } = html_tags_1.loadHtmlTags(plugins);
237
+ const { headTags, preBodyTags, postBodyTags } = (0, html_tags_1.loadHtmlTags)(plugins);
161
238
  // Routing.
162
- const { registry, routesChunkNames, routesConfig, routesPaths, } = await routes_1.default(pluginsRouteConfigs, baseUrl);
163
- const genRegistry = utils_1.generate(generatedFilesDir, 'registry.js', `export default {
164
- ${Object.keys(registry)
165
- .sort()
166
- .map((key) =>
167
- // We need to JSON.stringify so that if its on windows, backslash are escaped.
168
- ` '${key}': [${registry[key].loader}, ${JSON.stringify(registry[key].modulePath)}, require.resolveWeak(${JSON.stringify(registry[key].modulePath)})],`)
169
- .join('\n')}};\n`);
170
- const genRoutesChunkNames = utils_1.generate(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
171
- const genRoutes = utils_1.generate(generatedFilesDir, 'routes.js', routesConfig);
172
- const genGlobalData = utils_1.generate(generatedFilesDir, 'globalData.json', JSON.stringify(globalData, null, 2));
173
- const genI18n = utils_1.generate(generatedFilesDir, 'i18n.json', JSON.stringify(i18n, null, 2));
239
+ const { registry, routesChunkNames, routesConfig, routesPaths } = await (0, routes_1.default)(pluginsRouteConfigs, baseUrl);
240
+ const genRegistry = (0, utils_1.generate)(generatedFilesDir, 'registry.js', `export default {
241
+ ${Object.entries(registry)
242
+ .sort((a, b) => a[0].localeCompare(b[0]))
243
+ .map(([key, chunk]) => ` '${key}': [${chunk.loader}, '${(0, utils_1.escapePath)(chunk.modulePath)}', require.resolveWeak('${(0, utils_1.escapePath)(chunk.modulePath)}')],`)
244
+ .join('\n')}};
245
+ `);
246
+ const genRoutesChunkNames = (0, utils_1.generate)(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
247
+ const genRoutes = (0, utils_1.generate)(generatedFilesDir, 'routes.js', routesConfig);
248
+ const genGlobalData = (0, utils_1.generate)(generatedFilesDir, 'globalData.json', JSON.stringify(globalData, null, 2));
249
+ const genI18n = (0, utils_1.generate)(generatedFilesDir, 'i18n.json', JSON.stringify(i18n, null, 2));
174
250
  const codeTranslationsWithFallbacks = {
175
- ...(await translations_1.getPluginsDefaultCodeTranslationMessages(plugins)),
251
+ ...(await (0, translations_1.getPluginsDefaultCodeTranslationMessages)(plugins)),
176
252
  ...codeTranslations,
177
253
  };
178
- const genCodeTranslations = utils_1.generate(generatedFilesDir, 'codeTranslations.json', JSON.stringify(codeTranslationsWithFallbacks, null, 2));
254
+ const genCodeTranslations = (0, utils_1.generate)(generatedFilesDir, 'codeTranslations.json', JSON.stringify(codeTranslationsWithFallbacks, null, 2));
179
255
  // Version metadata.
180
256
  const siteMetadata = {
181
- docusaurusVersion: versions_1.getPackageJsonVersion(path_1.join(__dirname, '../../package.json')),
182
- siteVersion: versions_1.getPackageJsonVersion(path_1.join(siteDir, 'package.json')),
257
+ docusaurusVersion: (await (0, versions_1.getPackageJsonVersion)(path_1.default.join(__dirname, '../../package.json'))),
258
+ siteVersion: await (0, versions_1.getPackageJsonVersion)(path_1.default.join(siteDir, 'package.json')),
183
259
  pluginVersions: {},
184
260
  };
185
261
  plugins
@@ -188,8 +264,9 @@ ${Object.keys(registry)
188
264
  siteMetadata.pluginVersions[name] = version;
189
265
  });
190
266
  checkDocusaurusPackagesVersion(siteMetadata);
191
- const genSiteMetadata = utils_1.generate(generatedFilesDir, 'site-metadata.json', JSON.stringify(siteMetadata, null, 2));
267
+ const genSiteMetadata = (0, utils_1.generate)(generatedFilesDir, 'site-metadata.json', JSON.stringify(siteMetadata, null, 2));
192
268
  await Promise.all([
269
+ genWarning,
193
270
  genClientModules,
194
271
  genSiteConfig,
195
272
  genRegistry,
@@ -215,25 +292,27 @@ ${Object.keys(registry)
215
292
  headTags,
216
293
  preBodyTags,
217
294
  postBodyTags,
218
- ssrTemplate: ssrTemplate || ssr_html_template_1.default,
295
+ ssrTemplate,
219
296
  codeTranslations,
220
297
  };
221
298
  return props;
222
299
  }
223
300
  exports.load = load;
224
- // We want all @docusaurus/* packages to have the exact same version!
301
+ // We want all @docusaurus/* packages to have the exact same version!
225
302
  // See https://github.com/facebook/docusaurus/issues/3371
226
303
  // See https://github.com/facebook/docusaurus/pull/3386
227
304
  function checkDocusaurusPackagesVersion(siteMetadata) {
228
305
  const { docusaurusVersion } = siteMetadata;
229
306
  Object.entries(siteMetadata.pluginVersions).forEach(([plugin, versionInfo]) => {
230
- var _a;
231
307
  if (versionInfo.type === 'package' &&
232
- ((_a = versionInfo.name) === null || _a === void 0 ? void 0 : _a.startsWith('@docusaurus/')) &&
308
+ versionInfo.name?.startsWith('@docusaurus/') &&
309
+ versionInfo.version &&
233
310
  versionInfo.version !== docusaurusVersion) {
234
311
  // should we throw instead?
235
312
  // It still could work with different versions
236
- console.warn(chalk_1.default.red(`Bad ${plugin} version ${versionInfo.version}.\nAll official @docusaurus/* packages should have the exact same version as @docusaurus/core (${docusaurusVersion}).\nMaybe you want to check, or regenerate your yarn.lock or package-lock.json file?`));
313
+ logger_1.default.error `Invalid name=${plugin} version number=${versionInfo.version}.
314
+ All official @docusaurus/* packages should have the exact same version as @docusaurus/core (number=${docusaurusVersion}).
315
+ Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?`;
237
316
  }
238
317
  });
239
318
  }
@@ -0,0 +1,9 @@
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
+ /// <reference types="node" />
8
+ export declare function getNamePatterns(moduleName: string, moduleType: 'preset' | 'theme' | 'plugin'): string[];
9
+ export declare function resolveModuleName(moduleName: string, moduleRequire: NodeRequire, moduleType: 'preset' | 'theme' | 'plugin'): string;