@docusaurus/core 4.0.0-canary-7102 → 4.0.0-canary-7130
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 +19 -7
- package/lib/commands/serve/requestHandler.js +30 -0
- package/package.json +14 -13
package/bin/beforeCli.mjs
CHANGED
|
@@ -32,7 +32,7 @@ try {
|
|
|
32
32
|
|
|
33
33
|
const {
|
|
34
34
|
name,
|
|
35
|
-
engines: {node:
|
|
35
|
+
engines: {node: requiredNodeVersion, bun: requiredBunVersion},
|
|
36
36
|
} = packageJson;
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -167,12 +167,24 @@ export default async function beforeCli() {
|
|
|
167
167
|
|
|
168
168
|
// Bun reports an older Node.js version than our requirement, like v26.12.1
|
|
169
169
|
// See https://github.com/meta/docusaurus/pull/13024
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
const bunVersion = process.versions.bun;
|
|
171
|
+
const isBun = bunVersion !== undefined;
|
|
172
|
+
const runtime = isBun
|
|
173
|
+
? {
|
|
174
|
+
name: 'Bun',
|
|
175
|
+
version: bunVersion,
|
|
176
|
+
requiredVersion: requiredBunVersion,
|
|
177
|
+
}
|
|
178
|
+
: {
|
|
179
|
+
name: 'Node.js',
|
|
180
|
+
version: process.version,
|
|
181
|
+
requiredVersion: requiredNodeVersion,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Notify user if the runtime version needs to be updated
|
|
185
|
+
if (!semver.satisfies(runtime.version, runtime.requiredVersion)) {
|
|
186
|
+
logger.error(`Minimum ${runtime.name} version not met :(`);
|
|
187
|
+
logger.info`You are using ${runtime.name} number=${runtime.version}, Requirement: ${runtime.name} number=${runtime.requiredVersion}.`;
|
|
176
188
|
process.exit(1);
|
|
177
189
|
}
|
|
178
190
|
}
|
|
@@ -92,6 +92,9 @@ function createServeRequestHandler({ outDir, baseUrl: configBaseUrl, trailingSla
|
|
|
92
92
|
],
|
|
93
93
|
},
|
|
94
94
|
],
|
|
95
|
+
}, {
|
|
96
|
+
// serve-handler only calls it for 404 errors
|
|
97
|
+
sendError: (absolutePath) => sendNotFoundPage(res, outDir, absolutePath),
|
|
95
98
|
});
|
|
96
99
|
};
|
|
97
100
|
}
|
|
@@ -230,6 +233,33 @@ function getCleanPathname(pathname, baseUrl) {
|
|
|
230
233
|
// Like serve-handler, /index redirects to /
|
|
231
234
|
return cleanPathname === baseUrl.slice(0, -1) ? baseUrl : cleanPathname;
|
|
232
235
|
}
|
|
236
|
+
// Serves the nearest 404.html, like Cloudflare Pages: "/fr/missing" gets the
|
|
237
|
+
// 404 page of the "fr" locale build, "fr/404.html"
|
|
238
|
+
// See https://developers.cloudflare.com/pages/configuration/serving-pages/#not-found-behavior
|
|
239
|
+
async function sendNotFoundPage(res, outDir, absolutePath) {
|
|
240
|
+
const page = await readNearestNotFoundPage(outDir, absolutePath);
|
|
241
|
+
if (page === undefined) {
|
|
242
|
+
res.writeHead(404);
|
|
243
|
+
res.end('Not Found');
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
res.writeHead(404, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
247
|
+
res.end(page);
|
|
248
|
+
}
|
|
249
|
+
async function readNearestNotFoundPage(outDir, absolutePath) {
|
|
250
|
+
const folders = node_path_1.default
|
|
251
|
+
.relative(outDir, absolutePath)
|
|
252
|
+
.split(node_path_1.default.sep)
|
|
253
|
+
.slice(0, -1);
|
|
254
|
+
for (let depth = folders.length; depth >= 0; depth -= 1) {
|
|
255
|
+
const pagePath = node_path_1.default.join(outDir, ...folders.slice(0, depth), '404.html');
|
|
256
|
+
const page = await fs_1.fs.readFile(pagePath).catch(() => undefined);
|
|
257
|
+
if (page !== undefined) {
|
|
258
|
+
return page;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
233
263
|
function redirect(res, statusCode, location) {
|
|
234
264
|
res.writeHead(statusCode, {
|
|
235
265
|
Location: location,
|
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": "4.0.0-canary-
|
|
4
|
+
"version": "4.0.0-canary-7130",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"url": "https://github.com/meta/docusaurus/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@docusaurus/babel": "4.0.0-canary-
|
|
31
|
-
"@docusaurus/bundler": "4.0.0-canary-
|
|
32
|
-
"@docusaurus/fs": "4.0.0-canary-
|
|
33
|
-
"@docusaurus/glob": "4.0.0-canary-
|
|
34
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
35
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
36
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
37
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
38
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
30
|
+
"@docusaurus/babel": "4.0.0-canary-7130",
|
|
31
|
+
"@docusaurus/bundler": "4.0.0-canary-7130",
|
|
32
|
+
"@docusaurus/fs": "4.0.0-canary-7130",
|
|
33
|
+
"@docusaurus/glob": "4.0.0-canary-7130",
|
|
34
|
+
"@docusaurus/logger": "4.0.0-canary-7130",
|
|
35
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-7130",
|
|
36
|
+
"@docusaurus/utils": "4.0.0-canary-7130",
|
|
37
|
+
"@docusaurus/utils-common": "4.0.0-canary-7130",
|
|
38
|
+
"@docusaurus/utils-validation": "4.0.0-canary-7130",
|
|
39
39
|
"@rspack/core": "^2.3.0",
|
|
40
40
|
"@rspack/dev-server": "^2.2.2",
|
|
41
41
|
"boxen": "^9.0.0",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"webpack-merge": "^6.0.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
72
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
71
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-7130",
|
|
72
|
+
"@docusaurus/types": "4.0.0-canary-7130",
|
|
73
73
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
74
74
|
"@types/escape-html": "^1.0.4",
|
|
75
75
|
"@types/history": "^4.7.11",
|
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
"react-dom": "^19.3.0"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
|
-
"node": ">=26.13"
|
|
91
|
+
"node": ">=26.13",
|
|
92
|
+
"bun": ">=1.4.3"
|
|
92
93
|
},
|
|
93
94
|
"scripts": {
|
|
94
95
|
"build": "tsc --build && copy-untyped-files",
|