@docusaurus/core 2.3.1 → 2.4.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.
@@ -24,6 +24,12 @@ import {
24
24
  } from '../lib/index.js';
25
25
  import beforeCli from './beforeCli.mjs';
26
26
 
27
+ // Env variables are initialized to dev, but can be overridden by each command
28
+ // For example, "docusaurus build" overrides them to "production"
29
+ // See also https://github.com/facebook/docusaurus/issues/8599
30
+ process.env.BABEL_ENV ??= 'development';
31
+ process.env.NODE_ENV ??= 'development';
32
+
27
33
  await beforeCli();
28
34
 
29
35
  cli.version(DOCUSAURUS_VERSION).usage('<command> [options]');
@@ -24,7 +24,7 @@ function createInlineHtmlBanner(baseUrl) {
24
24
  return `
25
25
  <div id="${BannerId}" style="border: thick solid red; background-color: rgb(255, 230, 179); margin: 20px; padding: 20px; font-size: 20px;">
26
26
  <p style="font-weight: bold; font-size: 30px;">Your Docusaurus site did not load properly.</p>
27
- <p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#baseurl" style="font-weight: bold;">baseUrl configuration</a>.</p>
27
+ <p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#baseUrl" style="font-weight: bold;">baseUrl configuration</a>.</p>
28
28
  <p>Current configured baseUrl = <span style="font-weight: bold; color: red;">${baseUrl}</span> ${baseUrl === '/' ? ' (default value)' : ''}</p>
29
29
  <p>We suggest trying baseUrl = <span id="${SuggestionContainerId}" style="font-weight: bold; color: green;"></span></p>
30
30
  </div>
@@ -9,24 +9,39 @@
9
9
  import React from 'react';
10
10
  import Head from '@docusaurus/Head';
11
11
  import ErrorBoundary from '@docusaurus/ErrorBoundary';
12
+ import { getErrorCausalChain } from '@docusaurus/utils-common';
12
13
  import Layout from '@theme/Layout';
13
14
  function ErrorDisplay({ error, tryAgain }) {
14
15
  return (<div style={{
15
16
  display: 'flex',
16
17
  flexDirection: 'column',
17
18
  justifyContent: 'center',
18
- alignItems: 'center',
19
- height: '50vh',
19
+ alignItems: 'flex-start',
20
+ minHeight: '100vh',
20
21
  width: '100%',
22
+ maxWidth: '80ch',
21
23
  fontSize: '20px',
24
+ margin: '0 auto',
25
+ padding: '1rem',
26
+ }}>
27
+ <h1 style={{ fontSize: '3rem' }}>This page crashed</h1>
28
+ <button type="button" onClick={tryAgain} style={{
29
+ margin: '1rem 0',
30
+ fontSize: '2rem',
31
+ cursor: 'pointer',
32
+ borderRadius: 20,
33
+ padding: '1rem',
22
34
  }}>
23
- <h1>This page crashed.</h1>
24
- <p>{error.message}</p>
25
- <button type="button" onClick={tryAgain}>
26
35
  Try again
27
36
  </button>
37
+ <ErrorBoundaryError error={error}/>
28
38
  </div>);
29
39
  }
40
+ function ErrorBoundaryError({ error }) {
41
+ const causalChain = getErrorCausalChain(error);
42
+ const fullMessage = causalChain.map((e) => e.message).join('\n\nCause:\n');
43
+ return <p style={{ whiteSpace: 'pre-wrap' }}>{fullMessage}</p>;
44
+ }
30
45
  export default function Error({ error, tryAgain }) {
31
46
  // We wrap the error in its own error boundary because the layout can actually
32
47
  // throw too... Only the ErrorDisplay component is simple enough to be
@@ -29,6 +29,9 @@ async function build(siteDirParam = '.', cliOptions = {},
29
29
  // deploy, we have to let deploy finish.
30
30
  // See https://github.com/facebook/docusaurus/pull/2496
31
31
  forceTerminate = true) {
32
+ process.env.BABEL_ENV = 'production';
33
+ process.env.NODE_ENV = 'production';
34
+ process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale;
32
35
  const siteDir = await fs_extra_1.default.realpath(siteDirParam);
33
36
  ['SIGINT', 'SIGTERM'].forEach((sig) => {
34
37
  process.on(sig, () => process.exit());
@@ -78,8 +81,10 @@ forceTerminate = true) {
78
81
  }
79
82
  exports.build = build;
80
83
  async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
81
- process.env.BABEL_ENV = 'production';
82
- process.env.NODE_ENV = 'production';
84
+ // Temporary workaround to unlock the ability to translate the site config
85
+ // We'll remove it if a better official API can be designed
86
+ // See https://github.com/facebook/docusaurus/issues/4542
87
+ process.env.DOCUSAURUS_CURRENT_LOCALE = locale;
83
88
  logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
84
89
  const props = await (0, server_1.load)({
85
90
  siteDir,
@@ -26,9 +26,11 @@ const client_1 = tslib_1.__importDefault(require("../webpack/client"));
26
26
  const utils_2 = require("../webpack/utils");
27
27
  const getHostPort_1 = require("../server/getHostPort");
28
28
  async function start(siteDirParam = '.', cliOptions = {}) {
29
+ // Temporary workaround to unlock the ability to translate the site config
30
+ // We'll remove it if a better official API can be designed
31
+ // See https://github.com/facebook/docusaurus/issues/4542
32
+ process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale;
29
33
  const siteDir = await fs_extra_1.default.realpath(siteDirParam);
30
- process.env.NODE_ENV = 'development';
31
- process.env.BABEL_ENV = 'development';
32
34
  logger_1.default.info('Starting the development server...');
33
35
  function loadSite() {
34
36
  return (0, server_1.load)({
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.3.1",
4
+ "version": "2.4.0",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,13 +43,13 @@
43
43
  "@babel/runtime": "^7.18.6",
44
44
  "@babel/runtime-corejs3": "^7.18.6",
45
45
  "@babel/traverse": "^7.18.8",
46
- "@docusaurus/cssnano-preset": "2.3.1",
47
- "@docusaurus/logger": "2.3.1",
48
- "@docusaurus/mdx-loader": "2.3.1",
46
+ "@docusaurus/cssnano-preset": "2.4.0",
47
+ "@docusaurus/logger": "2.4.0",
48
+ "@docusaurus/mdx-loader": "2.4.0",
49
49
  "@docusaurus/react-loadable": "5.5.2",
50
- "@docusaurus/utils": "2.3.1",
51
- "@docusaurus/utils-common": "2.3.1",
52
- "@docusaurus/utils-validation": "2.3.1",
50
+ "@docusaurus/utils": "2.4.0",
51
+ "@docusaurus/utils-common": "2.4.0",
52
+ "@docusaurus/utils-validation": "2.4.0",
53
53
  "@slorber/static-site-generator-webpack-plugin": "^4.0.7",
54
54
  "@svgr/webpack": "^6.2.1",
55
55
  "autoprefixer": "^10.4.7",
@@ -106,8 +106,8 @@
106
106
  "webpackbar": "^5.0.2"
107
107
  },
108
108
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "2.3.1",
110
- "@docusaurus/types": "2.3.1",
109
+ "@docusaurus/module-type-aliases": "2.4.0",
110
+ "@docusaurus/types": "2.4.0",
111
111
  "@types/detect-port": "^1.3.2",
112
112
  "@types/react-dom": "^18.0.6",
113
113
  "@types/react-router-config": "^5.0.6",
@@ -127,5 +127,5 @@
127
127
  "engines": {
128
128
  "node": ">=16.14"
129
129
  },
130
- "gitHead": "cf12f21a10f6c5439ff931e61419c4bb03a5a2dc"
130
+ "gitHead": "898b85ef134cc43bf3b1209aad0ca8cdcfb214c5"
131
131
  }