@docusaurus/core 3.6.0 → 3.6.1-canary-6141
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/lib/server/site.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export type LoadContextParams = {
|
|
|
22
22
|
*/
|
|
23
23
|
localizePath?: boolean;
|
|
24
24
|
};
|
|
25
|
-
export type LoadSiteParams = LoadContextParams
|
|
25
|
+
export type LoadSiteParams = LoadContextParams & {
|
|
26
|
+
isReload?: boolean;
|
|
27
|
+
};
|
|
26
28
|
export type Site = {
|
|
27
29
|
props: Props;
|
|
28
30
|
params: LoadSiteParams;
|
|
@@ -40,6 +42,6 @@ export declare function loadContext(params: LoadContextParams): Promise<LoadCont
|
|
|
40
42
|
* lifecycles to generate content and other data. It is side-effect-ful because
|
|
41
43
|
* it generates temp files in the `.docusaurus` folder for the bundler.
|
|
42
44
|
*/
|
|
43
|
-
export declare function loadSite(params:
|
|
45
|
+
export declare function loadSite(params: LoadSiteParams): Promise<Site>;
|
|
44
46
|
export declare function reloadSite(site: Site): Promise<Site>;
|
|
45
47
|
export declare function reloadSitePlugin(site: Site, pluginIdentifier: PluginIdentifier): Promise<Site>;
|
package/lib/server/site.js
CHANGED
|
@@ -26,6 +26,7 @@ const translations_1 = require("./translations/translations");
|
|
|
26
26
|
const codegen_1 = require("./codegen/codegen");
|
|
27
27
|
const routes_1 = require("./routes");
|
|
28
28
|
const storage_1 = require("./storage");
|
|
29
|
+
const siteMessages_1 = require("./siteMessages");
|
|
29
30
|
/**
|
|
30
31
|
* Loading context is the very first step in site building. Its params are
|
|
31
32
|
* directly acquired from CLI options. It mainly loads `siteConfig` and the i18n
|
|
@@ -147,13 +148,20 @@ async function loadSite(params) {
|
|
|
147
148
|
site,
|
|
148
149
|
globalData,
|
|
149
150
|
});
|
|
151
|
+
// For now, we don't re-emit messages on site reloads, it's too verbose
|
|
152
|
+
if (!params.isReload) {
|
|
153
|
+
await (0, siteMessages_1.emitSiteMessages)({ site });
|
|
154
|
+
}
|
|
150
155
|
return site;
|
|
151
156
|
}
|
|
152
157
|
async function reloadSite(site) {
|
|
153
158
|
// TODO this can be optimized, for example:
|
|
154
159
|
// - plugins loading same data as before should not recreate routes/bundles
|
|
155
160
|
// - codegen does not need to re-run if nothing changed
|
|
156
|
-
return loadSite(
|
|
161
|
+
return loadSite({
|
|
162
|
+
...site.params,
|
|
163
|
+
isReload: true,
|
|
164
|
+
});
|
|
157
165
|
}
|
|
158
166
|
async function reloadSitePlugin(site, pluginIdentifier) {
|
|
159
167
|
const { plugins, routes, globalData } = await (0, plugins_1.reloadPlugin)({
|
|
@@ -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 type { Site } from './site';
|
|
8
|
+
type Params = {
|
|
9
|
+
site: Site;
|
|
10
|
+
};
|
|
11
|
+
type SiteMessage = {
|
|
12
|
+
type: 'warning' | 'error';
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function collectAllSiteMessages(params: Params): Promise<SiteMessage[]>;
|
|
16
|
+
export declare function emitSiteMessages(params: Params): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.collectAllSiteMessages = collectAllSiteMessages;
|
|
10
|
+
exports.emitSiteMessages = emitSiteMessages;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
14
|
+
const babel_1 = require("@docusaurus/babel");
|
|
15
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
16
|
+
const uselessBabelConfigMessages = async ({ site }) => {
|
|
17
|
+
const { props: { siteDir, siteConfig }, } = site;
|
|
18
|
+
if (siteConfig.future.experimental_faster.swcJsLoader) {
|
|
19
|
+
const babelConfigFilePath = await (0, babel_1.getCustomBabelConfigFilePath)(siteDir);
|
|
20
|
+
if (babelConfigFilePath) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: 'warning',
|
|
24
|
+
message: `Your site is using the SWC js loader. You can safely remove the Babel config file at ${logger_1.default.code(path_1.default.relative(process.cwd(), babelConfigFilePath))}.`,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
};
|
|
31
|
+
async function collectAllSiteMessages(params) {
|
|
32
|
+
const messageCreators = [uselessBabelConfigMessages];
|
|
33
|
+
return (await Promise.all(messageCreators.map((createMessages) => createMessages(params)))).flat();
|
|
34
|
+
}
|
|
35
|
+
function printSiteMessages(siteMessages) {
|
|
36
|
+
const [errors, warnings] = lodash_1.default.partition(siteMessages, (sm) => sm.type === 'error');
|
|
37
|
+
if (errors.length > 0) {
|
|
38
|
+
logger_1.default.error(`Docusaurus site errors:
|
|
39
|
+
- ${errors.map((sm) => sm.message).join('\n- ')}`);
|
|
40
|
+
}
|
|
41
|
+
if (warnings.length > 0) {
|
|
42
|
+
logger_1.default.warn(`Docusaurus site warnings:
|
|
43
|
+
- ${warnings.map((sm) => sm.message).join('\n- ')}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function emitSiteMessages(params) {
|
|
47
|
+
const siteMessages = await collectAllSiteMessages(params);
|
|
48
|
+
printSiteMessages(siteMessages);
|
|
49
|
+
}
|
|
@@ -36,6 +36,12 @@ async function createStaticDirectoriesCopyPlugin({ props, }) {
|
|
|
36
36
|
from: dir,
|
|
37
37
|
to: outDir,
|
|
38
38
|
toType: 'dir',
|
|
39
|
+
info: {
|
|
40
|
+
// Prevents Webpack from minimizing static files (js/css)
|
|
41
|
+
// see https://github.com/facebook/docusaurus/pull/10658
|
|
42
|
+
// see https://github.com/webpack-contrib/copy-webpack-plugin#skip-running-javascript-files-through-a-minimizer
|
|
43
|
+
minimized: true,
|
|
44
|
+
},
|
|
39
45
|
})),
|
|
40
46
|
});
|
|
41
47
|
}
|
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.6.
|
|
4
|
+
"version": "3.6.1-canary-6141",
|
|
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.6.
|
|
37
|
-
"@docusaurus/bundler": "3.6.
|
|
38
|
-
"@docusaurus/logger": "3.6.
|
|
39
|
-
"@docusaurus/mdx-loader": "3.6.
|
|
40
|
-
"@docusaurus/utils": "3.6.
|
|
41
|
-
"@docusaurus/utils-common": "3.6.
|
|
42
|
-
"@docusaurus/utils-validation": "3.6.
|
|
36
|
+
"@docusaurus/babel": "3.6.1-canary-6141",
|
|
37
|
+
"@docusaurus/bundler": "3.6.1-canary-6141",
|
|
38
|
+
"@docusaurus/logger": "3.6.1-canary-6141",
|
|
39
|
+
"@docusaurus/mdx-loader": "3.6.1-canary-6141",
|
|
40
|
+
"@docusaurus/utils": "3.6.1-canary-6141",
|
|
41
|
+
"@docusaurus/utils-common": "3.6.1-canary-6141",
|
|
42
|
+
"@docusaurus/utils-validation": "3.6.1-canary-6141",
|
|
43
43
|
"boxen": "^6.2.1",
|
|
44
44
|
"chalk": "^4.1.2",
|
|
45
45
|
"chokidar": "^3.5.3",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"webpack-merge": "^6.0.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@docusaurus/module-type-aliases": "3.6.
|
|
82
|
-
"@docusaurus/types": "3.6.
|
|
81
|
+
"@docusaurus/module-type-aliases": "3.6.1-canary-6141",
|
|
82
|
+
"@docusaurus/types": "3.6.1-canary-6141",
|
|
83
83
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
84
84
|
"@types/detect-port": "^1.3.3",
|
|
85
85
|
"@types/react-dom": "^18.2.7",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=18.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "1cded62199840b5801ba20634092dc3a658eb9f2"
|
|
104
104
|
}
|