@docusaurus/core 3.3.2 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/bin/docusaurus.mjs +13 -12
  2. package/lib/babel/preset.js +1 -1
  3. package/lib/client/App.d.ts +0 -2
  4. package/lib/client/BaseUrlIssueBanner/index.d.ts +0 -1
  5. package/lib/client/BrokenLinksContext.d.ts +0 -1
  6. package/lib/client/SiteMetadataDefaults.d.ts +0 -1
  7. package/lib/client/clientEntry.js +7 -3
  8. package/lib/client/exports/BrowserOnly.d.ts +0 -2
  9. package/lib/client/exports/ErrorBoundary.d.ts +0 -1
  10. package/lib/client/exports/Head.d.ts +0 -2
  11. package/lib/client/exports/Interpolate.d.ts +0 -1
  12. package/lib/client/exports/Link.d.ts +0 -1
  13. package/lib/client/exports/Link.js +26 -5
  14. package/lib/client/exports/Translate.d.ts +0 -2
  15. package/lib/client/exports/useBaseUrl.d.ts +8 -1
  16. package/lib/client/exports/useBaseUrl.js +11 -3
  17. package/lib/client/exports/useBrokenLinks.d.ts +0 -1
  18. package/lib/client/hasHydratedDataAttribute.d.ts +0 -1
  19. package/lib/client/theme-fallback/Error/index.d.ts +0 -2
  20. package/lib/client/theme-fallback/Layout/index.d.ts +0 -2
  21. package/lib/client/theme-fallback/Loading/index.d.ts +0 -1
  22. package/lib/client/theme-fallback/NotFound/index.d.ts +0 -1
  23. package/lib/client/theme-fallback/Root/index.d.ts +0 -2
  24. package/lib/client/theme-fallback/SiteMetadata/index.d.ts +0 -1
  25. package/lib/commands/build.js +36 -23
  26. package/lib/commands/clear.js +1 -2
  27. package/lib/commands/deploy.js +1 -2
  28. package/lib/commands/external.js +1 -2
  29. package/lib/commands/serve.js +16 -6
  30. package/lib/commands/start/start.js +1 -2
  31. package/lib/commands/start/utils.d.ts +3 -2
  32. package/lib/commands/start/utils.js +9 -5
  33. package/lib/commands/start/watcher.js +5 -6
  34. package/lib/commands/start/webpack.js +4 -5
  35. package/lib/commands/swizzle/actions.js +4 -4
  36. package/lib/commands/swizzle/common.js +7 -7
  37. package/lib/commands/swizzle/components.js +5 -6
  38. package/lib/commands/swizzle/config.js +2 -3
  39. package/lib/commands/swizzle/context.js +19 -8
  40. package/lib/commands/swizzle/index.js +1 -2
  41. package/lib/commands/swizzle/prompts.js +4 -5
  42. package/lib/commands/swizzle/tables.js +2 -3
  43. package/lib/commands/swizzle/themes.js +5 -6
  44. package/lib/commands/writeHeadingIds.js +1 -2
  45. package/lib/commands/writeTranslations.js +1 -2
  46. package/lib/server/brokenLinks.js +10 -3
  47. package/lib/server/clientModules.js +1 -2
  48. package/lib/server/codegen/codegen.d.ts +2 -1
  49. package/lib/server/codegen/codegen.js +5 -2
  50. package/lib/server/codegen/codegenRoutes.d.ts +1 -0
  51. package/lib/server/codegen/codegenRoutes.js +22 -9
  52. package/lib/server/config.js +1 -2
  53. package/lib/server/configValidation.d.ts +4 -1
  54. package/lib/server/configValidation.js +30 -2
  55. package/lib/server/getHostPort.js +1 -2
  56. package/lib/server/htmlTags.d.ts +5 -2
  57. package/lib/server/htmlTags.js +16 -8
  58. package/lib/server/i18n.js +39 -11
  59. package/lib/server/plugins/actions.js +1 -2
  60. package/lib/server/plugins/configs.js +1 -2
  61. package/lib/server/plugins/init.d.ts +11 -0
  62. package/lib/server/plugins/init.js +42 -7
  63. package/lib/server/plugins/moduleShorthand.d.ts +0 -1
  64. package/lib/server/plugins/moduleShorthand.js +2 -3
  65. package/lib/server/plugins/pluginIds.js +1 -2
  66. package/lib/server/plugins/plugins.js +2 -3
  67. package/lib/server/plugins/pluginsUtils.js +7 -8
  68. package/lib/server/plugins/presets.js +1 -2
  69. package/lib/server/plugins/routeConfig.js +2 -3
  70. package/lib/server/plugins/synthetic.js +2 -3
  71. package/lib/server/routes.js +2 -3
  72. package/lib/server/site.js +17 -10
  73. package/lib/server/siteMetadata.js +3 -4
  74. package/lib/server/storage.d.ts +13 -0
  75. package/lib/server/storage.js +35 -0
  76. package/lib/server/translations/translations.js +9 -10
  77. package/lib/server/translations/translationsExtractor.js +4 -5
  78. package/lib/server/utils.js +1 -2
  79. package/lib/ssg.d.ts +4 -1
  80. package/lib/ssg.js +10 -3
  81. package/lib/templates/templates.d.ts +3 -0
  82. package/lib/templates/templates.js +27 -3
  83. package/lib/webpack/aliases/index.js +4 -5
  84. package/lib/webpack/base.js +4 -4
  85. package/lib/webpack/client.js +13 -22
  86. package/lib/webpack/configure.d.ts +25 -0
  87. package/lib/webpack/configure.js +99 -0
  88. package/lib/webpack/minification.js +1 -2
  89. package/lib/webpack/plugins/ForceTerminatePlugin.d.ts +10 -0
  90. package/lib/webpack/plugins/ForceTerminatePlugin.js +25 -0
  91. package/lib/webpack/plugins/StaticDirectoriesCopyPlugin.d.ts +11 -0
  92. package/lib/webpack/plugins/StaticDirectoriesCopyPlugin.js +38 -0
  93. package/lib/webpack/server.js +1 -29
  94. package/lib/webpack/utils.d.ts +1 -24
  95. package/lib/webpack/utils.js +8 -87
  96. package/package.json +10 -10
@@ -0,0 +1,99 @@
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.applyConfigureWebpack = applyConfigureWebpack;
10
+ exports.applyConfigurePostCss = applyConfigurePostCss;
11
+ exports.executePluginsConfigureWebpack = executePluginsConfigureWebpack;
12
+ const webpack_merge_1 = require("webpack-merge");
13
+ const utils_1 = require("./utils");
14
+ /**
15
+ * Helper function to modify webpack config
16
+ * @param configureWebpack a webpack config or a function to modify config
17
+ * @param config initial webpack config
18
+ * @param isServer indicates if this is a server webpack configuration
19
+ * @param jsLoader custom js loader config
20
+ * @param content content loaded by the plugin
21
+ * @returns final/ modified webpack config
22
+ */
23
+ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, content) {
24
+ // Export some utility functions
25
+ const utils = {
26
+ getStyleLoaders: utils_1.getStyleLoaders,
27
+ getJSLoader: (0, utils_1.getCustomizableJSLoader)(jsLoader),
28
+ };
29
+ if (typeof configureWebpack === 'function') {
30
+ const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content) ?? {};
31
+ const customizeRules = mergeStrategy ?? {};
32
+ return (0, webpack_merge_1.mergeWithCustomize)({
33
+ customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
34
+ customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
35
+ })(config, res);
36
+ }
37
+ return config;
38
+ }
39
+ function applyConfigurePostCss(configurePostCss, config) {
40
+ // Not ideal heuristic but good enough for our use-case?
41
+ function isPostCssLoader(loader) {
42
+ return !!loader?.options?.postcssOptions;
43
+ }
44
+ // Does not handle all edge cases, but good enough for now
45
+ function overridePostCssOptions(entry) {
46
+ if (isPostCssLoader(entry)) {
47
+ entry.options.postcssOptions = configurePostCss(entry.options.postcssOptions);
48
+ }
49
+ else if (Array.isArray(entry.oneOf)) {
50
+ entry.oneOf.forEach((r) => {
51
+ if (r) {
52
+ overridePostCssOptions(r);
53
+ }
54
+ });
55
+ }
56
+ else if (Array.isArray(entry.use)) {
57
+ entry.use
58
+ .filter((u) => typeof u === 'object')
59
+ .forEach((rule) => overridePostCssOptions(rule));
60
+ }
61
+ }
62
+ config.module?.rules?.forEach((rule) => overridePostCssOptions(rule));
63
+ return config;
64
+ }
65
+ // Plugin Lifecycle - configurePostCss()
66
+ function executePluginsConfigurePostCss({ plugins, config, }) {
67
+ let resultConfig = config;
68
+ plugins.forEach((plugin) => {
69
+ const { configurePostCss } = plugin;
70
+ if (configurePostCss) {
71
+ resultConfig = applyConfigurePostCss(configurePostCss.bind(plugin), resultConfig);
72
+ }
73
+ });
74
+ return resultConfig;
75
+ }
76
+ // Plugin Lifecycle - configureWebpack()
77
+ function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }) {
78
+ // Step1 - Configure Webpack
79
+ let resultConfig = config;
80
+ plugins.forEach((plugin) => {
81
+ const { configureWebpack } = plugin;
82
+ if (configureWebpack) {
83
+ resultConfig = applyConfigureWebpack(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
84
+ resultConfig, isServer, jsLoader, plugin.content);
85
+ }
86
+ });
87
+ // Step2 - For client code, configure PostCSS
88
+ // The order matters! We want to configure PostCSS on loaders
89
+ // that were potentially added by configureWebpack
90
+ // See https://github.com/facebook/docusaurus/issues/10106
91
+ // Note: it's useless to configure postCSS for the server
92
+ if (!isServer) {
93
+ resultConfig = executePluginsConfigurePostCss({
94
+ plugins,
95
+ config: resultConfig,
96
+ });
97
+ }
98
+ return resultConfig;
99
+ }
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getMinimizer = void 0;
9
+ exports.getMinimizer = getMinimizer;
10
10
  const tslib_1 = require("tslib");
11
11
  const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
12
12
  const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
@@ -94,4 +94,3 @@ function getMinimizer() {
94
94
  }
95
95
  return minimizer;
96
96
  }
97
- exports.getMinimizer = getMinimizer;
@@ -0,0 +1,10 @@
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 webpack from 'webpack';
8
+ export default class ForceTerminatePlugin implements webpack.WebpackPluginInstance {
9
+ apply(compiler: webpack.Compiler): void;
10
+ }
@@ -0,0 +1,25 @@
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 logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
+ const utils_1 = require("../utils");
12
+ // When building, include the plugin to force terminate building if errors
13
+ // happened in the client bundle.
14
+ class ForceTerminatePlugin {
15
+ apply(compiler) {
16
+ compiler.hooks.done.tap('client:done', (stats) => {
17
+ if (stats.hasErrors()) {
18
+ const errorsWarnings = stats.toJson('errors-warnings');
19
+ logger_1.default.error(`Client bundle compiled with errors therefore further build is impossible.\n${(0, utils_1.formatStatsErrorMessage)(errorsWarnings)}`);
20
+ process.exit(1);
21
+ }
22
+ });
23
+ }
24
+ }
25
+ exports.default = ForceTerminatePlugin;
@@ -0,0 +1,11 @@
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 CopyWebpackPlugin from 'copy-webpack-plugin';
8
+ import type { Props } from '@docusaurus/types';
9
+ export declare function createStaticDirectoriesCopyPlugin({ props, }: {
10
+ props: Props;
11
+ }): Promise<CopyWebpackPlugin | undefined>;
@@ -0,0 +1,38 @@
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.createStaticDirectoriesCopyPlugin = createStaticDirectoriesCopyPlugin;
10
+ const tslib_1 = require("tslib");
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
14
+ async function createStaticDirectoriesCopyPlugin({ props, }) {
15
+ const { outDir, siteDir, siteConfig: { staticDirectories: staticDirectoriesOption }, } = props;
16
+ // The staticDirectories option can contain empty directories, or non-existent
17
+ // directories (e.g. user deleted `static`). Instead of issuing an error, we
18
+ // just silently filter them out, because user could have never configured it
19
+ // in the first place (the default option should always "work").
20
+ const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
21
+ const staticDir = path_1.default.resolve(siteDir, dir);
22
+ if ((await fs_extra_1.default.pathExists(staticDir)) &&
23
+ (await fs_extra_1.default.readdir(staticDir)).length > 0) {
24
+ return staticDir;
25
+ }
26
+ return '';
27
+ }))).filter(Boolean);
28
+ if (staticDirectories.length === 0) {
29
+ return undefined;
30
+ }
31
+ return new copy_webpack_plugin_1.default({
32
+ patterns: staticDirectories.map((dir) => ({
33
+ from: dir,
34
+ to: outDir,
35
+ toType: 'dir',
36
+ })),
37
+ });
38
+ }
@@ -6,13 +6,12 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.default = createServerConfig;
9
10
  const tslib_1 = require("tslib");
10
11
  const path_1 = tslib_1.__importDefault(require("path"));
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
14
  const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
15
- const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
16
15
  const base_1 = require("./base");
17
16
  async function createServerConfig(params) {
18
17
  const { props } = params;
@@ -41,34 +40,7 @@ async function createServerConfig(params) {
41
40
  name: 'Server',
42
41
  color: 'yellow',
43
42
  }),
44
- await createStaticDirectoriesCopyPlugin(params),
45
43
  ].filter(Boolean),
46
44
  });
47
45
  return { config, serverBundlePath };
48
46
  }
49
- exports.default = createServerConfig;
50
- async function createStaticDirectoriesCopyPlugin({ props }) {
51
- const { outDir, siteDir, siteConfig: { staticDirectories: staticDirectoriesOption }, } = props;
52
- // The staticDirectories option can contain empty directories, or non-existent
53
- // directories (e.g. user deleted `static`). Instead of issuing an error, we
54
- // just silently filter them out, because user could have never configured it
55
- // in the first place (the default option should always "work").
56
- const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
57
- const staticDir = path_1.default.resolve(siteDir, dir);
58
- if ((await fs_extra_1.default.pathExists(staticDir)) &&
59
- (await fs_extra_1.default.readdir(staticDir)).length > 0) {
60
- return staticDir;
61
- }
62
- return '';
63
- }))).filter(Boolean);
64
- if (staticDirectories.length === 0) {
65
- return undefined;
66
- }
67
- return new copy_webpack_plugin_1.default({
68
- patterns: staticDirectories.map((dir) => ({
69
- from: dir,
70
- to: outDir,
71
- toType: 'dir',
72
- })),
73
- });
74
- }
@@ -4,10 +4,8 @@
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
- /// <reference types="node" />
8
7
  import webpack, { type Configuration, type RuleSetRule } from 'webpack';
9
8
  import type { TransformOptions } from '@babel/core';
10
- import type { Plugin, LoadedPlugin } from '@docusaurus/types';
11
9
  export declare function formatStatsErrorMessage(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): string | undefined;
12
10
  export declare function printStatsWarnings(statsJson: ReturnType<webpack.Stats['toJson']> | undefined): void;
13
11
  export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
@@ -18,31 +16,10 @@ export declare function getBabelOptions({ isServer, babelOptions, }?: {
18
16
  isServer?: boolean;
19
17
  babelOptions?: TransformOptions | string;
20
18
  }): TransformOptions;
21
- export declare const getCustomizableJSLoader: (jsLoader?: 'babel' | ((isServer: boolean) => RuleSetRule)) => ({ isServer, babelOptions, }: {
19
+ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer: boolean) => RuleSetRule)) => ({ isServer, babelOptions, }: {
22
20
  isServer: boolean;
23
21
  babelOptions?: TransformOptions | string;
24
22
  }) => RuleSetRule;
25
- /**
26
- * Helper function to modify webpack config
27
- * @param configureWebpack a webpack config or a function to modify config
28
- * @param config initial webpack config
29
- * @param isServer indicates if this is a server webpack configuration
30
- * @param jsLoader custom js loader config
31
- * @param content content loaded by the plugin
32
- * @returns final/ modified webpack config
33
- */
34
- export declare function applyConfigureWebpack(configureWebpack: NonNullable<Plugin['configureWebpack']>, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
35
- export declare function applyConfigurePostCss(configurePostCss: NonNullable<Plugin['configurePostCss']>, config: Configuration): Configuration;
36
- export declare function executePluginsConfigurePostCss({ plugins, config, }: {
37
- plugins: LoadedPlugin[];
38
- config: Configuration;
39
- }): Configuration;
40
- export declare function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }: {
41
- plugins: LoadedPlugin[];
42
- config: Configuration;
43
- isServer: boolean;
44
- jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined;
45
- }): Configuration;
46
23
  declare global {
47
24
  interface Error {
48
25
  /** @see https://webpack.js.org/api/node/#error-handling */
@@ -6,7 +6,14 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getHttpsConfig = exports.compile = exports.executePluginsConfigureWebpack = exports.executePluginsConfigurePostCss = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = exports.printStatsWarnings = exports.formatStatsErrorMessage = void 0;
9
+ exports.getCustomizableJSLoader = void 0;
10
+ exports.formatStatsErrorMessage = formatStatsErrorMessage;
11
+ exports.printStatsWarnings = printStatsWarnings;
12
+ exports.getStyleLoaders = getStyleLoaders;
13
+ exports.getCustomBabelConfigFilePath = getCustomBabelConfigFilePath;
14
+ exports.getBabelOptions = getBabelOptions;
15
+ exports.compile = compile;
16
+ exports.getHttpsConfig = getHttpsConfig;
10
17
  const tslib_1 = require("tslib");
11
18
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
19
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -14,7 +21,6 @@ const crypto_1 = tslib_1.__importDefault(require("crypto"));
14
21
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
22
  const utils_1 = require("@docusaurus/utils");
16
23
  const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
17
- const webpack_merge_1 = require("webpack-merge");
18
24
  const webpack_1 = tslib_1.__importDefault(require("webpack"));
19
25
  const formatWebpackMessages_1 = tslib_1.__importDefault(require("react-dev-utils/formatWebpackMessages"));
20
26
  function formatStatsErrorMessage(statsJson) {
@@ -29,7 +35,6 @@ function formatStatsErrorMessage(statsJson) {
29
35
  }
30
36
  return undefined;
31
37
  }
32
- exports.formatStatsErrorMessage = formatStatsErrorMessage;
33
38
  function printStatsWarnings(statsJson) {
34
39
  if (statsJson?.warnings?.length) {
35
40
  statsJson.warnings?.forEach((warning) => {
@@ -37,7 +42,6 @@ function printStatsWarnings(statsJson) {
37
42
  });
38
43
  }
39
44
  }
40
- exports.printStatsWarnings = printStatsWarnings;
41
45
  // Utility method to get style loaders
42
46
  function getStyleLoaders(isServer, cssOptionsArg = {}) {
43
47
  const cssOptions = {
@@ -98,14 +102,12 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) {
98
102
  },
99
103
  ];
100
104
  }
101
- exports.getStyleLoaders = getStyleLoaders;
102
105
  async function getCustomBabelConfigFilePath(siteDir) {
103
106
  const customBabelConfigurationPath = path_1.default.join(siteDir, utils_1.BABEL_CONFIG_FILE_NAME);
104
107
  return (await fs_extra_1.default.pathExists(customBabelConfigurationPath))
105
108
  ? customBabelConfigurationPath
106
109
  : undefined;
107
110
  }
108
- exports.getCustomBabelConfigFilePath = getCustomBabelConfigFilePath;
109
111
  function getBabelOptions({ isServer, babelOptions, } = {}) {
110
112
  if (typeof babelOptions === 'string') {
111
113
  return {
@@ -121,7 +123,6 @@ function getBabelOptions({ isServer, babelOptions, } = {}) {
121
123
  caller: { name: isServer ? 'server' : 'client' },
122
124
  };
123
125
  }
124
- exports.getBabelOptions = getBabelOptions;
125
126
  // Name is generic on purpose
126
127
  // we want to support multiple js loader implementations (babel + esbuild)
127
128
  function getDefaultBabelLoader({ isServer, babelOptions, }) {
@@ -134,84 +135,6 @@ const getCustomizableJSLoader = (jsLoader = 'babel') => ({ isServer, babelOption
134
135
  ? getDefaultBabelLoader({ isServer, babelOptions })
135
136
  : jsLoader(isServer);
136
137
  exports.getCustomizableJSLoader = getCustomizableJSLoader;
137
- /**
138
- * Helper function to modify webpack config
139
- * @param configureWebpack a webpack config or a function to modify config
140
- * @param config initial webpack config
141
- * @param isServer indicates if this is a server webpack configuration
142
- * @param jsLoader custom js loader config
143
- * @param content content loaded by the plugin
144
- * @returns final/ modified webpack config
145
- */
146
- function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, content) {
147
- // Export some utility functions
148
- const utils = {
149
- getStyleLoaders,
150
- getJSLoader: (0, exports.getCustomizableJSLoader)(jsLoader),
151
- };
152
- if (typeof configureWebpack === 'function') {
153
- const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content) ?? {};
154
- const customizeRules = mergeStrategy ?? {};
155
- return (0, webpack_merge_1.mergeWithCustomize)({
156
- customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
157
- customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
158
- })(config, res);
159
- }
160
- return config;
161
- }
162
- exports.applyConfigureWebpack = applyConfigureWebpack;
163
- function applyConfigurePostCss(configurePostCss, config) {
164
- // Not ideal heuristic but good enough for our use-case?
165
- function isPostCssLoader(loader) {
166
- return !!loader?.options?.postcssOptions;
167
- }
168
- // Does not handle all edge cases, but good enough for now
169
- function overridePostCssOptions(entry) {
170
- if (isPostCssLoader(entry)) {
171
- entry.options.postcssOptions = configurePostCss(entry.options.postcssOptions);
172
- }
173
- else if (Array.isArray(entry.oneOf)) {
174
- entry.oneOf.forEach((r) => {
175
- if (r) {
176
- overridePostCssOptions(r);
177
- }
178
- });
179
- }
180
- else if (Array.isArray(entry.use)) {
181
- entry.use
182
- .filter((u) => typeof u === 'object')
183
- .forEach((rule) => overridePostCssOptions(rule));
184
- }
185
- }
186
- config.module?.rules?.forEach((rule) => overridePostCssOptions(rule));
187
- return config;
188
- }
189
- exports.applyConfigurePostCss = applyConfigurePostCss;
190
- // Plugin Lifecycle - configurePostCss()
191
- function executePluginsConfigurePostCss({ plugins, config, }) {
192
- let resultConfig = config;
193
- plugins.forEach((plugin) => {
194
- const { configurePostCss } = plugin;
195
- if (configurePostCss) {
196
- resultConfig = applyConfigurePostCss(configurePostCss.bind(plugin), resultConfig);
197
- }
198
- });
199
- return resultConfig;
200
- }
201
- exports.executePluginsConfigurePostCss = executePluginsConfigurePostCss;
202
- // Plugin Lifecycle - configureWebpack()
203
- function executePluginsConfigureWebpack({ plugins, config, isServer, jsLoader, }) {
204
- let resultConfig = config;
205
- plugins.forEach((plugin) => {
206
- const { configureWebpack } = plugin;
207
- if (configureWebpack) {
208
- resultConfig = applyConfigureWebpack(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
209
- resultConfig, isServer, jsLoader, plugin.content);
210
- }
211
- });
212
- return resultConfig;
213
- }
214
- exports.executePluginsConfigureWebpack = executePluginsConfigureWebpack;
215
138
  function compile(config) {
216
139
  return new Promise((resolve, reject) => {
217
140
  const compiler = (0, webpack_1.default)(config);
@@ -244,7 +167,6 @@ function compile(config) {
244
167
  });
245
168
  });
246
169
  }
247
- exports.compile = compile;
248
170
  // Ensure the certificate and key provided are valid and if not
249
171
  // throw an easy to debug error
250
172
  function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
@@ -291,4 +213,3 @@ async function getHttpsConfig() {
291
213
  }
292
214
  return isHttps;
293
215
  }
294
- exports.getHttpsConfig = getHttpsConfig;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "3.3.2",
4
+ "version": "3.5.0",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,12 +43,12 @@
43
43
  "@babel/runtime": "^7.22.6",
44
44
  "@babel/runtime-corejs3": "^7.22.6",
45
45
  "@babel/traverse": "^7.22.8",
46
- "@docusaurus/cssnano-preset": "3.3.2",
47
- "@docusaurus/logger": "3.3.2",
48
- "@docusaurus/mdx-loader": "3.3.2",
49
- "@docusaurus/utils": "3.3.2",
50
- "@docusaurus/utils-common": "3.3.2",
51
- "@docusaurus/utils-validation": "3.3.2",
46
+ "@docusaurus/cssnano-preset": "3.5.0",
47
+ "@docusaurus/logger": "3.5.0",
48
+ "@docusaurus/mdx-loader": "3.5.0",
49
+ "@docusaurus/utils": "3.5.0",
50
+ "@docusaurus/utils-common": "3.5.0",
51
+ "@docusaurus/utils-validation": "3.5.0",
52
52
  "autoprefixer": "^10.4.14",
53
53
  "babel-loader": "^9.1.3",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
@@ -103,8 +103,8 @@
103
103
  "webpackbar": "^5.0.2"
104
104
  },
105
105
  "devDependencies": {
106
- "@docusaurus/module-type-aliases": "3.3.2",
107
- "@docusaurus/types": "3.3.2",
106
+ "@docusaurus/module-type-aliases": "3.5.0",
107
+ "@docusaurus/types": "3.5.0",
108
108
  "@total-typescript/shoehorn": "^0.1.2",
109
109
  "@types/detect-port": "^1.3.3",
110
110
  "@types/react-dom": "^18.2.7",
@@ -124,5 +124,5 @@
124
124
  "engines": {
125
125
  "node": ">=18.0"
126
126
  },
127
- "gitHead": "bc638d674bfbde1e254ef306697f47e764b5e107"
127
+ "gitHead": "cb5829f3c34b26d798b869e38ee25073488140bd"
128
128
  }