@docusaurus/core 0.0.0-5598 → 0.0.0-5600
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/docusaurus.mjs +4 -0
- package/lib/babel/preset.js +6 -1
- package/lib/client/BaseUrlIssueBanner/index.d.ts +0 -7
- package/lib/client/BaseUrlIssueBanner/index.js +7 -19
- package/lib/client/ClientLifecyclesDispatcher.js +2 -2
- package/lib/client/clientEntry.js +27 -13
- package/lib/client/exports/useIsomorphicLayoutEffect.d.ts +21 -0
- package/lib/client/exports/useIsomorphicLayoutEffect.js +24 -0
- package/lib/client/serverEntry.js +3 -2
- package/lib/client/serverRenderer.d.ts +8 -0
- package/lib/client/serverRenderer.js +61 -0
- package/lib/commands/build.d.ts +1 -0
- package/lib/commands/build.js +6 -1
- package/lib/commands/start.js +1 -1
- package/lib/webpack/client.d.ts +1 -1
- package/lib/webpack/client.js +5 -1
- package/lib/webpack/templates/ssr.html.template.d.ts +1 -1
- package/lib/webpack/templates/ssr.html.template.js +1 -3
- package/package.json +13 -13
package/bin/docusaurus.mjs
CHANGED
|
@@ -37,6 +37,10 @@ cli.version(DOCUSAURUS_VERSION).usage('<command> [options]');
|
|
|
37
37
|
cli
|
|
38
38
|
.command('build [siteDir]')
|
|
39
39
|
.description('Build website.')
|
|
40
|
+
.option(
|
|
41
|
+
'--dev',
|
|
42
|
+
'Builds the website in dev mode, including full React error messages.',
|
|
43
|
+
)
|
|
40
44
|
.option(
|
|
41
45
|
'--bundle-analyzer',
|
|
42
46
|
'visualize size of webpack output files with an interactive zoomable tree map (default: false)',
|
package/lib/babel/preset.js
CHANGED
|
@@ -36,7 +36,12 @@ function getTransformOptions(isServer) {
|
|
|
36
36
|
exclude: ['transform-typeof-symbol'],
|
|
37
37
|
},
|
|
38
38
|
],
|
|
39
|
-
|
|
39
|
+
[
|
|
40
|
+
require.resolve('@babel/preset-react'),
|
|
41
|
+
{
|
|
42
|
+
runtime: 'automatic',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
40
45
|
require.resolve('@babel/preset-typescript'),
|
|
41
46
|
],
|
|
42
47
|
plugins: [
|
|
@@ -6,12 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="react" />
|
|
8
8
|
import './styles.module.css';
|
|
9
|
-
declare const InsertBannerWindowAttribute = "__DOCUSAURUS_INSERT_BASEURL_BANNER";
|
|
10
|
-
declare global {
|
|
11
|
-
interface Window {
|
|
12
|
-
[InsertBannerWindowAttribute]: boolean;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
9
|
/**
|
|
16
10
|
* We want to help the users with a bad baseUrl configuration (very common
|
|
17
11
|
* error). Help message is inlined, and hidden if JS or CSS is able to load.
|
|
@@ -24,4 +18,3 @@ declare global {
|
|
|
24
18
|
* @see https://github.com/facebook/docusaurus/pull/3621
|
|
25
19
|
*/
|
|
26
20
|
export default function MaybeBaseUrlIssueBanner(): JSX.Element | null;
|
|
27
|
-
export {};
|
|
@@ -4,7 +4,7 @@
|
|
|
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 React
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import { useLocation } from '@docusaurus/router';
|
|
9
9
|
import Head from '@docusaurus/Head';
|
|
10
10
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
@@ -16,7 +16,6 @@ import './styles.module.css';
|
|
|
16
16
|
const BannerContainerId = '__docusaurus-base-url-issue-banner-container';
|
|
17
17
|
const BannerId = '__docusaurus-base-url-issue-banner';
|
|
18
18
|
const SuggestionContainerId = '__docusaurus-base-url-issue-banner-suggestion-container';
|
|
19
|
-
const InsertBannerWindowAttribute = '__DOCUSAURUS_INSERT_BASEURL_BANNER';
|
|
20
19
|
// It is important to not use React to render this banner
|
|
21
20
|
// otherwise Google would index it, even if it's hidden with some critical CSS!
|
|
22
21
|
// See https://github.com/facebook/docusaurus/issues/4028
|
|
@@ -36,24 +35,19 @@ function createInlineHtmlBanner(baseUrl) {
|
|
|
36
35
|
function createInlineScript(baseUrl) {
|
|
37
36
|
/* language=js */
|
|
38
37
|
return `
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
document.addEventListener('DOMContentLoaded', maybeInsertBanner);
|
|
42
|
-
|
|
43
|
-
function maybeInsertBanner() {
|
|
44
|
-
var shouldInsert = window['${InsertBannerWindowAttribute}'];
|
|
38
|
+
document.addEventListener('DOMContentLoaded', function maybeInsertBanner() {
|
|
39
|
+
var shouldInsert = typeof window['docusaurus'] === 'undefined';
|
|
45
40
|
shouldInsert && insertBanner();
|
|
46
|
-
}
|
|
41
|
+
});
|
|
47
42
|
|
|
48
43
|
function insertBanner() {
|
|
49
|
-
var bannerContainer = document.
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
44
|
+
var bannerContainer = document.createElement('div');
|
|
45
|
+
bannerContainer.id = '${BannerContainerId}';
|
|
53
46
|
var bannerHtml = ${JSON.stringify(createInlineHtmlBanner(baseUrl))
|
|
54
47
|
// See https://redux.js.org/recipes/server-rendering/#security-considerations
|
|
55
48
|
.replace(/</g, '\\\u003c')};
|
|
56
49
|
bannerContainer.innerHTML = bannerHtml;
|
|
50
|
+
document.body.prepend(bannerContainer);
|
|
57
51
|
var suggestionContainer = document.getElementById('${SuggestionContainerId}');
|
|
58
52
|
var actualHomePagePath = window.location.pathname;
|
|
59
53
|
var suggestedBaseUrl = actualHomePagePath.substr(-1) === '/'
|
|
@@ -65,11 +59,6 @@ function insertBanner() {
|
|
|
65
59
|
}
|
|
66
60
|
function BaseUrlIssueBanner() {
|
|
67
61
|
const { siteConfig: { baseUrl }, } = useDocusaurusContext();
|
|
68
|
-
// useLayoutEffect fires before DOMContentLoaded.
|
|
69
|
-
// It gives the opportunity to avoid inserting the banner in the first place
|
|
70
|
-
useLayoutEffect(() => {
|
|
71
|
-
window[InsertBannerWindowAttribute] = false;
|
|
72
|
-
}, []);
|
|
73
62
|
return (<>
|
|
74
63
|
{!ExecutionEnvironment.canUseDOM && (
|
|
75
64
|
// Safe to use `ExecutionEnvironment`, because `Head` is purely
|
|
@@ -77,7 +66,6 @@ function BaseUrlIssueBanner() {
|
|
|
77
66
|
<Head>
|
|
78
67
|
<script>{createInlineScript(baseUrl)}</script>
|
|
79
68
|
</Head>)}
|
|
80
|
-
<div id={BannerContainerId}/>
|
|
81
69
|
</>);
|
|
82
70
|
}
|
|
83
71
|
/**
|
|
@@ -4,8 +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
|
-
import { useLayoutEffect } from 'react';
|
|
8
7
|
import clientModules from '@generated/client-modules';
|
|
8
|
+
import useIsomorphicLayoutEffect from './exports/useIsomorphicLayoutEffect';
|
|
9
9
|
export function dispatchLifecycleAction(lifecycleAction, ...args) {
|
|
10
10
|
const callbacks = clientModules.map((clientModule) => {
|
|
11
11
|
const lifecycleFunction = (clientModule.default?.[lifecycleAction] ??
|
|
@@ -36,7 +36,7 @@ function scrollAfterNavigation({ location, previousLocation, }) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
function ClientLifecyclesDispatcher({ children, location, previousLocation, }) {
|
|
39
|
-
|
|
39
|
+
useIsomorphicLayoutEffect(() => {
|
|
40
40
|
if (previousLocation !== location) {
|
|
41
41
|
scrollAfterNavigation({ location, previousLocation });
|
|
42
42
|
dispatchLifecycleAction('onRouteDidUpdate', { previousLocation, location });
|
|
@@ -5,29 +5,43 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import ReactDOM from 'react-dom';
|
|
8
|
+
import ReactDOM from 'react-dom/client';
|
|
9
9
|
import { BrowserRouter } from 'react-router-dom';
|
|
10
10
|
import { HelmetProvider } from 'react-helmet-async';
|
|
11
11
|
import ExecutionEnvironment from './exports/ExecutionEnvironment';
|
|
12
12
|
import App from './App';
|
|
13
13
|
import preload from './preload';
|
|
14
14
|
import docusaurus from './docusaurus';
|
|
15
|
+
const hydrate = Boolean(process.env.HYDRATE_CLIENT_ENTRY);
|
|
15
16
|
// Client-side render (e.g: running in browser) to become single-page
|
|
16
17
|
// application (SPA).
|
|
17
18
|
if (ExecutionEnvironment.canUseDOM) {
|
|
18
19
|
window.docusaurus = docusaurus;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const container = document.getElementById('__docusaurus');
|
|
21
|
+
const app = (<HelmetProvider>
|
|
22
|
+
<BrowserRouter>
|
|
23
|
+
<App />
|
|
24
|
+
</BrowserRouter>
|
|
25
|
+
</HelmetProvider>);
|
|
26
|
+
const onRecoverableError = (error) => {
|
|
27
|
+
console.error('Docusaurus React Root onRecoverableError:', error);
|
|
28
|
+
};
|
|
29
|
+
const renderApp = () => {
|
|
30
|
+
if (hydrate) {
|
|
31
|
+
React.startTransition(() => {
|
|
32
|
+
ReactDOM.hydrateRoot(container, app, {
|
|
33
|
+
onRecoverableError,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const root = ReactDOM.createRoot(container, { onRecoverableError });
|
|
39
|
+
React.startTransition(() => {
|
|
40
|
+
root.render(app);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
preload(window.location.pathname).then(renderApp);
|
|
31
45
|
// Webpack Hot Module Replacement API
|
|
32
46
|
if (module.hot) {
|
|
33
47
|
// Self-accepting method/ trick
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { useEffect } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* This hook is like `useLayoutEffect`, but without the SSR warning.
|
|
10
|
+
* It seems hacky but it's used in many React libs (Redux, Formik...).
|
|
11
|
+
* Also mentioned here: https://github.com/facebook/react/issues/16956
|
|
12
|
+
*
|
|
13
|
+
* It is useful when you need to update a ref as soon as possible after a React
|
|
14
|
+
* render (before `useEffect`).
|
|
15
|
+
*
|
|
16
|
+
* TODO should become unnecessary in React v19?
|
|
17
|
+
* https://github.com/facebook/react/pull/26395
|
|
18
|
+
* This was added in core with Docusaurus v3 but kept undocumented on purpose
|
|
19
|
+
*/
|
|
20
|
+
declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
21
|
+
export default useIsomorphicLayoutEffect;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { useEffect, useLayoutEffect } from 'react';
|
|
8
|
+
import ExecutionEnvironment from './ExecutionEnvironment';
|
|
9
|
+
/**
|
|
10
|
+
* This hook is like `useLayoutEffect`, but without the SSR warning.
|
|
11
|
+
* It seems hacky but it's used in many React libs (Redux, Formik...).
|
|
12
|
+
* Also mentioned here: https://github.com/facebook/react/issues/16956
|
|
13
|
+
*
|
|
14
|
+
* It is useful when you need to update a ref as soon as possible after a React
|
|
15
|
+
* render (before `useEffect`).
|
|
16
|
+
*
|
|
17
|
+
* TODO should become unnecessary in React v19?
|
|
18
|
+
* https://github.com/facebook/react/pull/26395
|
|
19
|
+
* This was added in core with Docusaurus v3 but kept undocumented on purpose
|
|
20
|
+
*/
|
|
21
|
+
const useIsomorphicLayoutEffect = ExecutionEnvironment.canUseDOM
|
|
22
|
+
? useLayoutEffect
|
|
23
|
+
: useEffect;
|
|
24
|
+
export default useIsomorphicLayoutEffect;
|
|
@@ -11,11 +11,11 @@ import fs from 'fs-extra';
|
|
|
11
11
|
import _ from 'lodash';
|
|
12
12
|
import * as eta from 'eta';
|
|
13
13
|
import { StaticRouter } from 'react-router-dom';
|
|
14
|
-
import ReactDOMServer from 'react-dom/server';
|
|
15
14
|
import { HelmetProvider } from 'react-helmet-async';
|
|
16
15
|
import { getBundles } from 'react-loadable-ssr-addon-v5-slorber';
|
|
17
16
|
import Loadable from 'react-loadable';
|
|
18
17
|
import { minify } from 'html-minifier-terser';
|
|
18
|
+
import { renderStaticApp } from './serverRenderer';
|
|
19
19
|
import preload from './preload';
|
|
20
20
|
import App from './App';
|
|
21
21
|
import { createStatefulLinksCollector, LinksCollectorProvider, } from './LinksCollector';
|
|
@@ -62,7 +62,7 @@ async function doRender(locals) {
|
|
|
62
62
|
const routerContext = {};
|
|
63
63
|
const helmetContext = {};
|
|
64
64
|
const linksCollector = createStatefulLinksCollector();
|
|
65
|
-
const
|
|
65
|
+
const app = (
|
|
66
66
|
// @ts-expect-error: we are migrating away from react-loadable anyways
|
|
67
67
|
<Loadable.Capture report={(moduleName) => modules.add(moduleName)}>
|
|
68
68
|
<HelmetProvider context={helmetContext}>
|
|
@@ -73,6 +73,7 @@ async function doRender(locals) {
|
|
|
73
73
|
</StaticRouter>
|
|
74
74
|
</HelmetProvider>
|
|
75
75
|
</Loadable.Capture>);
|
|
76
|
+
const appHtml = await renderStaticApp(app);
|
|
76
77
|
onLinksCollected(location, linksCollector.getCollectedLinks());
|
|
77
78
|
const { helmet } = helmetContext;
|
|
78
79
|
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
@@ -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
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
export declare function renderStaticApp(app: ReactNode): Promise<string>;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { renderToPipeableStream } from 'react-dom/server';
|
|
8
|
+
import { Writable } from 'stream';
|
|
9
|
+
export async function renderStaticApp(app) {
|
|
10
|
+
// Inspired from
|
|
11
|
+
// https://react.dev/reference/react-dom/server/renderToPipeableStream#waiting-for-all-content-to-load-for-crawlers-and-static-generation
|
|
12
|
+
// https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/static-entry.js
|
|
13
|
+
const writableStream = new WritableAsPromise();
|
|
14
|
+
const { pipe } = renderToPipeableStream(app, {
|
|
15
|
+
onError(error) {
|
|
16
|
+
writableStream.destroy(error);
|
|
17
|
+
},
|
|
18
|
+
onAllReady() {
|
|
19
|
+
pipe(writableStream);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return writableStream.getPromise();
|
|
23
|
+
}
|
|
24
|
+
// WritableAsPromise inspired by https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/server-utils/writable-as-promise.js
|
|
25
|
+
/* eslint-disable no-underscore-dangle */
|
|
26
|
+
class WritableAsPromise extends Writable {
|
|
27
|
+
_output;
|
|
28
|
+
_deferred;
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this._output = ``;
|
|
32
|
+
this._deferred = {
|
|
33
|
+
promise: null,
|
|
34
|
+
resolve: () => null,
|
|
35
|
+
reject: () => null,
|
|
36
|
+
};
|
|
37
|
+
this._deferred.promise = new Promise((resolve, reject) => {
|
|
38
|
+
this._deferred.resolve = resolve;
|
|
39
|
+
this._deferred.reject = reject;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
_write(chunk, _enc, next) {
|
|
43
|
+
this._output += chunk.toString();
|
|
44
|
+
next();
|
|
45
|
+
}
|
|
46
|
+
_destroy(error, next) {
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
this._deferred.reject(error);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
next();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
end() {
|
|
55
|
+
this._deferred.resolve(this._output);
|
|
56
|
+
return this.destroy();
|
|
57
|
+
}
|
|
58
|
+
getPromise() {
|
|
59
|
+
return this._deferred.promise;
|
|
60
|
+
}
|
|
61
|
+
}
|
package/lib/commands/build.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ import { type LoadContextOptions } from '../server';
|
|
|
8
8
|
export type BuildCLIOptions = Pick<LoadContextOptions, 'config' | 'locale' | 'outDir'> & {
|
|
9
9
|
bundleAnalyzer?: boolean;
|
|
10
10
|
minify?: boolean;
|
|
11
|
+
dev?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export declare function build(siteDirParam?: string, cliOptions?: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
|
package/lib/commands/build.js
CHANGED
|
@@ -32,6 +32,11 @@ forceTerminate = true) {
|
|
|
32
32
|
process.env.BABEL_ENV = 'production';
|
|
33
33
|
process.env.NODE_ENV = 'production';
|
|
34
34
|
process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale;
|
|
35
|
+
if (cliOptions.dev) {
|
|
36
|
+
logger_1.default.info `Building in dev mode`;
|
|
37
|
+
process.env.BABEL_ENV = 'development';
|
|
38
|
+
process.env.NODE_ENV = 'development';
|
|
39
|
+
}
|
|
35
40
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
36
41
|
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
|
37
42
|
process.on(sig, () => process.exit());
|
|
@@ -97,7 +102,7 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
|
|
|
97
102
|
// Apply user webpack config.
|
|
98
103
|
const { outDir, generatedFilesDir, plugins, siteConfig: { baseUrl, onBrokenLinks, staticDirectories: staticDirectoriesOption, }, routes, } = props;
|
|
99
104
|
const clientManifestPath = path_1.default.join(generatedFilesDir, 'client-manifest.json');
|
|
100
|
-
let clientConfig = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify), {
|
|
105
|
+
let clientConfig = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify, true), {
|
|
101
106
|
plugins: [
|
|
102
107
|
// Remove/clean build folders before building bundles.
|
|
103
108
|
new CleanWebpackPlugin_1.default({ verbose: false }),
|
package/lib/commands/start.js
CHANGED
|
@@ -89,7 +89,7 @@ async function start(siteDirParam = '.', cliOptions = {}) {
|
|
|
89
89
|
...{ pollingOptions },
|
|
90
90
|
});
|
|
91
91
|
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) => fsWatcher.on(event, reload));
|
|
92
|
-
let config = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify), {
|
|
92
|
+
let config = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify, false), {
|
|
93
93
|
watchOptions: {
|
|
94
94
|
ignored: /node_modules\/(?!@docusaurus)/,
|
|
95
95
|
poll: cliOptions.poll,
|
package/lib/webpack/client.d.ts
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Props } from '@docusaurus/types';
|
|
8
8
|
import type { Configuration } from 'webpack';
|
|
9
|
-
export default function createClientConfig(props: Props, minify?: boolean): Promise<Configuration>;
|
|
9
|
+
export default function createClientConfig(props: Props, minify?: boolean, hydrate?: boolean): Promise<Configuration>;
|
package/lib/webpack/client.js
CHANGED
|
@@ -11,10 +11,11 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
11
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
13
13
|
const webpackbar_1 = tslib_1.__importDefault(require("webpackbar"));
|
|
14
|
+
const webpack_1 = require("webpack");
|
|
14
15
|
const base_1 = require("./base");
|
|
15
16
|
const ChunkAssetPlugin_1 = tslib_1.__importDefault(require("./plugins/ChunkAssetPlugin"));
|
|
16
17
|
const utils_1 = require("./utils");
|
|
17
|
-
async function createClientConfig(props, minify = true) {
|
|
18
|
+
async function createClientConfig(props, minify = true, hydrate = true) {
|
|
18
19
|
const isBuilding = process.argv[2] === 'build';
|
|
19
20
|
const config = await (0, base_1.createBaseConfig)(props, false, minify);
|
|
20
21
|
const clientConfig = (0, webpack_merge_1.default)(config, {
|
|
@@ -28,6 +29,9 @@ async function createClientConfig(props, minify = true) {
|
|
|
28
29
|
runtimeChunk: true,
|
|
29
30
|
},
|
|
30
31
|
plugins: [
|
|
32
|
+
new webpack_1.DefinePlugin({
|
|
33
|
+
'process.env.HYDRATE_CLIENT_ENTRY': JSON.stringify(hydrate),
|
|
34
|
+
}),
|
|
31
35
|
new ChunkAssetPlugin_1.default(),
|
|
32
36
|
// Show compilation progress bar and build time.
|
|
33
37
|
new webpackbar_1.default({
|
|
@@ -4,5 +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
|
-
declare const _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"generator\" content=\"Docusaurus v<%= it.version %>\">\n <% it.metaAttributes.forEach((metaAttribute) => { %>\n <%~ metaAttribute %>\n <% }); %>\n <%~ it.headTags %>\n <% it.stylesheets.forEach((stylesheet) => { %>\n <link rel=\"stylesheet\" href=\"<%= it.baseUrl %><%= stylesheet %>\" />\n <% }); %>\n <% it.scripts.forEach((script) => { %>\n <script src=\"<%= it.baseUrl %><%= script %>\" defer></script>\n <% }); %>\n </head>\n <body <%~ it.bodyAttributes %>>\n <%~ it.preBodyTags %>\n <div id=\"__docusaurus\"
|
|
7
|
+
declare const _default: "\n<!DOCTYPE html>\n<html <%~ it.htmlAttributes %>>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"generator\" content=\"Docusaurus v<%= it.version %>\">\n <% it.metaAttributes.forEach((metaAttribute) => { %>\n <%~ metaAttribute %>\n <% }); %>\n <%~ it.headTags %>\n <% it.stylesheets.forEach((stylesheet) => { %>\n <link rel=\"stylesheet\" href=\"<%= it.baseUrl %><%= stylesheet %>\" />\n <% }); %>\n <% it.scripts.forEach((script) => { %>\n <script src=\"<%= it.baseUrl %><%= script %>\" defer></script>\n <% }); %>\n </head>\n <body <%~ it.bodyAttributes %>>\n <%~ it.preBodyTags %>\n <div id=\"__docusaurus\"><%~ it.appHtml %></div>\n <%~ it.postBodyTags %>\n </body>\n</html>\n";
|
|
8
8
|
export default _default;
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5600",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.21.0",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
45
45
|
"@babel/traverse": "^7.21.2",
|
|
46
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
47
|
-
"@docusaurus/logger": "0.0.0-
|
|
48
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
46
|
+
"@docusaurus/cssnano-preset": "0.0.0-5600",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5600",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5600",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "0.0.0-
|
|
51
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
52
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
50
|
+
"@docusaurus/utils": "0.0.0-5600",
|
|
51
|
+
"@docusaurus/utils-common": "0.0.0-5600",
|
|
52
|
+
"@docusaurus/utils-validation": "0.0.0-5600",
|
|
53
53
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.7",
|
|
54
54
|
"@svgr/webpack": "^6.5.1",
|
|
55
55
|
"autoprefixer": "^10.4.13",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
110
|
-
"@docusaurus/types": "0.0.0-
|
|
109
|
+
"@docusaurus/module-type-aliases": "0.0.0-5600",
|
|
110
|
+
"@docusaurus/types": "0.0.0-5600",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/react-dom": "^18.0.11",
|
|
113
113
|
"@types/react-router-config": "^5.0.6",
|
|
@@ -116,16 +116,16 @@
|
|
|
116
116
|
"@types/update-notifier": "^6.0.2",
|
|
117
117
|
"@types/wait-on": "^5.3.1",
|
|
118
118
|
"@types/webpack-bundle-analyzer": "^4.6.0",
|
|
119
|
-
"react-test-renderer": "^
|
|
119
|
+
"react-test-renderer": "^18.0.0",
|
|
120
120
|
"tmp-promise": "^3.0.3",
|
|
121
121
|
"tree-node-cli": "^1.6.0"
|
|
122
122
|
},
|
|
123
123
|
"peerDependencies": {
|
|
124
|
-
"react": "^
|
|
125
|
-
"react-dom": "^
|
|
124
|
+
"react": "^18.0.0",
|
|
125
|
+
"react-dom": "^18.0.0"
|
|
126
126
|
},
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": ">=16.14"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "62f084dfadb259afeeb0fca09913a0b382d7d180"
|
|
131
131
|
}
|