@docusaurus/core 2.0.0-beta.18 → 2.0.0-beta.19

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 (130) hide show
  1. package/bin/beforeCli.mjs +12 -7
  2. package/bin/docusaurus.mjs +21 -72
  3. package/lib/client/.eslintrc.js +2 -3
  4. package/lib/client/App.d.ts +1 -1
  5. package/lib/client/App.js +9 -5
  6. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → BaseUrlIssueBanner/index.d.ts} +10 -5
  7. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +14 -9
  8. package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
  9. package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
  10. package/lib/client/ClientLifecyclesDispatcher.js +34 -0
  11. package/lib/client/LinksCollector.js +1 -2
  12. package/lib/client/PendingNavigation.d.ts +8 -17
  13. package/lib/client/PendingNavigation.js +39 -70
  14. package/lib/client/clientEntry.js +1 -2
  15. package/lib/client/docusaurus.d.ts +5 -5
  16. package/lib/client/docusaurus.js +25 -29
  17. package/lib/client/exports/BrowserOnly.d.ts +3 -4
  18. package/lib/client/exports/BrowserOnly.js +1 -1
  19. package/lib/client/exports/ComponentCreator.js +51 -46
  20. package/lib/client/exports/ErrorBoundary.d.ts +2 -2
  21. package/lib/client/exports/Interpolate.js +16 -39
  22. package/lib/client/exports/Link.d.ts +3 -15
  23. package/lib/client/exports/Link.js +21 -26
  24. package/lib/client/exports/useBaseUrl.js +3 -9
  25. package/lib/client/exports/useGlobalData.d.ts +3 -3
  26. package/lib/client/exports/useGlobalData.js +5 -5
  27. package/lib/client/flat.d.ts +10 -2
  28. package/lib/client/flat.js +11 -3
  29. package/lib/client/normalizeLocation.js +14 -5
  30. package/lib/client/prefetch.js +7 -25
  31. package/lib/client/preload.d.ts +1 -3
  32. package/lib/client/preload.js +2 -2
  33. package/lib/client/routeContext.js +1 -1
  34. package/lib/client/serverEntry.js +12 -11
  35. package/lib/client/theme-fallback/Error/index.js +2 -0
  36. package/lib/client/theme-fallback/Loading/index.js +2 -0
  37. package/lib/client/theme-fallback/NotFound/index.js +2 -0
  38. package/lib/commands/build.d.ts +6 -2
  39. package/lib/commands/build.js +35 -15
  40. package/lib/commands/clear.d.ts +1 -1
  41. package/lib/commands/clear.js +3 -2
  42. package/lib/commands/deploy.d.ts +5 -2
  43. package/lib/commands/deploy.js +12 -9
  44. package/lib/commands/external.d.ts +1 -1
  45. package/lib/commands/external.js +5 -6
  46. package/lib/commands/serve.d.ts +7 -2
  47. package/lib/commands/serve.js +12 -12
  48. package/lib/commands/start.d.ts +8 -2
  49. package/lib/commands/start.js +14 -9
  50. package/lib/commands/swizzle/actions.d.ts +2 -2
  51. package/lib/commands/swizzle/actions.js +5 -4
  52. package/lib/commands/swizzle/common.d.ts +3 -3
  53. package/lib/commands/swizzle/components.js +41 -3
  54. package/lib/commands/swizzle/config.js +14 -11
  55. package/lib/commands/swizzle/context.js +6 -10
  56. package/lib/commands/swizzle/index.d.ts +2 -2
  57. package/lib/commands/swizzle/index.js +4 -3
  58. package/lib/commands/writeHeadingIds.d.ts +1 -1
  59. package/lib/commands/writeHeadingIds.js +5 -8
  60. package/lib/commands/writeTranslations.d.ts +3 -4
  61. package/lib/commands/writeTranslations.js +7 -9
  62. package/lib/index.d.ts +9 -10
  63. package/lib/index.js +18 -19
  64. package/lib/server/brokenLinks.js +1 -2
  65. package/lib/server/{client-modules/index.d.ts → clientModules.d.ts} +5 -1
  66. package/lib/server/{client-modules/index.js → clientModules.js} +6 -1
  67. package/lib/server/config.d.ts +5 -2
  68. package/lib/server/config.js +11 -6
  69. package/lib/server/configValidation.js +6 -5
  70. package/lib/server/getHostPort.d.ts +14 -0
  71. package/lib/{choosePort.js → server/getHostPort.js} +21 -35
  72. package/lib/server/htmlTags.d.ts +12 -0
  73. package/lib/server/htmlTags.js +62 -0
  74. package/lib/server/i18n.d.ts +2 -11
  75. package/lib/server/i18n.js +4 -19
  76. package/lib/server/index.d.ts +28 -13
  77. package/lib/server/index.js +42 -210
  78. package/lib/server/plugins/configs.d.ts +51 -0
  79. package/lib/server/plugins/configs.js +101 -0
  80. package/lib/server/plugins/index.d.ts +8 -7
  81. package/lib/server/plugins/index.js +59 -134
  82. package/lib/server/plugins/init.d.ts +6 -19
  83. package/lib/server/plugins/init.js +16 -68
  84. package/lib/server/{moduleShorthand.d.ts → plugins/moduleShorthand.d.ts} +0 -0
  85. package/lib/server/{moduleShorthand.js → plugins/moduleShorthand.js} +0 -0
  86. package/lib/server/plugins/pluginIds.d.ts +4 -0
  87. package/lib/server/plugins/pluginIds.js +4 -2
  88. package/lib/server/plugins/presets.d.ts +12 -0
  89. package/lib/server/{presets/index.js → plugins/presets.js} +14 -6
  90. package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +3 -1
  91. package/lib/server/plugins/routeConfig.js +54 -0
  92. package/lib/server/plugins/synthetic.d.ts +20 -0
  93. package/lib/server/plugins/synthetic.js +112 -0
  94. package/lib/server/routes.d.ts +42 -8
  95. package/lib/server/routes.js +150 -92
  96. package/lib/server/{versions/index.d.ts → siteMetadata.d.ts} +5 -2
  97. package/lib/server/{versions/index.js → siteMetadata.js} +36 -3
  98. package/lib/server/translations/translations.d.ts +5 -13
  99. package/lib/server/translations/translations.js +5 -8
  100. package/lib/server/translations/translationsExtractor.d.ts +2 -4
  101. package/lib/webpack/aliases/index.d.ts +34 -0
  102. package/lib/webpack/aliases/index.js +106 -0
  103. package/lib/webpack/base.d.ts +0 -3
  104. package/lib/webpack/base.js +8 -25
  105. package/lib/webpack/client.js +1 -1
  106. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +2 -2
  107. package/lib/webpack/plugins/WaitPlugin.d.ts +2 -2
  108. package/lib/webpack/server.d.ts +2 -2
  109. package/lib/webpack/server.js +5 -3
  110. package/lib/webpack/utils.d.ts +3 -3
  111. package/lib/webpack/utils.js +3 -3
  112. package/package.json +33 -36
  113. package/lib/choosePort.d.ts +0 -11
  114. package/lib/client/client-lifecycles-dispatcher.d.ts +0 -9
  115. package/lib/client/client-lifecycles-dispatcher.js +0 -23
  116. package/lib/client/nprogress.css +0 -36
  117. package/lib/commands/commandUtils.d.ts +0 -9
  118. package/lib/commands/commandUtils.js +0 -21
  119. package/lib/server/duplicateRoutes.d.ts +0 -8
  120. package/lib/server/duplicateRoutes.js +0 -42
  121. package/lib/server/html-tags/htmlTags.d.ts +0 -7
  122. package/lib/server/html-tags/htmlTags.js +0 -38
  123. package/lib/server/html-tags/index.d.ts +0 -8
  124. package/lib/server/html-tags/index.js +0 -42
  125. package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
  126. package/lib/server/presets/index.d.ts +0 -11
  127. package/lib/server/themes/alias.d.ts +0 -9
  128. package/lib/server/themes/alias.js +0 -50
  129. package/lib/server/themes/index.d.ts +0 -12
  130. package/lib/server/themes/index.js +0 -47
@@ -30,7 +30,7 @@ function ensureTranslationFileContent(content) {
30
30
  async function readTranslationFileContent(filePath) {
31
31
  if (await fs_extra_1.default.pathExists(filePath)) {
32
32
  try {
33
- const content = JSON.parse(await fs_extra_1.default.readFile(filePath, 'utf8'));
33
+ const content = await fs_extra_1.default.readJSON(filePath);
34
34
  ensureTranslationFileContent(content);
35
35
  return content;
36
36
  }
@@ -55,7 +55,7 @@ function mergeTranslationFileContent({ existingContent = {}, newContent, options
55
55
  message: options.override
56
56
  ? message
57
57
  : existingContent[key]?.message ?? message,
58
- description, // description
58
+ description,
59
59
  };
60
60
  });
61
61
  return result;
@@ -79,12 +79,9 @@ Maybe you should remove them? ${unknownKeys}`;
79
79
  await fs_extra_1.default.outputFile(filePath, `${JSON.stringify(mergedContent, null, 2)}\n`);
80
80
  }
81
81
  }
82
- // should we make this configurable?
83
- function getTranslationsDirPath(context) {
84
- return path_1.default.resolve(path_1.default.join(context.siteDir, utils_1.I18N_DIR_NAME));
85
- }
82
+ // Should we make this configurable?
86
83
  function getTranslationsLocaleDirPath(context) {
87
- return path_1.default.join(getTranslationsDirPath(context), context.locale);
84
+ return path_1.default.join(context.siteDir, utils_1.I18N_DIR_NAME, context.locale);
88
85
  }
89
86
  exports.getTranslationsLocaleDirPath = getTranslationsLocaleDirPath;
90
87
  function getCodeTranslationsFilePath(context) {
@@ -144,7 +141,7 @@ async function localizePluginTranslationFile({ siteDir, plugin, locale, translat
144
141
  });
145
142
  const localizedContent = await readTranslationFileContent(filePath);
146
143
  if (localizedContent) {
147
- // localized messages "override" default unlocalized messages
144
+ // Localized messages "override" default unlocalized messages
148
145
  return {
149
146
  path: translationFile.path,
150
147
  content: {
@@ -5,14 +5,12 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { type TransformOptions } from '@babel/core';
8
- import type { InitializedPlugin, TranslationFileContent, TranslationMessage } from '@docusaurus/types';
8
+ import type { InitializedPlugin, TranslationFileContent } from '@docusaurus/types';
9
9
  export declare function globSourceCodeFilePaths(dirPaths: string[]): Promise<string[]>;
10
10
  export declare function extractSiteSourceCodeTranslations(siteDir: string, plugins: InitializedPlugin[], babelOptions: TransformOptions, extraSourceCodeFilePaths?: string[]): Promise<TranslationFileContent>;
11
11
  declare type SourceCodeFileTranslations = {
12
12
  sourceCodeFilePath: string;
13
- translations: {
14
- [msgId: string]: TranslationMessage;
15
- };
13
+ translations: TranslationFileContent;
16
14
  warnings: string[];
17
15
  };
18
16
  export declare function extractAllSourceCodeFileTranslations(sourceCodeFilePaths: string[], babelOptions: TransformOptions): Promise<SourceCodeFileTranslations[]>;
@@ -0,0 +1,34 @@
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 { LoadedPlugin } from '@docusaurus/types';
8
+ /**
9
+ * Aliases used for Webpack resolution (useful for implementing swizzling)
10
+ */
11
+ declare type ThemeAliases = {
12
+ [alias: string]: string;
13
+ };
14
+ /**
15
+ * Order of Webpack aliases is important because one alias can shadow another.
16
+ * This ensures `@theme/NavbarItem` alias is after
17
+ * `@theme/NavbarItem/LocaleDropdown`.
18
+ *
19
+ * @see https://github.com/facebook/docusaurus/pull/3922
20
+ * @see https://github.com/facebook/docusaurus/issues/5382
21
+ */
22
+ export declare function sortAliases(aliases: ThemeAliases): ThemeAliases;
23
+ export declare function createAliasesForTheme(themePath: string, addOriginalAlias: boolean): Promise<ThemeAliases>;
24
+ export declare function loadThemeAliases({ siteDir, plugins, }: {
25
+ siteDir: string;
26
+ plugins: LoadedPlugin[];
27
+ }): Promise<ThemeAliases>;
28
+ /**
29
+ * Note: a `@docusaurus` alias would also catch `@docusaurus/theme-common`, so
30
+ * instead of naively aliasing this to `client/exports`, we use fine-grained
31
+ * aliases instead.
32
+ */
33
+ export declare function loadDocusaurusAliases(): Promise<ThemeAliases>;
34
+ export {};
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.loadDocusaurusAliases = exports.loadThemeAliases = exports.createAliasesForTheme = exports.sortAliases = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const path_1 = tslib_1.__importDefault(require("path"));
13
+ const utils_1 = require("@docusaurus/utils");
14
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
15
+ const ThemeFallbackDir = path_1.default.join(__dirname, '../../client/theme-fallback');
16
+ /**
17
+ * Order of Webpack aliases is important because one alias can shadow another.
18
+ * This ensures `@theme/NavbarItem` alias is after
19
+ * `@theme/NavbarItem/LocaleDropdown`.
20
+ *
21
+ * @see https://github.com/facebook/docusaurus/pull/3922
22
+ * @see https://github.com/facebook/docusaurus/issues/5382
23
+ */
24
+ function sortAliases(aliases) {
25
+ // Alphabetical order by default
26
+ const entries = lodash_1.default.sortBy(Object.entries(aliases), ([alias]) => alias);
27
+ // @theme/NavbarItem should be after @theme/NavbarItem/LocaleDropdown
28
+ entries.sort(([alias1], [alias2]) =>
29
+ // eslint-disable-next-line no-nested-ternary
30
+ alias1.includes(`${alias2}/`) ? -1 : alias2.includes(`${alias1}/`) ? 1 : 0);
31
+ return Object.fromEntries(entries);
32
+ }
33
+ exports.sortAliases = sortAliases;
34
+ async function createAliasesForTheme(themePath, addOriginalAlias) {
35
+ if (!(await fs_extra_1.default.pathExists(themePath))) {
36
+ return {};
37
+ }
38
+ const themeComponentFiles = await (0, utils_1.Globby)(['**/*.{js,jsx,ts,tsx}'], {
39
+ cwd: themePath,
40
+ });
41
+ const aliases = {};
42
+ themeComponentFiles.forEach((relativeSource) => {
43
+ const filePath = path_1.default.join(themePath, relativeSource);
44
+ const fileName = (0, utils_1.fileToPath)(relativeSource);
45
+ const aliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme', fileName]).replace(/\/$/, ''));
46
+ aliases[aliasName] = filePath;
47
+ if (addOriginalAlias) {
48
+ // For swizzled components to access the original.
49
+ const originalAliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme-original', fileName]).replace(/\/$/, ''));
50
+ aliases[originalAliasName] = filePath;
51
+ }
52
+ });
53
+ return sortAliases(aliases);
54
+ }
55
+ exports.createAliasesForTheme = createAliasesForTheme;
56
+ async function createThemeAliases(themePaths, userThemePaths) {
57
+ const aliases = {};
58
+ for (const themePath of themePaths) {
59
+ const themeAliases = await createAliasesForTheme(themePath, true);
60
+ Object.entries(themeAliases).forEach(([aliasKey, alias]) => {
61
+ // If this alias shadows a previous one, use @theme-init to preserve the
62
+ // initial one. @theme-init is only applied once: to the initial theme
63
+ // that provided this component
64
+ if (aliasKey in aliases) {
65
+ const componentName = aliasKey.substring(aliasKey.indexOf('/') + 1);
66
+ const initAlias = `@theme-init/${componentName}`;
67
+ if (!(initAlias in aliases)) {
68
+ aliases[initAlias] = aliases[aliasKey];
69
+ }
70
+ }
71
+ aliases[aliasKey] = alias;
72
+ });
73
+ }
74
+ for (const themePath of userThemePaths) {
75
+ const userThemeAliases = await createAliasesForTheme(themePath, false);
76
+ Object.assign(aliases, userThemeAliases);
77
+ }
78
+ return sortAliases(aliases);
79
+ }
80
+ function loadThemeAliases({ siteDir, plugins, }) {
81
+ const pluginThemes = plugins
82
+ .map((plugin) => plugin.getThemePath && path_1.default.resolve(plugin.path, plugin.getThemePath()))
83
+ .filter((x) => Boolean(x));
84
+ const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
85
+ return createThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
86
+ }
87
+ exports.loadThemeAliases = loadThemeAliases;
88
+ /**
89
+ * Note: a `@docusaurus` alias would also catch `@docusaurus/theme-common`, so
90
+ * instead of naively aliasing this to `client/exports`, we use fine-grained
91
+ * aliases instead.
92
+ */
93
+ async function loadDocusaurusAliases() {
94
+ const dirPath = path_1.default.resolve(__dirname, '../../client/exports');
95
+ const extensions = ['.js', '.ts', '.tsx'];
96
+ const aliases = {};
97
+ (await fs_extra_1.default.readdir(dirPath))
98
+ .filter((fileName) => extensions.includes(path_1.default.extname(fileName)))
99
+ .forEach((fileName) => {
100
+ const fileNameWithoutExtension = path_1.default.basename(fileName, path_1.default.extname(fileName));
101
+ const aliasName = `@docusaurus/${fileNameWithoutExtension}`;
102
+ aliases[aliasName] = path_1.default.resolve(dirPath, fileName);
103
+ });
104
+ return aliases;
105
+ }
106
+ exports.loadDocusaurusAliases = loadDocusaurusAliases;
@@ -8,7 +8,4 @@ import type { Configuration } from 'webpack';
8
8
  import type { Props } from '@docusaurus/types';
9
9
  export declare const clientDir: string;
10
10
  export declare function excludeJS(modulePath: string): boolean;
11
- export declare function getDocusaurusAliases(): Promise<{
12
- [aliasName: string]: string;
13
- }>;
14
11
  export declare function createBaseConfig(props: Props, isServer: boolean, minify?: boolean): Promise<Configuration>;
@@ -6,23 +6,23 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createBaseConfig = exports.getDocusaurusAliases = exports.excludeJS = exports.clientDir = void 0;
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
12
  const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
13
13
  const path_1 = tslib_1.__importDefault(require("path"));
14
14
  const utils_1 = require("./utils");
15
- const themes_1 = require("../server/themes");
15
+ const aliases_1 = require("./aliases");
16
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');
20
20
  const LibrariesToTranspile = [
21
- 'copy-text-to-clipboard', // contains optional catch binding, incompatible with recent versions of Edge
21
+ 'copy-text-to-clipboard', // Contains optional catch binding, incompatible with recent versions of Edge
22
22
  ];
23
23
  const LibrariesToTranspileRegex = new RegExp(LibrariesToTranspile.map((libName) => `(node_modules/${libName})`).join('|'));
24
24
  function excludeJS(modulePath) {
25
- // always transpile client dir
25
+ // Always transpile client dir
26
26
  if (modulePath.startsWith(exports.clientDir)) {
27
27
  return false;
28
28
  }
@@ -32,20 +32,6 @@ function excludeJS(modulePath) {
32
32
  !LibrariesToTranspileRegex.test(modulePath));
33
33
  }
34
34
  exports.excludeJS = excludeJS;
35
- async function getDocusaurusAliases() {
36
- const dirPath = path_1.default.resolve(__dirname, '../client/exports');
37
- const extensions = ['.js', '.ts', '.tsx'];
38
- const aliases = {};
39
- (await fs_extra_1.default.readdir(dirPath))
40
- .filter((fileName) => extensions.includes(path_1.default.extname(fileName)))
41
- .forEach((fileName) => {
42
- const fileNameWithoutExtension = path_1.default.basename(fileName, path_1.default.extname(fileName));
43
- const aliasName = `@docusaurus/${fileNameWithoutExtension}`;
44
- aliases[aliasName] = path_1.default.resolve(dirPath, fileName);
45
- });
46
- return aliases;
47
- }
48
- exports.getDocusaurusAliases = getDocusaurusAliases;
49
35
  async function createBaseConfig(props, isServer, minify = true) {
50
36
  const { outDir, siteDir, siteConfig, siteConfigPath, baseUrl, generatedFilesDir, routesPaths, siteMetadata, plugins, } = props;
51
37
  const totalPages = routesPaths.length;
@@ -55,7 +41,7 @@ async function createBaseConfig(props, isServer, minify = true) {
55
41
  const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
56
42
  const name = isServer ? 'server' : 'client';
57
43
  const mode = isProd ? 'production' : 'development';
58
- const themeAliases = await (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
44
+ const themeAliases = await (0, aliases_1.loadThemeAliases)({ siteDir, plugins });
59
45
  return {
60
46
  mode,
61
47
  name,
@@ -116,10 +102,7 @@ async function createBaseConfig(props, isServer, minify = true) {
116
102
  alias: {
117
103
  '@site': siteDir,
118
104
  '@generated': generatedFilesDir,
119
- // Note: a @docusaurus alias would also catch @docusaurus/theme-common,
120
- // so we use fine-grained aliases instead
121
- // '@docusaurus': path.resolve(__dirname, '../client/exports'),
122
- ...(await getDocusaurusAliases()),
105
+ ...(await (0, aliases_1.loadDocusaurusAliases)()),
123
106
  ...themeAliases,
124
107
  },
125
108
  // This allows you to set a fallback for where Webpack should look for
@@ -152,7 +135,7 @@ async function createBaseConfig(props, isServer, minify = true) {
152
135
  // include [name] in the filenames
153
136
  name: false,
154
137
  cacheGroups: {
155
- // disable the built-in cacheGroups
138
+ // Disable the built-in cacheGroups
156
139
  default: false,
157
140
  common: {
158
141
  name: 'common',
@@ -223,7 +206,7 @@ async function createBaseConfig(props, isServer, minify = true) {
223
206
  chunkFilename: isProd
224
207
  ? 'assets/css/[name].[contenthash:8].css'
225
208
  : '[name].css',
226
- // remove css order warnings if css imports are not sorted
209
+ // Remove css order warnings if css imports are not sorted
227
210
  // alphabetically. See https://github.com/webpack-contrib/mini-css-extract-plugin/pull/422
228
211
  // for more reasoning
229
212
  ignoreOrder: true,
@@ -17,7 +17,7 @@ async function createClientConfig(props, minify = true) {
17
17
  const isBuilding = process.argv[2] === 'build';
18
18
  const config = await (0, base_1.createBaseConfig)(props, false, minify);
19
19
  const clientConfig = (0, webpack_merge_1.default)(config, {
20
- // useless, disabled on purpose (errors on existing sites with no
20
+ // Useless, disabled on purpose (errors on existing sites with no
21
21
  // browserslist config)
22
22
  // target: 'browserslist',
23
23
  entry: path_1.default.resolve(__dirname, '../client/clientEntry.js'),
@@ -24,7 +24,7 @@
24
24
  * SOFTWARE.
25
25
  */
26
26
  import type { Compiler, Stats } from 'webpack';
27
- export interface Options {
27
+ export declare type Options = {
28
28
  /**
29
29
  * Write Logs to Console
30
30
  * (Always enabled when dry is true)
@@ -53,7 +53,7 @@ export interface Options {
53
53
  * default: ['**\/*']
54
54
  */
55
55
  cleanOnceBeforeBuildPatterns?: string[];
56
- }
56
+ };
57
57
  export default class CleanWebpackPlugin {
58
58
  private readonly verbose;
59
59
  private readonly cleanStaleWebpackAssets;
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { Compiler } from 'webpack';
8
- interface WaitPluginOptions {
8
+ declare type WaitPluginOptions = {
9
9
  filepath: string;
10
- }
10
+ };
11
11
  export default class WaitPlugin {
12
12
  filepath: string;
13
13
  constructor(options: WaitPluginOptions);
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import type { Configuration } from 'webpack';
8
8
  import type { Props } from '@docusaurus/types';
9
- export default function createServerConfig({ props, onLinksCollected, }: {
9
+ import { type Locals } from '@slorber/static-site-generator-webpack-plugin';
10
+ export default function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }: Pick<Locals, 'onLinksCollected' | 'onHeadTagsCollected'> & {
10
11
  props: Props;
11
- onLinksCollected?: (staticPagePath: string, links: string[]) => void;
12
12
  }): Promise<Configuration>;
@@ -13,10 +13,11 @@ const base_1 = require("./base");
13
13
  const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
14
14
  const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
+ const ssr_html_template_1 = tslib_1.__importDefault(require("./templates/ssr.html.template"));
16
17
  // Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
17
18
  const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
18
- async function createServerConfig({ props, onLinksCollected = () => { }, }) {
19
- const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, ssrTemplate, siteConfig: { noIndex, trailingSlash }, } = props;
19
+ async function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }) {
20
+ const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, siteConfig: { noIndex, trailingSlash, ssrTemplate }, } = props;
20
21
  const config = await (0, base_1.createBaseConfig)(props, true);
21
22
  const routesLocation = {};
22
23
  // Array of paths to be rendered. Relative to output directory
@@ -52,7 +53,8 @@ async function createServerConfig({ props, onLinksCollected = () => { }, }) {
52
53
  preBodyTags,
53
54
  postBodyTags,
54
55
  onLinksCollected,
55
- ssrTemplate,
56
+ onHeadTagsCollected,
57
+ ssrTemplate: ssrTemplate ?? ssr_html_template_1.default,
56
58
  noIndex,
57
59
  },
58
60
  paths: ssgPaths,
@@ -7,7 +7,7 @@
7
7
  /// <reference types="node" />
8
8
  import { type Configuration, type RuleSetRule, type WebpackPluginInstance } from 'webpack';
9
9
  import type { TransformOptions } from '@babel/core';
10
- import type { ConfigureWebpackFn, ConfigurePostCssFn } from '@docusaurus/types';
10
+ import type { Plugin } from '@docusaurus/types';
11
11
  export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
12
12
  [key: string]: unknown;
13
13
  }): RuleSetRule[];
@@ -29,8 +29,8 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
29
29
  * @param content content loaded by the plugin
30
30
  * @returns final/ modified webpack config
31
31
  */
32
- export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
33
- export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
32
+ export declare function applyConfigureWebpack(configureWebpack: NonNullable<Plugin['configureWebpack']>, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
33
+ export declare function applyConfigurePostCss(configurePostCss: NonNullable<Plugin['configurePostCss']>, config: Configuration): Configuration;
34
34
  declare global {
35
35
  interface Error {
36
36
  /** @see https://webpack.js.org/api/node/#error-handling */
@@ -143,7 +143,7 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
143
143
  }
144
144
  exports.applyConfigureWebpack = applyConfigureWebpack;
145
145
  function applyConfigurePostCss(configurePostCss, config) {
146
- // not ideal heuristic but good enough for our use-case?
146
+ // Not ideal heuristic but good enough for our use-case?
147
147
  function isPostCssLoader(loader) {
148
148
  return !!loader?.options?.postcssOptions;
149
149
  }
@@ -176,7 +176,7 @@ function compile(config) {
176
176
  }
177
177
  reject(err);
178
178
  }
179
- // let plugins consume all the stats
179
+ // Let plugins consume all the stats
180
180
  const errorsWarnings = stats?.toJson('errors-warnings');
181
181
  if (stats?.hasErrors()) {
182
182
  reject(new Error('Failed to compile with errors.'));
@@ -266,7 +266,7 @@ function getMinimizer(useSimpleCssMinifier = false) {
266
266
  parallel: getTerserParallel(),
267
267
  terserOptions: {
268
268
  parse: {
269
- // we want uglify-js to parse ecma 8 code. However, we don't want it
269
+ // We want uglify-js to parse ecma 8 code. However, we don't want it
270
270
  // to apply any minification steps that turns valid ecma 5 code
271
271
  // into invalid ecma 5 code. This is why the 'compress' and 'output'
272
272
  // sections only apply transformations that are ecma 5 safe
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.18",
4
+ "version": "2.0.0-beta.19",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -31,59 +31,57 @@
31
31
  "url": "https://github.com/facebook/docusaurus/issues"
32
32
  },
33
33
  "dependencies": {
34
- "@babel/core": "^7.17.8",
35
- "@babel/generator": "^7.17.7",
34
+ "@babel/core": "^7.17.10",
35
+ "@babel/generator": "^7.17.10",
36
36
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
37
- "@babel/plugin-transform-runtime": "^7.17.0",
38
- "@babel/preset-env": "^7.16.11",
37
+ "@babel/plugin-transform-runtime": "^7.17.10",
38
+ "@babel/preset-env": "^7.17.10",
39
39
  "@babel/preset-react": "^7.16.7",
40
40
  "@babel/preset-typescript": "^7.16.7",
41
- "@babel/runtime": "^7.17.8",
42
- "@babel/runtime-corejs3": "^7.17.8",
43
- "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "2.0.0-beta.18",
45
- "@docusaurus/logger": "2.0.0-beta.18",
46
- "@docusaurus/mdx-loader": "2.0.0-beta.18",
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.19",
45
+ "@docusaurus/logger": "2.0.0-beta.19",
46
+ "@docusaurus/mdx-loader": "2.0.0-beta.19",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "2.0.0-beta.18",
49
- "@docusaurus/utils-common": "2.0.0-beta.18",
50
- "@docusaurus/utils-validation": "2.0.0-beta.18",
48
+ "@docusaurus/utils": "2.0.0-beta.19",
49
+ "@docusaurus/utils-common": "2.0.0-beta.19",
50
+ "@docusaurus/utils-validation": "2.0.0-beta.19",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.4",
52
52
  "@svgr/webpack": "^6.2.1",
53
- "autoprefixer": "^10.4.4",
54
- "babel-loader": "^8.2.4",
53
+ "autoprefixer": "^10.4.5",
54
+ "babel-loader": "^8.2.5",
55
55
  "babel-plugin-dynamic-import-node": "2.3.0",
56
56
  "boxen": "^6.2.1",
57
57
  "chokidar": "^3.5.3",
58
- "clean-css": "^5.2.4",
59
- "cli-table3": "^0.6.1",
58
+ "clean-css": "^5.3.0",
59
+ "cli-table3": "^0.6.2",
60
60
  "combine-promises": "^1.1.0",
61
61
  "commander": "^5.1.0",
62
62
  "copy-webpack-plugin": "^10.2.4",
63
- "core-js": "^3.21.1",
63
+ "core-js": "^3.22.3",
64
64
  "css-loader": "^6.7.1",
65
65
  "css-minimizer-webpack-plugin": "^3.4.1",
66
- "cssnano": "^5.1.5",
66
+ "cssnano": "^5.1.7",
67
67
  "del": "^6.0.0",
68
68
  "detect-port": "^1.3.0",
69
69
  "escape-html": "^1.0.3",
70
70
  "eta": "^1.12.3",
71
71
  "file-loader": "^6.2.0",
72
- "fs-extra": "^10.0.1",
72
+ "fs-extra": "^10.1.0",
73
73
  "html-minifier-terser": "^6.1.0",
74
- "html-tags": "^3.1.0",
74
+ "html-tags": "^3.2.0",
75
75
  "html-webpack-plugin": "^5.5.0",
76
76
  "import-fresh": "^3.3.0",
77
- "is-root": "^2.1.0",
78
77
  "leven": "^3.1.0",
79
78
  "lodash": "^4.17.21",
80
79
  "mini-css-extract-plugin": "^2.6.0",
81
- "nprogress": "^0.2.0",
82
- "postcss": "^8.4.12",
80
+ "postcss": "^8.4.13",
83
81
  "postcss-loader": "^6.2.1",
84
82
  "prompts": "^2.4.2",
85
- "react-dev-utils": "^12.0.0",
86
- "react-helmet-async": "^1.2.3",
83
+ "react-dev-utils": "^12.0.1",
84
+ "react-helmet-async": "^1.3.0",
87
85
  "react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
88
86
  "react-loadable-ssr-addon-v5-slorber": "^1.0.1",
89
87
  "react-router": "^5.2.0",
@@ -91,26 +89,25 @@
91
89
  "react-router-dom": "^5.2.0",
92
90
  "remark-admonitions": "^1.2.1",
93
91
  "rtl-detect": "^1.0.4",
94
- "semver": "^7.3.5",
92
+ "semver": "^7.3.7",
95
93
  "serve-handler": "^6.1.3",
96
94
  "shelljs": "^0.8.5",
97
95
  "terser-webpack-plugin": "^5.3.1",
98
- "tslib": "^2.3.1",
96
+ "tslib": "^2.4.0",
99
97
  "update-notifier": "^5.1.0",
100
98
  "url-loader": "^4.1.1",
101
99
  "wait-on": "^6.0.1",
102
- "webpack": "^5.70.0",
100
+ "webpack": "^5.72.0",
103
101
  "webpack-bundle-analyzer": "^4.5.0",
104
- "webpack-dev-server": "^4.7.4",
102
+ "webpack-dev-server": "^4.8.1",
105
103
  "webpack-merge": "^5.8.0",
106
104
  "webpackbar": "^5.0.2"
107
105
  },
108
106
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "2.0.0-beta.18",
110
- "@docusaurus/types": "2.0.0-beta.18",
107
+ "@docusaurus/module-type-aliases": "2.0.0-beta.19",
108
+ "@docusaurus/types": "2.0.0-beta.19",
111
109
  "@types/detect-port": "^1.3.2",
112
- "@types/nprogress": "^0.2.0",
113
- "@types/react-dom": "^17.0.14",
110
+ "@types/react-dom": "^18.0.3",
114
111
  "@types/react-router-config": "^5.0.6",
115
112
  "@types/rtl-detect": "^1.0.0",
116
113
  "@types/serve-handler": "^6.1.1",
@@ -128,5 +125,5 @@
128
125
  "engines": {
129
126
  "node": ">=14"
130
127
  },
131
- "gitHead": "1a945d06993d53376e61bed2c942799fe07dc336"
128
+ "gitHead": "a71e60a49cce93c1006ef10c41ac03187f057102"
132
129
  }
@@ -1,11 +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
- /**
8
- * Detects if program is running on port and prompts user
9
- * to choose another if port is already being used
10
- */
11
- export default function choosePort(host: string, defaultPort: number): Promise<number | null>;
@@ -1,9 +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 { ClientModule } from '@docusaurus/types';
8
- declare const clientLifecyclesDispatchers: Required<ClientModule>;
9
- export default clientLifecyclesDispatchers;
@@ -1,23 +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 clientModules from '@generated/client-modules';
8
- function dispatchLifecycleAction(lifecycleAction, args) {
9
- clientModules.forEach((clientModule) => {
10
- const lifecycleFunction = (clientModule?.default?.[lifecycleAction] ??
11
- clientModule[lifecycleAction]);
12
- lifecycleFunction?.(...args);
13
- });
14
- }
15
- const clientLifecyclesDispatchers = {
16
- onRouteUpdate(...args) {
17
- dispatchLifecycleAction('onRouteUpdate', args);
18
- },
19
- onRouteUpdateDelayed(...args) {
20
- dispatchLifecycleAction('onRouteUpdateDelayed', args);
21
- },
22
- };
23
- export default clientLifecyclesDispatchers;
@@ -1,36 +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
-
8
- /**
9
- * Styles for NProgress
10
- * Copied over to remove unused styles for the spinner.
11
- * https://github.com/rstacruz/nprogress/blob/master/nprogress.css
12
- */
13
-
14
- #nprogress {
15
- pointer-events: none;
16
- }
17
-
18
- #nprogress .bar {
19
- background: #29d;
20
- position: fixed;
21
- z-index: 1031;
22
- top: 0;
23
- left: 0;
24
- width: 100%;
25
- height: 2px;
26
- }
27
-
28
- #nprogress .peg {
29
- position: absolute;
30
- right: 0;
31
- width: 100px;
32
- height: 100%;
33
- box-shadow: 0 0 10px #29d, 0 0 5px #29d;
34
- opacity: 1;
35
- transform: rotate(3deg) translate(0, -4px);
36
- }