@docusaurus/core 0.0.0-4307 → 0.0.0-4315
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/commands/external.js +1 -1
- package/lib/commands/swizzle.js +2 -2
- package/lib/commands/writeHeadingIds.js +1 -1
- package/lib/commands/writeTranslations.js +1 -1
- package/lib/server/config.d.ts +1 -1
- package/lib/server/config.js +5 -2
- package/lib/server/plugins/index.js +1 -1
- package/lib/server/plugins/init.d.ts +1 -1
- package/lib/server/plugins/init.js +10 -9
- package/package.json +10 -10
package/lib/commands/external.js
CHANGED
|
@@ -12,7 +12,7 @@ const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
|
|
|
12
12
|
async function externalCommand(cli, siteDir) {
|
|
13
13
|
const context = await (0, server_1.loadContext)(siteDir);
|
|
14
14
|
const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
|
|
15
|
-
const plugins = (0, init_1.default)({ pluginConfigs, context });
|
|
15
|
+
const plugins = await (0, init_1.default)({ pluginConfigs, context });
|
|
16
16
|
// Plugin Lifecycle - extendCli.
|
|
17
17
|
plugins.forEach((plugin) => {
|
|
18
18
|
const { extendCli } = plugin;
|
package/lib/commands/swizzle.js
CHANGED
|
@@ -111,7 +111,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
|
111
111
|
const context = await (0, server_1.loadContext)(siteDir);
|
|
112
112
|
const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
|
|
113
113
|
const pluginNames = getPluginNames(pluginConfigs);
|
|
114
|
-
const plugins = (0, init_1.default)({
|
|
114
|
+
const plugins = await (0, init_1.default)({
|
|
115
115
|
pluginConfigs,
|
|
116
116
|
context,
|
|
117
117
|
});
|
|
@@ -162,7 +162,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
|
162
162
|
}
|
|
163
163
|
// support both commonjs and ES style exports
|
|
164
164
|
const plugin = (_c = pluginModule.default) !== null && _c !== void 0 ? _c : pluginModule;
|
|
165
|
-
const pluginInstance = plugin(context, pluginOptions);
|
|
165
|
+
const pluginInstance = await plugin(context, pluginOptions);
|
|
166
166
|
const themePath = typescript
|
|
167
167
|
? (_d = pluginInstance.getTypeScriptThemePath) === null || _d === void 0 ? void 0 : _d.call(pluginInstance)
|
|
168
168
|
: (_e = pluginInstance.getThemePath) === null || _e === void 0 ? void 0 : _e.call(pluginInstance);
|
|
@@ -87,7 +87,7 @@ async function transformMarkdownFile(filepath, options) {
|
|
|
87
87
|
async function getPathsToWatch(siteDir) {
|
|
88
88
|
const context = await (0, server_1.loadContext)(siteDir);
|
|
89
89
|
const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
|
|
90
|
-
const plugins = (0, init_1.default)({
|
|
90
|
+
const plugins = await (0, init_1.default)({
|
|
91
91
|
pluginConfigs,
|
|
92
92
|
context,
|
|
93
93
|
});
|
|
@@ -51,7 +51,7 @@ async function writeTranslations(siteDir, options) {
|
|
|
51
51
|
locale: options.locale,
|
|
52
52
|
});
|
|
53
53
|
const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
|
|
54
|
-
const plugins = (0, init_1.default)({
|
|
54
|
+
const plugins = await (0, init_1.default)({
|
|
55
55
|
pluginConfigs,
|
|
56
56
|
context,
|
|
57
57
|
});
|
package/lib/server/config.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { DocusaurusConfig } from '@docusaurus/types';
|
|
8
|
-
export default function loadConfig(configPath: string): DocusaurusConfig
|
|
8
|
+
export default function loadConfig(configPath: string): Promise<DocusaurusConfig>;
|
package/lib/server/config.js
CHANGED
|
@@ -10,11 +10,14 @@ const tslib_1 = require("tslib");
|
|
|
10
10
|
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
11
11
|
const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
|
|
12
12
|
const configValidation_1 = require("./configValidation");
|
|
13
|
-
function loadConfig(configPath) {
|
|
13
|
+
async function loadConfig(configPath) {
|
|
14
14
|
if (!fs_extra_1.default.existsSync(configPath)) {
|
|
15
15
|
throw new Error(`Config file at "${configPath}" not found.`);
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const importedConfig = (0, import_fresh_1.default)(configPath);
|
|
18
|
+
const loadedConfig = importedConfig instanceof Function
|
|
19
|
+
? await importedConfig()
|
|
20
|
+
: await importedConfig;
|
|
18
21
|
return (0, configValidation_1.validateConfig)(loadedConfig);
|
|
19
22
|
}
|
|
20
23
|
exports.default = loadConfig;
|
|
@@ -52,7 +52,7 @@ function sortConfig(routeConfigs, baseUrl = '/') {
|
|
|
52
52
|
exports.sortConfig = sortConfig;
|
|
53
53
|
async function loadPlugins({ pluginConfigs, context, }) {
|
|
54
54
|
// 1. Plugin Lifecycle - Initialization/Constructor.
|
|
55
|
-
const plugins = (0, init_1.default)({
|
|
55
|
+
const plugins = await (0, init_1.default)({
|
|
56
56
|
pluginConfigs,
|
|
57
57
|
context,
|
|
58
58
|
});
|
|
@@ -85,7 +85,7 @@ function getThemeValidationFunction(normalizedPluginConfig) {
|
|
|
85
85
|
return normalizedPluginConfig.plugin.validateThemeConfig;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
function initPlugins({ pluginConfigs, context, }) {
|
|
88
|
+
async function initPlugins({ pluginConfigs, context, }) {
|
|
89
89
|
// We need to resolve plugins from the perspective of the siteDir, since the siteDir's package.json
|
|
90
90
|
// declares the dependency on these plugins.
|
|
91
91
|
const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
|
|
@@ -130,11 +130,7 @@ function initPlugins({ pluginConfigs, context, }) {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
.map((pluginConfig) => {
|
|
135
|
-
if (!pluginConfig) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
133
|
+
async function initializePlugin(pluginConfig) {
|
|
138
134
|
const normalizedPluginConfig = normalizePluginConfig(pluginConfig, pluginRequire);
|
|
139
135
|
const pluginVersion = doGetPluginVersion(normalizedPluginConfig);
|
|
140
136
|
const pluginOptions = doValidatePluginOptions(normalizedPluginConfig);
|
|
@@ -143,14 +139,19 @@ function initPlugins({ pluginConfigs, context, }) {
|
|
|
143
139
|
...context.siteConfig.themeConfig,
|
|
144
140
|
...doValidateThemeConfig(normalizedPluginConfig),
|
|
145
141
|
};
|
|
146
|
-
const pluginInstance = normalizedPluginConfig.plugin(context, pluginOptions);
|
|
142
|
+
const pluginInstance = await normalizedPluginConfig.plugin(context, pluginOptions);
|
|
147
143
|
return {
|
|
148
144
|
...pluginInstance,
|
|
149
145
|
options: pluginOptions,
|
|
150
146
|
version: pluginVersion,
|
|
151
147
|
};
|
|
152
|
-
}
|
|
153
|
-
|
|
148
|
+
}
|
|
149
|
+
const plugins = (await Promise.all(pluginConfigs.map((pluginConfig) => {
|
|
150
|
+
if (!pluginConfig) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
return initializePlugin(pluginConfig);
|
|
154
|
+
}))).filter((item) => Boolean(item));
|
|
154
155
|
(0, pluginIds_1.ensureUniquePluginInstanceIds)(plugins);
|
|
155
156
|
return plugins;
|
|
156
157
|
}
|
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-4315",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@babel/runtime": "^7.16.3",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.16.3",
|
|
43
43
|
"@babel/traverse": "^7.16.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4315",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4315",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4315",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4315",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4315",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4315",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.0",
|
|
52
52
|
"@svgr/webpack": "^6.0.0",
|
|
53
53
|
"autoprefixer": "^10.3.5",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
"webpackbar": "^5.0.0-3"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
112
|
-
"@docusaurus/types": "0.0.0-
|
|
111
|
+
"@docusaurus/module-type-aliases": "0.0.0-4315",
|
|
112
|
+
"@docusaurus/types": "0.0.0-4315",
|
|
113
113
|
"@types/copy-webpack-plugin": "^8.0.1",
|
|
114
114
|
"@types/css-minimizer-webpack-plugin": "^3.0.2",
|
|
115
115
|
"@types/detect-port": "^1.3.0",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "74ad9e9368fb6683a9494d7157f79df21cc5ee25"
|
|
132
132
|
}
|