@docusaurus/core 3.0.0-alpha.0 → 3.0.0-rc.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.
package/bin/beforeCli.mjs CHANGED
@@ -141,7 +141,16 @@ export default async function beforeCli() {
141
141
  margin: 1,
142
142
  align: 'center',
143
143
  borderColor: 'yellow',
144
- borderStyle: 'round',
144
+ borderStyle: {
145
+ topLeft: ' ',
146
+ topRight: ' ',
147
+ bottomLeft: ' ',
148
+ bottomRight: ' ',
149
+ top: '-',
150
+ bottom: '-',
151
+ left: ' ',
152
+ right: ' ',
153
+ },
145
154
  };
146
155
 
147
156
  const docusaurusUpdateMessage = boxen(
package/lib/client/App.js CHANGED
@@ -20,6 +20,7 @@ import SiteMetadataDefaults from './SiteMetadataDefaults';
20
20
  // TODO, quick fix for CSS insertion order
21
21
  // eslint-disable-next-line import/order
22
22
  import ErrorBoundary from '@docusaurus/ErrorBoundary';
23
+ import HasHydratedDataAttribute from './hasHydratedDataAttribute';
23
24
  export default function App() {
24
25
  const routeElement = renderRoutes(routes);
25
26
  const location = useLocation();
@@ -34,6 +35,7 @@ export default function App() {
34
35
  {routeElement}
35
36
  </PendingNavigation>
36
37
  </Root>
38
+ <HasHydratedDataAttribute />
37
39
  </BrowserContextProvider>
38
40
  </DocusaurusContextProvider>
39
41
  </ErrorBoundary>);
@@ -23,8 +23,8 @@ if (ExecutionEnvironment.canUseDOM) {
23
23
  <App />
24
24
  </BrowserRouter>
25
25
  </HelmetProvider>);
26
- const onRecoverableError = (error) => {
27
- console.error('Docusaurus React Root onRecoverableError:', error);
26
+ const onRecoverableError = (error, errorInfo) => {
27
+ console.error('Docusaurus React Root onRecoverableError:', error, errorInfo);
28
28
  };
29
29
  const renderApp = () => {
30
30
  if (hydrate) {
@@ -0,0 +1,8 @@
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="react" />
8
+ export default function HasHydratedDataAttribute(): JSX.Element;
@@ -0,0 +1,17 @@
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 React from 'react';
8
+ import Head from '@docusaurus/Head';
9
+ import useIsBrowser from '@docusaurus/useIsBrowser';
10
+ // See https://github.com/facebook/docusaurus/pull/9256
11
+ // Docusaurus adds a <html data-has-hydrated="true"> after hydration
12
+ export default function HasHydratedDataAttribute() {
13
+ const isBrowser = useIsBrowser();
14
+ return (<Head>
15
+ <html data-has-hydrated={isBrowser}/>
16
+ </Head>);
17
+ }
@@ -151,6 +151,14 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
151
151
  throw err;
152
152
  }
153
153
  shellExecLog('git add --all');
154
+ const gitUserName = process.env.GIT_USER_NAME;
155
+ if (gitUserName) {
156
+ shellExecLog(`git config user.name "${gitUserName}"`);
157
+ }
158
+ const gitUserEmail = process.env.GIT_USER_EMAIL;
159
+ if (gitUserEmail) {
160
+ shellExecLog(`git config user.email "${gitUserEmail}"`);
161
+ }
154
162
  const commitMessage = process.env.CUSTOM_COMMIT_MESSAGE ??
155
163
  `Deploy website - based on ${currentCommit}`;
156
164
  const commitResults = shellExecLog(`git commit -m "${commitMessage}"`);
@@ -10,13 +10,12 @@ exports.loadSiteConfig = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
- const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
14
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
14
  const utils_1 = require("@docusaurus/utils");
16
15
  const configValidation_1 = require("./configValidation");
17
16
  async function findConfig(siteDir) {
18
17
  // We could support .mjs, .ts, etc. in the future
19
- const candidates = ['.js', '.cjs'].map((ext) => utils_1.DEFAULT_CONFIG_FILE_NAME + ext);
18
+ const candidates = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'].map((ext) => utils_1.DEFAULT_CONFIG_FILE_NAME + ext);
20
19
  const configPath = await (0, utils_1.findAsyncSequential)(candidates.map((file) => path_1.default.join(siteDir, file)), fs_extra_1.default.pathExists);
21
20
  if (!configPath) {
22
21
  logger_1.default.error('No config file found.');
@@ -33,7 +32,7 @@ async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
33
32
  if (!(await fs_extra_1.default.pathExists(siteConfigPath))) {
34
33
  throw new Error(`Config file at "${siteConfigPath}" not found.`);
35
34
  }
36
- const importedConfig = (0, import_fresh_1.default)(siteConfigPath);
35
+ const importedConfig = await (0, utils_1.loadFreshModule)(siteConfigPath);
37
36
  const loadedConfig = typeof importedConfig === 'function'
38
37
  ? await importedConfig()
39
38
  : await importedConfig;
@@ -36,6 +36,7 @@ exports.DEFAULT_CONFIG = {
36
36
  baseUrlIssueBanner: true,
37
37
  staticDirectories: [utils_1.DEFAULT_STATIC_DIR_NAME],
38
38
  markdown: {
39
+ format: 'mdx',
39
40
  mermaid: false,
40
41
  preprocessor: undefined,
41
42
  mdx1Compat: {
@@ -210,6 +211,9 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
210
211
  .optional(),
211
212
  }).optional(),
212
213
  markdown: utils_validation_1.Joi.object({
214
+ format: utils_validation_1.Joi.string()
215
+ .equal('mdx', 'md', 'detect')
216
+ .default(exports.DEFAULT_CONFIG.markdown.format),
213
217
  mermaid: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.markdown.mermaid),
214
218
  preprocessor: utils_validation_1.Joi.function()
215
219
  .arity(1)
@@ -102,14 +102,16 @@ export default ${JSON.stringify(siteConfig, null, 2)};
102
102
  ${clientModules
103
103
  // Use `require()` because `import()` is async but client modules can have CSS
104
104
  // and the order matters for loading CSS.
105
- .map((clientModule) => ` require('${(0, utils_1.escapePath)(clientModule)}'),`)
105
+ .map((clientModule) => ` require("${(0, utils_1.escapePath)(clientModule)}"),`)
106
106
  .join('\n')}
107
107
  ];
108
108
  `);
109
109
  const genRegistry = (0, utils_1.generate)(generatedFilesDir, 'registry.js', `export default {
110
110
  ${Object.entries(registry)
111
111
  .sort((a, b) => a[0].localeCompare(b[0]))
112
- .map(([chunkName, modulePath]) => ` '${chunkName}': [() => import(/* webpackChunkName: '${chunkName}' */ '${modulePath}'), '${modulePath}', require.resolveWeak('${modulePath}')],`)
112
+ .map(([chunkName, modulePath]) =>
113
+ // modulePath is already escaped by escapePath
114
+ ` "${chunkName}": [() => import(/* webpackChunkName: "${chunkName}" */ "${modulePath}"), "${modulePath}", require.resolveWeak("${modulePath}")],`)
113
115
  .join('\n')}};
114
116
  `);
115
117
  const genRoutesChunkNames = (0, utils_1.generate)(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
@@ -7,9 +7,8 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadPluginConfigs = void 0;
10
- const tslib_1 = require("tslib");
11
10
  const module_1 = require("module");
12
- const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
11
+ const utils_1 = require("@docusaurus/utils");
13
12
  const presets_1 = require("./presets");
14
13
  const moduleShorthand_1 = require("./moduleShorthand");
15
14
  async function normalizePluginConfig(pluginConfig, configPath, pluginRequire) {
@@ -17,7 +16,7 @@ async function normalizePluginConfig(pluginConfig, configPath, pluginRequire) {
17
16
  if (typeof pluginConfig === 'string') {
18
17
  const pluginModuleImport = pluginConfig;
19
18
  const pluginPath = pluginRequire.resolve(pluginModuleImport);
20
- const pluginModule = (0, import_fresh_1.default)(pluginPath);
19
+ const pluginModule = (await (0, utils_1.loadFreshModule)(pluginPath));
21
20
  return {
22
21
  plugin: pluginModule.default ?? pluginModule,
23
22
  options: {},
@@ -42,7 +41,7 @@ async function normalizePluginConfig(pluginConfig, configPath, pluginRequire) {
42
41
  if (typeof pluginConfig[0] === 'string') {
43
42
  const pluginModuleImport = pluginConfig[0];
44
43
  const pluginPath = pluginRequire.resolve(pluginModuleImport);
45
- const pluginModule = (0, import_fresh_1.default)(pluginPath);
44
+ const pluginModule = (await (0, utils_1.loadFreshModule)(pluginPath));
46
45
  return {
47
46
  plugin: pluginModule.default ?? pluginModule,
48
47
  options: pluginConfig[1],
@@ -7,9 +7,8 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadPresets = void 0;
10
- const tslib_1 = require("tslib");
11
10
  const module_1 = require("module");
12
- const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
11
+ const utils_1 = require("@docusaurus/utils");
13
12
  const moduleShorthand_1 = require("./moduleShorthand");
14
13
  /**
15
14
  * Calls preset functions, aggregates each of their return values, and returns
@@ -19,15 +18,10 @@ async function loadPresets(context) {
19
18
  // We need to resolve plugins from the perspective of the site config, as if
20
19
  // we are using `require.resolve` on those module names.
21
20
  const presetRequire = (0, module_1.createRequire)(context.siteConfigPath);
22
- const { presets } = context.siteConfig;
23
- const plugins = [];
24
- const themes = [];
25
- presets.forEach((presetItem) => {
21
+ const presets = context.siteConfig.presets.filter((p) => !!p);
22
+ async function loadPreset(presetItem) {
26
23
  let presetModuleImport;
27
24
  let presetOptions = {};
28
- if (!presetItem) {
29
- return;
30
- }
31
25
  if (typeof presetItem === 'string') {
32
26
  presetModuleImport = presetItem;
33
27
  }
@@ -35,15 +29,14 @@ async function loadPresets(context) {
35
29
  [presetModuleImport, presetOptions] = presetItem;
36
30
  }
37
31
  const presetName = (0, moduleShorthand_1.resolveModuleName)(presetModuleImport, presetRequire, 'preset');
38
- const presetModule = (0, import_fresh_1.default)(presetRequire.resolve(presetName));
39
- const preset = (presetModule.default ?? presetModule)(context, presetOptions);
40
- if (preset.plugins) {
41
- plugins.push(...preset.plugins);
42
- }
43
- if (preset.themes) {
44
- themes.push(...preset.themes);
45
- }
46
- });
32
+ const presetPath = presetRequire.resolve(presetName);
33
+ const presetModule = (await (0, utils_1.loadFreshModule)(presetPath));
34
+ const presetFunction = presetModule.default ?? presetModule;
35
+ return presetFunction(context, presetOptions);
36
+ }
37
+ const loadedPresets = await Promise.all(presets.map(loadPreset));
38
+ const plugins = loadedPresets.flatMap((preset) => preset.plugins ?? []);
39
+ const themes = loadedPresets.flatMap((preset) => preset.themes ?? []);
47
40
  return { plugins, themes };
48
41
  }
49
42
  exports.loadPresets = loadPresets;
@@ -10,7 +10,6 @@ exports.loadSiteMetadata = exports.getPluginVersion = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
13
- const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
13
  const utils_1 = require("@docusaurus/utils");
15
14
  async function getPackageJsonVersion(packageJsonPath) {
16
15
  if (await fs_extra_1.default.pathExists(packageJsonPath)) {
@@ -60,10 +59,9 @@ function checkDocusaurusPackagesVersion(siteMetadata) {
60
59
  versionInfo.name?.startsWith('@docusaurus/') &&
61
60
  versionInfo.version &&
62
61
  versionInfo.version !== docusaurusVersion) {
63
- // Should we throw instead? It still could work with different versions
64
- logger_1.default.error `Invalid name=${plugin} version number=${versionInfo.version}.
62
+ throw new Error(`Invalid name=${plugin} version number=${versionInfo.version}.
65
63
  All official @docusaurus/* packages should have the exact same version as @docusaurus/core (number=${docusaurusVersion}).
66
- Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?`;
64
+ Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?`);
67
65
  }
68
66
  });
69
67
  }
@@ -30,6 +30,7 @@ const tslib_1 = require("tslib");
30
30
  // Modified to optimize performance for Docusaurus specific use case
31
31
  // More context: https://github.com/facebook/docusaurus/pull/1839
32
32
  const path_1 = tslib_1.__importDefault(require("path"));
33
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
33
34
  const del_1 = require("del");
34
35
  class CleanWebpackPlugin {
35
36
  constructor(options = {}) {
@@ -89,6 +90,13 @@ class CleanWebpackPlugin {
89
90
  if (this.initialClean) {
90
91
  return;
91
92
  }
93
+ if (
94
+ // eslint-disable-next-line no-restricted-properties
95
+ fs_extra_1.default.pathExistsSync(this.outputPath) &&
96
+ // eslint-disable-next-line no-restricted-properties
97
+ fs_extra_1.default.statSync(this.outputPath).isFile()) {
98
+ throw new Error(`A file '${this.outputPath}' already exists. Docusaurus needs this directory to save the build output. Either remove/change the file or choose a different build directory via '--out-dir'.`);
99
+ }
92
100
  this.initialClean = true;
93
101
  this.removeFiles(this.cleanOnceBeforeBuildPatterns);
94
102
  }
@@ -173,7 +173,11 @@ function applyConfigurePostCss(configurePostCss, config) {
173
173
  entry.options.postcssOptions = configurePostCss(entry.options.postcssOptions);
174
174
  }
175
175
  else if (Array.isArray(entry.oneOf)) {
176
- entry.oneOf.forEach(overridePostCssOptions);
176
+ entry.oneOf.forEach((r) => {
177
+ if (r) {
178
+ overridePostCssOptions(r);
179
+ }
180
+ });
177
181
  }
178
182
  else if (Array.isArray(entry.use)) {
179
183
  entry.use
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.0.0-alpha.0",
4
+ "version": "3.0.0-rc.0",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -33,27 +33,27 @@
33
33
  "url": "https://github.com/facebook/docusaurus/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@babel/core": "^7.20.12",
37
- "@babel/generator": "^7.21.1",
36
+ "@babel/core": "^7.22.9",
37
+ "@babel/generator": "^7.22.9",
38
38
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
39
- "@babel/plugin-transform-runtime": "^7.21.0",
40
- "@babel/preset-env": "^7.20.2",
41
- "@babel/preset-react": "^7.18.6",
42
- "@babel/preset-typescript": "^7.21.0",
43
- "@babel/runtime": "^7.21.0",
44
- "@babel/runtime-corejs3": "^7.21.0",
45
- "@babel/traverse": "^7.21.2",
46
- "@docusaurus/cssnano-preset": "3.0.0-alpha.0",
47
- "@docusaurus/logger": "3.0.0-alpha.0",
48
- "@docusaurus/mdx-loader": "3.0.0-alpha.0",
39
+ "@babel/plugin-transform-runtime": "^7.22.9",
40
+ "@babel/preset-env": "^7.22.9",
41
+ "@babel/preset-react": "^7.22.5",
42
+ "@babel/preset-typescript": "^7.22.5",
43
+ "@babel/runtime": "^7.22.6",
44
+ "@babel/runtime-corejs3": "^7.22.6",
45
+ "@babel/traverse": "^7.22.8",
46
+ "@docusaurus/cssnano-preset": "3.0.0-rc.0",
47
+ "@docusaurus/logger": "3.0.0-rc.0",
48
+ "@docusaurus/mdx-loader": "3.0.0-rc.0",
49
49
  "@docusaurus/react-loadable": "5.5.2",
50
- "@docusaurus/utils": "3.0.0-alpha.0",
51
- "@docusaurus/utils-common": "3.0.0-alpha.0",
52
- "@docusaurus/utils-validation": "3.0.0-alpha.0",
50
+ "@docusaurus/utils": "3.0.0-rc.0",
51
+ "@docusaurus/utils-common": "3.0.0-rc.0",
52
+ "@docusaurus/utils-validation": "3.0.0-rc.0",
53
53
  "@slorber/static-site-generator-webpack-plugin": "^4.0.7",
54
54
  "@svgr/webpack": "^6.5.1",
55
- "autoprefixer": "^10.4.13",
56
- "babel-loader": "^9.1.2",
55
+ "autoprefixer": "^10.4.14",
56
+ "babel-loader": "^9.1.3",
57
57
  "babel-plugin-dynamic-import-node": "^2.3.3",
58
58
  "boxen": "^6.2.1",
59
59
  "chalk": "^4.1.2",
@@ -63,25 +63,24 @@
63
63
  "combine-promises": "^1.1.0",
64
64
  "commander": "^5.1.0",
65
65
  "copy-webpack-plugin": "^11.0.0",
66
- "core-js": "^3.29.0",
67
- "css-loader": "^6.7.3",
66
+ "core-js": "^3.31.1",
67
+ "css-loader": "^6.8.1",
68
68
  "css-minimizer-webpack-plugin": "^4.2.2",
69
69
  "cssnano": "^5.1.15",
70
70
  "del": "^6.1.1",
71
71
  "detect-port": "^1.5.1",
72
72
  "escape-html": "^1.0.3",
73
- "eta": "^2.0.1",
73
+ "eta": "^2.2.0",
74
74
  "file-loader": "^6.2.0",
75
- "fs-extra": "^11.1.0",
76
- "html-minifier-terser": "^7.1.0",
77
- "html-tags": "^3.2.0",
78
- "html-webpack-plugin": "^5.5.0",
79
- "import-fresh": "^3.3.0",
75
+ "fs-extra": "^11.1.1",
76
+ "html-minifier-terser": "^7.2.0",
77
+ "html-tags": "^3.3.1",
78
+ "html-webpack-plugin": "^5.5.3",
80
79
  "leven": "^3.1.0",
81
80
  "lodash": "^4.17.21",
82
- "mini-css-extract-plugin": "^2.7.3",
83
- "postcss": "^8.4.21",
84
- "postcss-loader": "^7.0.2",
81
+ "mini-css-extract-plugin": "^2.7.6",
82
+ "postcss": "^8.4.26",
83
+ "postcss-loader": "^7.3.3",
85
84
  "prompts": "^2.4.2",
86
85
  "react-dev-utils": "^12.0.1",
87
86
  "react-helmet-async": "^1.3.0",
@@ -91,29 +90,29 @@
91
90
  "react-router-config": "^5.1.1",
92
91
  "react-router-dom": "^5.3.4",
93
92
  "rtl-detect": "^1.0.4",
94
- "semver": "^7.3.8",
93
+ "semver": "^7.5.4",
95
94
  "serve-handler": "^6.1.5",
96
95
  "shelljs": "^0.8.5",
97
- "terser-webpack-plugin": "^5.3.7",
98
- "tslib": "^2.5.0",
96
+ "terser-webpack-plugin": "^5.3.9",
97
+ "tslib": "^2.6.0",
99
98
  "update-notifier": "^6.0.2",
100
99
  "url-loader": "^4.1.1",
101
100
  "wait-on": "^7.0.1",
102
- "webpack": "^5.76.0",
103
- "webpack-bundle-analyzer": "^4.8.0",
104
- "webpack-dev-server": "^4.11.1",
105
- "webpack-merge": "^5.8.0",
101
+ "webpack": "^5.88.1",
102
+ "webpack-bundle-analyzer": "^4.9.0",
103
+ "webpack-dev-server": "^4.15.1",
104
+ "webpack-merge": "^5.9.0",
106
105
  "webpackbar": "^5.0.2"
107
106
  },
108
107
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "3.0.0-alpha.0",
110
- "@docusaurus/types": "3.0.0-alpha.0",
111
- "@types/detect-port": "^1.3.2",
112
- "@types/react-dom": "^18.0.11",
113
- "@types/react-router-config": "^5.0.6",
108
+ "@docusaurus/module-type-aliases": "3.0.0-rc.0",
109
+ "@docusaurus/types": "3.0.0-rc.0",
110
+ "@types/detect-port": "^1.3.3",
111
+ "@types/react-dom": "^18.2.7",
112
+ "@types/react-router-config": "^5.0.7",
114
113
  "@types/rtl-detect": "^1.0.0",
115
114
  "@types/serve-handler": "^6.1.1",
116
- "@types/update-notifier": "^6.0.2",
115
+ "@types/update-notifier": "^6.0.4",
117
116
  "@types/wait-on": "^5.3.1",
118
117
  "@types/webpack-bundle-analyzer": "^4.6.0",
119
118
  "react-test-renderer": "^18.0.0",
@@ -125,7 +124,7 @@
125
124
  "react-dom": "^18.0.0"
126
125
  },
127
126
  "engines": {
128
- "node": ">=16.14"
127
+ "node": ">=18.0"
129
128
  },
130
- "gitHead": "7327f7ff880ed97ad7855744e59c9c55d467a950"
129
+ "gitHead": "e66dfe04d2972edce66f431908470c61340f8ffc"
131
130
  }