@docusaurus/core 0.0.0-5044 → 0.0.0-5047
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/client/docusaurus.d.ts +1 -1
- package/lib/commands/serve.js +1 -1
- package/lib/commands/swizzle/config.js +4 -6
- package/lib/commands/swizzle/themes.js +1 -1
- package/lib/commands/writeHeadingIds.d.ts +1 -1
- package/lib/commands/writeHeadingIds.js +1 -1
- package/lib/server/plugins/configs.js +2 -2
- package/lib/server/plugins/index.js +1 -1
- package/lib/server/plugins/init.js +3 -3
- package/lib/server/plugins/routeConfig.js +2 -2
- package/lib/server/plugins/synthetic.js +1 -1
- package/lib/server/translations/translationsExtractor.js +2 -4
- package/lib/webpack/base.js +1 -1
- package/lib/webpack/plugins/CleanWebpackPlugin.js +4 -4
- package/lib/webpack/utils.js +6 -8
- package/package.json +10 -10
package/lib/commands/serve.js
CHANGED
|
@@ -45,7 +45,7 @@ async function serve(siteDir, cliOptions) {
|
|
|
45
45
|
}
|
|
46
46
|
// Remove baseUrl before calling serveHandler, because /baseUrl/ should
|
|
47
47
|
// serve /build/index.html, not /build/baseUrl/index.html (does not exist)
|
|
48
|
-
req.url = req.url
|
|
48
|
+
req.url = req.url.replace(baseUrl, '/');
|
|
49
49
|
(0, serve_handler_1.default)(req, res, {
|
|
50
50
|
cleanUrls: true,
|
|
51
51
|
public: dir,
|
|
@@ -13,16 +13,14 @@ const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
|
13
13
|
const common_1 = require("./common");
|
|
14
14
|
const themes_1 = require("./themes");
|
|
15
15
|
function getModuleSwizzleConfig(swizzlePlugin) {
|
|
16
|
-
const getSwizzleConfig = swizzlePlugin.plugin.plugin
|
|
17
|
-
swizzlePlugin.plugin.pluginModule?.module.getSwizzleConfig
|
|
18
|
-
swizzlePlugin.plugin.pluginModule?.module?.getSwizzleConfig;
|
|
16
|
+
const getSwizzleConfig = swizzlePlugin.plugin.plugin.getSwizzleConfig ??
|
|
17
|
+
swizzlePlugin.plugin.pluginModule?.module.getSwizzleConfig;
|
|
19
18
|
if (getSwizzleConfig) {
|
|
20
19
|
return getSwizzleConfig();
|
|
21
20
|
}
|
|
22
21
|
// TODO deprecate getSwizzleComponentList later
|
|
23
|
-
const getSwizzleComponentList = swizzlePlugin.plugin.plugin
|
|
24
|
-
swizzlePlugin.plugin.pluginModule?.module.getSwizzleComponentList
|
|
25
|
-
swizzlePlugin.plugin.pluginModule?.module?.getSwizzleComponentList;
|
|
22
|
+
const getSwizzleComponentList = swizzlePlugin.plugin.plugin.getSwizzleComponentList ??
|
|
23
|
+
swizzlePlugin.plugin.pluginModule?.module.getSwizzleComponentList;
|
|
26
24
|
if (getSwizzleComponentList) {
|
|
27
25
|
const safeComponents = getSwizzleComponentList() ?? [];
|
|
28
26
|
const safeComponentConfig = {
|
|
@@ -65,7 +65,7 @@ function handleInvalidThemeName({ themeNameParam, themeNames, }) {
|
|
|
65
65
|
: logger_1.default.interpolate `Themes available for swizzle: ${themeNames}`}`;
|
|
66
66
|
return process.exit(1);
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
function validateThemeName({ themeNameParam, themeNames, }) {
|
|
69
69
|
const isValidName = themeNames.includes(themeNameParam);
|
|
70
70
|
if (!isValidName) {
|
|
71
71
|
return handleInvalidThemeName({
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type WriteHeadingIDOptions } from '@docusaurus/utils';
|
|
8
|
-
export declare function writeHeadingIds(siteDir: string, files: string[], options: WriteHeadingIDOptions): Promise<void>;
|
|
8
|
+
export declare function writeHeadingIds(siteDir: string, files: string[] | undefined, options: WriteHeadingIDOptions): Promise<void>;
|
|
@@ -32,7 +32,7 @@ async function transformMarkdownFile(filepath, options) {
|
|
|
32
32
|
async function getPathsToWatch(siteDir) {
|
|
33
33
|
const context = await (0, server_1.loadContext)({ siteDir });
|
|
34
34
|
const plugins = await (0, init_1.initPlugins)(context);
|
|
35
|
-
return plugins.flatMap((plugin) => plugin
|
|
35
|
+
return plugins.flatMap((plugin) => plugin.getPathsToWatch?.() ?? []);
|
|
36
36
|
}
|
|
37
37
|
async function writeHeadingIds(siteDir, files, options) {
|
|
38
38
|
const markdownFiles = await (0, utils_2.safeGlobby)(files ?? (await getPathsToWatch(siteDir)), {
|
|
@@ -19,7 +19,7 @@ async function normalizePluginConfig(pluginConfig, configPath, pluginRequire) {
|
|
|
19
19
|
const pluginPath = pluginRequire.resolve(pluginModuleImport);
|
|
20
20
|
const pluginModule = (0, import_fresh_1.default)(pluginPath);
|
|
21
21
|
return {
|
|
22
|
-
plugin: pluginModule
|
|
22
|
+
plugin: pluginModule.default ?? pluginModule,
|
|
23
23
|
options: {},
|
|
24
24
|
pluginModule: {
|
|
25
25
|
path: pluginModuleImport,
|
|
@@ -44,7 +44,7 @@ async function normalizePluginConfig(pluginConfig, configPath, pluginRequire) {
|
|
|
44
44
|
const pluginPath = pluginRequire.resolve(pluginModuleImport);
|
|
45
45
|
const pluginModule = (0, import_fresh_1.default)(pluginPath);
|
|
46
46
|
return {
|
|
47
|
-
plugin: pluginModule
|
|
47
|
+
plugin: pluginModule.default ?? pluginModule,
|
|
48
48
|
options: pluginConfig[1],
|
|
49
49
|
pluginModule: {
|
|
50
50
|
path: pluginModuleImport,
|
|
@@ -33,7 +33,7 @@ async function loadPlugins(context) {
|
|
|
33
33
|
// translation files that the plugin declares.
|
|
34
34
|
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
35
35
|
const content = await plugin.loadContent?.();
|
|
36
|
-
const rawTranslationFiles = (await plugin
|
|
36
|
+
const rawTranslationFiles = (await plugin.getTranslationFiles?.({ content })) ?? [];
|
|
37
37
|
const translationFiles = await Promise.all(rawTranslationFiles.map((translationFile) => (0, translations_1.localizePluginTranslationFile)({
|
|
38
38
|
locale: context.i18n.currentLocale,
|
|
39
39
|
siteDir: context.siteDir,
|
|
@@ -18,8 +18,8 @@ const configs_1 = require("./configs");
|
|
|
18
18
|
function getOptionValidationFunction(normalizedPluginConfig) {
|
|
19
19
|
if (normalizedPluginConfig.pluginModule) {
|
|
20
20
|
// Support both CommonJS and ES modules
|
|
21
|
-
return (normalizedPluginConfig.pluginModule.module
|
|
22
|
-
normalizedPluginConfig.pluginModule.module
|
|
21
|
+
return (normalizedPluginConfig.pluginModule.module.default?.validateOptions ??
|
|
22
|
+
normalizedPluginConfig.pluginModule.module.validateOptions);
|
|
23
23
|
}
|
|
24
24
|
return normalizedPluginConfig.plugin.validateOptions;
|
|
25
25
|
}
|
|
@@ -42,7 +42,7 @@ async function initPlugins(context) {
|
|
|
42
42
|
const pluginConfigs = await (0, configs_1.loadPluginConfigs)(context);
|
|
43
43
|
async function doGetPluginVersion(normalizedPluginConfig) {
|
|
44
44
|
if (normalizedPluginConfig.pluginModule?.path) {
|
|
45
|
-
const pluginPath = pluginRequire.resolve(normalizedPluginConfig.pluginModule
|
|
45
|
+
const pluginPath = pluginRequire.resolve(normalizedPluginConfig.pluginModule.path);
|
|
46
46
|
return (0, siteMetadata_1.getPluginVersion)(pluginPath, context.siteDir);
|
|
47
47
|
}
|
|
48
48
|
return { type: 'local' };
|
|
@@ -38,8 +38,8 @@ function sortConfig(routeConfigs, baseUrl = '/') {
|
|
|
38
38
|
}
|
|
39
39
|
// Higher priority get placed first.
|
|
40
40
|
if (a.priority || b.priority) {
|
|
41
|
-
const priorityA = a.priority
|
|
42
|
-
const priorityB = b.priority
|
|
41
|
+
const priorityA = a.priority ?? 0;
|
|
42
|
+
const priorityB = b.priority ?? 0;
|
|
43
43
|
const score = priorityB - priorityA;
|
|
44
44
|
if (score !== 0) {
|
|
45
45
|
return score;
|
|
@@ -74,7 +74,7 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
|
74
74
|
// processed by content plugins mdx loaders. This works, but a bit
|
|
75
75
|
// hacky... Not sure there's a way to handle that differently in webpack
|
|
76
76
|
function getMDXFallbackExcludedPaths() {
|
|
77
|
-
const rules = config
|
|
77
|
+
const rules = config.module?.rules;
|
|
78
78
|
return rules.flatMap((rule) => {
|
|
79
79
|
const isMDXRule = rule.test instanceof RegExp && rule.test.test('x.mdx');
|
|
80
80
|
return isMDXRule ? rule.include : [];
|
|
@@ -99,7 +99,7 @@ async function extractSourceCodeFileTranslations(sourceCodeFilePath, babelOption
|
|
|
99
99
|
// See https://twitter.com/NicoloRibaudo/status/1321130735605002243
|
|
100
100
|
filename: sourceCodeFilePath,
|
|
101
101
|
});
|
|
102
|
-
const translations =
|
|
102
|
+
const translations = extractSourceCodeAstTranslations(ast, sourceCodeFilePath);
|
|
103
103
|
return translations;
|
|
104
104
|
}
|
|
105
105
|
catch (err) {
|
|
@@ -157,9 +157,7 @@ Full code: ${(0, generator_1.default)(node).code}`;
|
|
|
157
157
|
const attributePath = path
|
|
158
158
|
.get('openingElement.attributes')
|
|
159
159
|
.find((attr) => attr.isJSXAttribute() &&
|
|
160
|
-
attr
|
|
161
|
-
.get('name')
|
|
162
|
-
.isJSXIdentifier({ name: propName }));
|
|
160
|
+
attr.get('name').isJSXIdentifier({ name: propName }));
|
|
163
161
|
if (attributePath) {
|
|
164
162
|
const attributeValue = attributePath.get('value');
|
|
165
163
|
const attributeValueEvaluated = attributeValue.isJSXExpressionContainer()
|
package/lib/webpack/base.js
CHANGED
|
@@ -27,7 +27,7 @@ function excludeJS(modulePath) {
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
// Don't transpile node_modules except any docusaurus npm package
|
|
30
|
-
return (
|
|
30
|
+
return (modulePath.includes('node_modules') &&
|
|
31
31
|
!/docusaurus(?:(?!node_modules).)*\.jsx?$/.test(modulePath) &&
|
|
32
32
|
!LibrariesToTranspileRegex.test(modulePath));
|
|
33
33
|
}
|
|
@@ -62,7 +62,7 @@ class CleanWebpackPlugin {
|
|
|
62
62
|
this.removeFiles = this.removeFiles.bind(this);
|
|
63
63
|
}
|
|
64
64
|
apply(compiler) {
|
|
65
|
-
if (!compiler.options.output
|
|
65
|
+
if (!compiler.options.output.path) {
|
|
66
66
|
console.warn('clean-webpack-plugin: options.output.path not defined. Plugin disabled...');
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
@@ -115,7 +115,7 @@ class CleanWebpackPlugin {
|
|
|
115
115
|
*
|
|
116
116
|
* (relies on del's cwd: outputPath option)
|
|
117
117
|
*/
|
|
118
|
-
const staleFiles = this.currentAssets.filter((previousAsset) => assets.includes(previousAsset)
|
|
118
|
+
const staleFiles = this.currentAssets.filter((previousAsset) => !assets.includes(previousAsset));
|
|
119
119
|
/**
|
|
120
120
|
* Save assets for next compilation
|
|
121
121
|
*/
|
|
@@ -124,7 +124,7 @@ class CleanWebpackPlugin {
|
|
|
124
124
|
/**
|
|
125
125
|
* Remove unused webpack assets
|
|
126
126
|
*/
|
|
127
|
-
if (this.cleanStaleWebpackAssets
|
|
127
|
+
if (this.cleanStaleWebpackAssets && staleFiles.length !== 0) {
|
|
128
128
|
removePatterns.push(...staleFiles);
|
|
129
129
|
}
|
|
130
130
|
if (removePatterns.length !== 0) {
|
|
@@ -157,7 +157,7 @@ class CleanWebpackPlugin {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
catch (err) {
|
|
160
|
-
const needsForce =
|
|
160
|
+
const needsForce = err.message.includes('Cannot delete files/folders outside the current working directory.');
|
|
161
161
|
if (needsForce) {
|
|
162
162
|
const message = 'clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the "dangerouslyAllowCleanPatternsOutsideProject" option.';
|
|
163
163
|
throw new Error(message);
|
package/lib/webpack/utils.js
CHANGED
|
@@ -131,13 +131,11 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
|
|
|
131
131
|
};
|
|
132
132
|
if (typeof configureWebpack === 'function') {
|
|
133
133
|
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content) ?? {};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
})(config, res);
|
|
140
|
-
}
|
|
134
|
+
const customizeRules = mergeStrategy ?? {};
|
|
135
|
+
return (0, webpack_merge_1.mergeWithCustomize)({
|
|
136
|
+
customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
|
|
137
|
+
customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
|
|
138
|
+
})(config, res);
|
|
141
139
|
}
|
|
142
140
|
return config;
|
|
143
141
|
}
|
|
@@ -170,7 +168,7 @@ function compile(config) {
|
|
|
170
168
|
const compiler = (0, webpack_1.default)(config);
|
|
171
169
|
compiler.run((err, stats) => {
|
|
172
170
|
if (err) {
|
|
173
|
-
logger_1.default.error(err.stack
|
|
171
|
+
logger_1.default.error(err.stack ?? err);
|
|
174
172
|
if (err.details) {
|
|
175
173
|
logger_1.default.error(err.details);
|
|
176
174
|
}
|
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-5047",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.18.0",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.18.0",
|
|
45
45
|
"@babel/traverse": "^7.18.0",
|
|
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-5047",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5047",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5047",
|
|
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-5047",
|
|
51
|
+
"@docusaurus/utils-common": "0.0.0-5047",
|
|
52
|
+
"@docusaurus/utils-validation": "0.0.0-5047",
|
|
53
53
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.4",
|
|
54
54
|
"@svgr/webpack": "^6.2.1",
|
|
55
55
|
"autoprefixer": "^10.4.7",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"webpackbar": "^5.0.2"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
111
|
-
"@docusaurus/types": "0.0.0-
|
|
110
|
+
"@docusaurus/module-type-aliases": "0.0.0-5047",
|
|
111
|
+
"@docusaurus/types": "0.0.0-5047",
|
|
112
112
|
"@types/detect-port": "^1.3.2",
|
|
113
113
|
"@types/react-dom": "^18.0.4",
|
|
114
114
|
"@types/react-router-config": "^5.0.6",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "67ac297469d98ac3eb8482d8636aee4648586f33"
|
|
132
132
|
}
|