@docusaurus/core 3.7.0-canary-6303 → 3.7.0-canary-6305
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.
|
@@ -12,7 +12,7 @@ import { renderToHtml } from './renderToHtml';
|
|
|
12
12
|
import preload from './preload';
|
|
13
13
|
import App from './App';
|
|
14
14
|
import { createStatefulBrokenLinks, BrokenLinksProvider, } from './BrokenLinksContext';
|
|
15
|
-
import {
|
|
15
|
+
import { toPageCollectedMetadataInternal } from './serverHelmetUtils';
|
|
16
16
|
const render = async ({ pathname, v4RemoveLegacyPostBuildHeadAttribute, }) => {
|
|
17
17
|
await preload(pathname);
|
|
18
18
|
const modules = new Set();
|
|
@@ -32,7 +32,7 @@ const render = async ({ pathname, v4RemoveLegacyPostBuildHeadAttribute, }) => {
|
|
|
32
32
|
</Loadable.Capture>);
|
|
33
33
|
const html = await renderToHtml(app);
|
|
34
34
|
const { helmet } = helmetContext;
|
|
35
|
-
const metadata =
|
|
35
|
+
const metadata = toPageCollectedMetadataInternal({ helmet });
|
|
36
36
|
// TODO Docusaurus v4 remove with deprecated postBuild({head}) API
|
|
37
37
|
// the returned collectedData must be serializable to run in workers
|
|
38
38
|
if (v4RemoveLegacyPostBuildHeadAttribute) {
|
|
@@ -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 type {
|
|
7
|
+
import type { PageCollectedMetadataInternal } from '../common';
|
|
8
8
|
import type { HelmetServerState } from 'react-helmet-async';
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function toPageCollectedMetadataInternal({ helmet, }: {
|
|
10
10
|
helmet: HelmetServerState;
|
|
11
|
-
}):
|
|
11
|
+
}): PageCollectedMetadataInternal;
|
|
@@ -19,7 +19,7 @@ function isNoIndexTag(tag) {
|
|
|
19
19
|
// Robots directives are not case-sensitive
|
|
20
20
|
tag.content.toLowerCase().includes('noindex'));
|
|
21
21
|
}
|
|
22
|
-
export function
|
|
22
|
+
export function toPageCollectedMetadataInternal({ helmet, }) {
|
|
23
23
|
const tags = getBuildMetaTags(helmet);
|
|
24
24
|
const noIndex = tags.some(isNoIndexTag);
|
|
25
25
|
return {
|
package/lib/ssg/ssgExecutor.js
CHANGED
|
@@ -22,7 +22,7 @@ const ssgWorkerInline_1 = require("./ssgWorkerInline");
|
|
|
22
22
|
const createSimpleSSGExecutor = async ({ params, pathnames, }) => {
|
|
23
23
|
return {
|
|
24
24
|
run: () => {
|
|
25
|
-
return logger_1.PerfLogger.async('
|
|
25
|
+
return logger_1.PerfLogger.async('SSG (current thread)', async () => {
|
|
26
26
|
const ssgResults = await (0, ssgWorkerInline_1.executeSSGInlineTask)({
|
|
27
27
|
pathnames,
|
|
28
28
|
params,
|
|
@@ -73,7 +73,7 @@ const createPooledSSGExecutor = async ({ params, pathnames, }) => {
|
|
|
73
73
|
if (numberOfThreads === 1) {
|
|
74
74
|
return createSimpleSSGExecutor({ params, pathnames });
|
|
75
75
|
}
|
|
76
|
-
const pool = await logger_1.PerfLogger.async(`Create SSG pool - ${logger_1.default.cyan(numberOfThreads)} threads`, async () => {
|
|
76
|
+
const pool = await logger_1.PerfLogger.async(`Create SSG thread pool - ${logger_1.default.cyan(numberOfThreads)} threads`, async () => {
|
|
77
77
|
const Tinypool = await import('tinypool').then((m) => m.default);
|
|
78
78
|
const workerURL = (0, node_url_1.pathToFileURL)(path.resolve(__dirname, 'ssgWorkerThread.js'));
|
|
79
79
|
return new Tinypool({
|
|
@@ -88,10 +88,16 @@ const createPooledSSGExecutor = async ({ params, pathnames, }) => {
|
|
|
88
88
|
});
|
|
89
89
|
const pathnamesChunks = lodash_1.default.chunk(pathnames, ssgEnv_1.SSGWorkerThreadTaskSize);
|
|
90
90
|
// Tiny wrapper for type-safety
|
|
91
|
-
const submitTask = (task) =>
|
|
91
|
+
const submitTask = async (task) => {
|
|
92
|
+
const result = await pool.run(task);
|
|
93
|
+
// Note, we don't use PerfLogger.async() because all tasks are submitted
|
|
94
|
+
// immediately at once and queued, while results are received progressively
|
|
95
|
+
logger_1.PerfLogger.log(`Result for task ${logger_1.default.name(task.id)}`);
|
|
96
|
+
return result;
|
|
97
|
+
};
|
|
92
98
|
return {
|
|
93
99
|
run: async () => {
|
|
94
|
-
const results = await logger_1.PerfLogger.async(`
|
|
100
|
+
const results = await logger_1.PerfLogger.async(`Thread pool`, async () => {
|
|
95
101
|
return Promise.all(pathnamesChunks.map((taskPathnames, taskIndex) => {
|
|
96
102
|
return submitTask({
|
|
97
103
|
id: taskIndex + 1,
|
package/lib/ssg/ssgRenderer.d.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { SSGParams } from './ssgParams';
|
|
8
|
-
import type {
|
|
8
|
+
import type { PageCollectedData } from '../common';
|
|
9
9
|
export type SSGSuccess = {
|
|
10
10
|
success: true;
|
|
11
11
|
pathname: string;
|
|
12
12
|
result: {
|
|
13
|
-
collectedData:
|
|
13
|
+
collectedData: PageCollectedData;
|
|
14
14
|
warnings: string[];
|
|
15
15
|
};
|
|
16
16
|
};
|
package/lib/ssg/ssgRenderer.js
CHANGED
|
@@ -74,6 +74,23 @@ async function loadSSGRenderer({ params, }) {
|
|
|
74
74
|
},
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
+
// We reduce the page collected data structure after the HTML file is written
|
|
78
|
+
// Some data (modules, metadata.internal) is only useful to create the HTML file
|
|
79
|
+
// It's not useful to aggregate that collected data in memory
|
|
80
|
+
// Keep this data structure as small as possible
|
|
81
|
+
// See https://github.com/facebook/docusaurus/pull/11162
|
|
82
|
+
function reduceCollectedData(pageCollectedData) {
|
|
83
|
+
// We re-create the object from scratch
|
|
84
|
+
// We absolutely want to avoid TS duck typing
|
|
85
|
+
return {
|
|
86
|
+
anchors: pageCollectedData.anchors,
|
|
87
|
+
metadata: {
|
|
88
|
+
public: pageCollectedData.metadata.public,
|
|
89
|
+
helmet: pageCollectedData.metadata.helmet,
|
|
90
|
+
},
|
|
91
|
+
links: pageCollectedData.links,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
77
94
|
async function generateStaticFile({ pathname, appRenderer, params, htmlMinifier, ssgTemplate, }) {
|
|
78
95
|
try {
|
|
79
96
|
// This only renders the app HTML
|
|
@@ -93,11 +110,12 @@ async function generateStaticFile({ pathname, appRenderer, params, htmlMinifier,
|
|
|
93
110
|
content: minifierResult.code,
|
|
94
111
|
params,
|
|
95
112
|
});
|
|
113
|
+
const collectedData = reduceCollectedData(appRenderResult.collectedData);
|
|
96
114
|
return {
|
|
97
115
|
success: true,
|
|
98
116
|
pathname,
|
|
99
117
|
result: {
|
|
100
|
-
collectedData
|
|
118
|
+
collectedData,
|
|
101
119
|
// As of today, only the html minifier can emit SSG warnings
|
|
102
120
|
warnings: minifierResult.warnings,
|
|
103
121
|
},
|
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.7.0-canary-
|
|
4
|
+
"version": "3.7.0-canary-6305",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docusaurus/babel": "3.7.0-canary-
|
|
37
|
-
"@docusaurus/bundler": "3.7.0-canary-
|
|
38
|
-
"@docusaurus/logger": "3.7.0-canary-
|
|
39
|
-
"@docusaurus/mdx-loader": "3.7.0-canary-
|
|
40
|
-
"@docusaurus/utils": "3.7.0-canary-
|
|
41
|
-
"@docusaurus/utils-common": "3.7.0-canary-
|
|
42
|
-
"@docusaurus/utils-validation": "3.7.0-canary-
|
|
36
|
+
"@docusaurus/babel": "3.7.0-canary-6305",
|
|
37
|
+
"@docusaurus/bundler": "3.7.0-canary-6305",
|
|
38
|
+
"@docusaurus/logger": "3.7.0-canary-6305",
|
|
39
|
+
"@docusaurus/mdx-loader": "3.7.0-canary-6305",
|
|
40
|
+
"@docusaurus/utils": "3.7.0-canary-6305",
|
|
41
|
+
"@docusaurus/utils-common": "3.7.0-canary-6305",
|
|
42
|
+
"@docusaurus/utils-validation": "3.7.0-canary-6305",
|
|
43
43
|
"boxen": "^6.2.1",
|
|
44
44
|
"chalk": "^4.1.2",
|
|
45
45
|
"chokidar": "^3.5.3",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"webpack-merge": "^6.0.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@docusaurus/module-type-aliases": "3.7.0-canary-
|
|
81
|
-
"@docusaurus/types": "3.7.0-canary-
|
|
80
|
+
"@docusaurus/module-type-aliases": "3.7.0-canary-6305",
|
|
81
|
+
"@docusaurus/types": "3.7.0-canary-6305",
|
|
82
82
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
83
83
|
"@types/detect-port": "^1.3.3",
|
|
84
84
|
"@types/react-dom": "^18.2.7",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"engines": {
|
|
99
99
|
"node": ">=18.0"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "23671c5708319ffafb2b94e29eb850e4d6c4fa1b"
|
|
102
102
|
}
|