@docusaurus/core 0.0.0-4203 → 0.0.0-4207
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/.tsbuildinfo +1 -1
- package/lib/choosePort.js +1 -2
- package/lib/client/.tsbuildinfo +1 -1
- package/lib/client/LinksCollector.d.ts +2 -2
- package/lib/client/LinksCollector.js +4 -8
- package/lib/client/docusaurus.js +6 -8
- package/lib/client/exports/Interpolate.js +7 -14
- package/lib/client/exports/useBaseUrl.js +1 -3
- package/lib/client/serverEntry.js +4 -4
- package/lib/client/theme-fallback/Layout/index.js +1 -1
- package/lib/client/theme-fallback/Loading/index.js +2 -2
- package/lib/client/theme-fallback/Root/index.js +1 -3
- package/lib/server/brokenLinks.js +2 -6
- package/lib/server/configValidation.js +2 -2
- package/lib/server/i18n.js +1 -5
- package/lib/server/plugins/index.js +4 -6
- package/lib/server/themes/alias.js +1 -3
- package/lib/server/translations/translations.js +3 -5
- package/lib/server/translations/translationsExtractor.js +1 -3
- package/lib/webpack/plugins/CleanWebpackPlugin.js +2 -6
- package/lib/webpack/utils.js +57 -71
- package/package.json +8 -8
|
@@ -83,12 +83,10 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
83
83
|
}));
|
|
84
84
|
const allContent = (0, lodash_1.chain)(loadedPlugins)
|
|
85
85
|
.groupBy((item) => item.name)
|
|
86
|
-
.mapValues((nameItems) =>
|
|
87
|
-
return (0
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.value();
|
|
91
|
-
})
|
|
86
|
+
.mapValues((nameItems) => (0, lodash_1.chain)(nameItems)
|
|
87
|
+
.groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID; })
|
|
88
|
+
.mapValues((idItems) => idItems[0].content)
|
|
89
|
+
.value())
|
|
92
90
|
.value();
|
|
93
91
|
// 3. Plugin Lifecycle - contentLoaded.
|
|
94
92
|
const pluginsRouteConfigs = [];
|
|
@@ -20,9 +20,7 @@ function sortAliases(aliases) {
|
|
|
20
20
|
// Alphabetical order by default
|
|
21
21
|
const entries = (0, lodash_1.sortBy)(Object.entries(aliases), ([alias]) => alias);
|
|
22
22
|
// @theme/NavbarItem should be after @theme/NavbarItem/LocaleDropdown
|
|
23
|
-
entries.sort(([alias1], [alias2]) => {
|
|
24
|
-
return alias1.includes(`${alias2}/`) ? -1 : 0;
|
|
25
|
-
});
|
|
23
|
+
entries.sort(([alias1], [alias2]) => alias1.includes(`${alias2}/`) ? -1 : 0);
|
|
26
24
|
return Object.fromEntries(entries);
|
|
27
25
|
}
|
|
28
26
|
exports.sortAliases = sortAliases;
|
|
@@ -172,9 +172,7 @@ async function localizePluginTranslationFile({ siteDir, plugin, locale, translat
|
|
|
172
172
|
exports.localizePluginTranslationFile = localizePluginTranslationFile;
|
|
173
173
|
async function getPluginsDefaultCodeTranslationMessages(plugins) {
|
|
174
174
|
const pluginsMessages = await Promise.all(plugins.map((plugin) => { var _a, _b; return (_b = (_a = plugin.getDefaultCodeTranslationMessages) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : {}; }));
|
|
175
|
-
return pluginsMessages.reduce((allMessages, pluginMessages) => {
|
|
176
|
-
return { ...allMessages, ...pluginMessages };
|
|
177
|
-
}, {});
|
|
175
|
+
return pluginsMessages.reduce((allMessages, pluginMessages) => ({ ...allMessages, ...pluginMessages }), {});
|
|
178
176
|
}
|
|
179
177
|
exports.getPluginsDefaultCodeTranslationMessages = getPluginsDefaultCodeTranslationMessages;
|
|
180
178
|
function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }) {
|
|
@@ -187,10 +185,10 @@ Please report this Docusaurus issue.
|
|
|
187
185
|
}
|
|
188
186
|
return (0, lodash_1.mapValues)(extractedCodeTranslations, (messageTranslation, messageId) => {
|
|
189
187
|
var _a;
|
|
190
|
-
return {
|
|
188
|
+
return ({
|
|
191
189
|
...messageTranslation,
|
|
192
190
|
message: (_a = defaultCodeMessages[messageId]) !== null && _a !== void 0 ? _a : messageTranslation.message,
|
|
193
|
-
};
|
|
191
|
+
});
|
|
194
192
|
});
|
|
195
193
|
}
|
|
196
194
|
exports.applyDefaultCodeTranslations = applyDefaultCodeTranslations;
|
|
@@ -63,9 +63,7 @@ async function getSourceCodeFilePaths(siteDir, plugins) {
|
|
|
63
63
|
async function extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions, extraSourceCodeFilePaths = []) {
|
|
64
64
|
// Should we warn here if the same translation "key" is found in multiple source code files?
|
|
65
65
|
function toTranslationFileContent(sourceCodeFileTranslations) {
|
|
66
|
-
return sourceCodeFileTranslations.reduce((acc, item) => {
|
|
67
|
-
return { ...acc, ...item.translations };
|
|
68
|
-
}, {});
|
|
66
|
+
return sourceCodeFileTranslations.reduce((acc, item) => ({ ...acc, ...item.translations }), {});
|
|
69
67
|
}
|
|
70
68
|
const sourceCodeFilePaths = await getSourceCodeFilePaths(siteDir, plugins);
|
|
71
69
|
const allSourceCodeFilePaths = [
|
|
@@ -86,17 +86,13 @@ class CleanWebpackPlugin {
|
|
|
86
86
|
all: false,
|
|
87
87
|
assets: true,
|
|
88
88
|
}).assets || [];
|
|
89
|
-
const assets = statsAssets.map((asset) =>
|
|
90
|
-
return asset.name;
|
|
91
|
-
});
|
|
89
|
+
const assets = statsAssets.map((asset) => asset.name);
|
|
92
90
|
/**
|
|
93
91
|
* Get all files that were in the previous build but not the current
|
|
94
92
|
*
|
|
95
93
|
* (relies on del's cwd: outputPath option)
|
|
96
94
|
*/
|
|
97
|
-
const staleFiles = this.currentAssets.filter((previousAsset) =>
|
|
98
|
-
return assets.includes(previousAsset) === false;
|
|
99
|
-
});
|
|
95
|
+
const staleFiles = this.currentAssets.filter((previousAsset) => assets.includes(previousAsset) === false);
|
|
100
96
|
/**
|
|
101
97
|
* Save assets for next compilation
|
|
102
98
|
*/
|
package/lib/webpack/utils.js
CHANGED
|
@@ -112,7 +112,7 @@ const getCustomizableJSLoader = (jsLoader = 'babel') => ({ isServer, babelOption
|
|
|
112
112
|
: jsLoader(isServer);
|
|
113
113
|
exports.getCustomizableJSLoader = getCustomizableJSLoader;
|
|
114
114
|
// TODO remove this before end of 2021?
|
|
115
|
-
const warnBabelLoaderOnce = (0, lodash_1.memoize)(
|
|
115
|
+
const warnBabelLoaderOnce = (0, lodash_1.memoize)(() => {
|
|
116
116
|
console.warn(chalk_1.default.yellow('Docusaurus plans to support multiple JS loader strategies (Babel, esbuild...): "getBabelLoader(isServer)" is now deprecated in favor of "getJSLoader({isServer})".'));
|
|
117
117
|
});
|
|
118
118
|
const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, babelOptions) {
|
|
@@ -120,7 +120,7 @@ const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, bab
|
|
|
120
120
|
return getDefaultBabelLoader({ isServer, babelOptions });
|
|
121
121
|
};
|
|
122
122
|
// TODO remove this before end of 2021 ?
|
|
123
|
-
const warnCacheLoaderOnce = (0, lodash_1.memoize)(
|
|
123
|
+
const warnCacheLoaderOnce = (0, lodash_1.memoize)(() => {
|
|
124
124
|
console.warn(chalk_1.default.yellow('Docusaurus uses Webpack 5 and getCacheLoader() usage is now deprecated.'));
|
|
125
125
|
});
|
|
126
126
|
function getCacheLoaderDeprecated() {
|
|
@@ -228,24 +228,20 @@ function getFileLoaderUtils() {
|
|
|
228
228
|
// defines the path/pattern of the assets handled by webpack
|
|
229
229
|
const fileLoaderFileName = (folder) => `${constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME}/${folder}/[name]-[hash].[ext]`;
|
|
230
230
|
const loaders = {
|
|
231
|
-
file: (options) => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
fallback: require.resolve(`file-loader`),
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
},
|
|
231
|
+
file: (options) => ({
|
|
232
|
+
loader: require.resolve(`file-loader`),
|
|
233
|
+
options: {
|
|
234
|
+
name: fileLoaderFileName(options.folder),
|
|
235
|
+
},
|
|
236
|
+
}),
|
|
237
|
+
url: (options) => ({
|
|
238
|
+
loader: require.resolve(`url-loader`),
|
|
239
|
+
options: {
|
|
240
|
+
limit: urlLoaderLimit,
|
|
241
|
+
name: fileLoaderFileName(options.folder),
|
|
242
|
+
fallback: require.resolve(`file-loader`),
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
249
245
|
// TODO find a better solution to avoid conflicts with the ideal-image plugin
|
|
250
246
|
// TODO this may require a little breaking change for ideal-image users?
|
|
251
247
|
// Maybe with the ideal image plugin, all md images should be "ideal"?
|
|
@@ -259,65 +255,55 @@ function getFileLoaderUtils() {
|
|
|
259
255
|
* Loads image assets, inlines images via a data URI if they are below
|
|
260
256
|
* the size threshold
|
|
261
257
|
*/
|
|
262
|
-
images: () => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
use: [loaders.url({ folder: 'fonts' })],
|
|
271
|
-
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
272
|
-
};
|
|
273
|
-
},
|
|
258
|
+
images: () => ({
|
|
259
|
+
use: [loaders.url({ folder: 'images' })],
|
|
260
|
+
test: /\.(ico|jpg|jpeg|png|gif|webp)(\?.*)?$/,
|
|
261
|
+
}),
|
|
262
|
+
fonts: () => ({
|
|
263
|
+
use: [loaders.url({ folder: 'fonts' })],
|
|
264
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
265
|
+
}),
|
|
274
266
|
/**
|
|
275
267
|
* Loads audio and video and inlines them via a data URI if they are below
|
|
276
268
|
* the size threshold
|
|
277
269
|
*/
|
|
278
|
-
media: () => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
svgo: true,
|
|
295
|
-
svgoConfig: {
|
|
296
|
-
plugins: [{ removeViewBox: false }],
|
|
297
|
-
},
|
|
298
|
-
titleProp: true,
|
|
299
|
-
ref: ![path_1.default],
|
|
270
|
+
media: () => ({
|
|
271
|
+
use: [loaders.url({ folder: 'medias' })],
|
|
272
|
+
test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/,
|
|
273
|
+
}),
|
|
274
|
+
svg: () => ({
|
|
275
|
+
test: /\.svg?$/,
|
|
276
|
+
oneOf: [
|
|
277
|
+
{
|
|
278
|
+
use: [
|
|
279
|
+
{
|
|
280
|
+
loader: '@svgr/webpack',
|
|
281
|
+
options: {
|
|
282
|
+
prettier: false,
|
|
283
|
+
svgo: true,
|
|
284
|
+
svgoConfig: {
|
|
285
|
+
plugins: [{ removeViewBox: false }],
|
|
300
286
|
},
|
|
287
|
+
titleProp: true,
|
|
288
|
+
ref: ![path_1.default],
|
|
301
289
|
},
|
|
302
|
-
],
|
|
303
|
-
// We don't want to use SVGR loader for non-React source code
|
|
304
|
-
// ie we don't want to use SVGR for CSS files...
|
|
305
|
-
issuer: {
|
|
306
|
-
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
|
307
290
|
},
|
|
291
|
+
],
|
|
292
|
+
// We don't want to use SVGR loader for non-React source code
|
|
293
|
+
// ie we don't want to use SVGR for CSS files...
|
|
294
|
+
issuer: {
|
|
295
|
+
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
|
308
296
|
},
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
},
|
|
315
|
-
otherAssets: () => {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
};
|
|
320
|
-
},
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
use: [loaders.url({ folder: 'images' })],
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
}),
|
|
303
|
+
otherAssets: () => ({
|
|
304
|
+
use: [loaders.file({ folder: 'files' })],
|
|
305
|
+
test: /\.(pdf|doc|docx|xls|xlsx|zip|rar)$/,
|
|
306
|
+
}),
|
|
321
307
|
};
|
|
322
308
|
return { loaders, rules };
|
|
323
309
|
}
|
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-4207",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
34
|
+
"@docusaurus/module-type-aliases": "0.0.0-4207",
|
|
35
35
|
"@types/copy-webpack-plugin": "^8.0.1",
|
|
36
36
|
"@types/css-minimizer-webpack-plugin": "^3.0.2",
|
|
37
37
|
"@types/detect-port": "^1.3.0",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"@babel/runtime": "^7.15.4",
|
|
55
55
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
56
56
|
"@babel/traverse": "^7.12.13",
|
|
57
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
57
|
+
"@docusaurus/cssnano-preset": "0.0.0-4207",
|
|
58
58
|
"@docusaurus/react-loadable": "5.5.2",
|
|
59
|
-
"@docusaurus/types": "0.0.0-
|
|
60
|
-
"@docusaurus/utils": "0.0.0-
|
|
61
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
62
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
59
|
+
"@docusaurus/types": "0.0.0-4207",
|
|
60
|
+
"@docusaurus/utils": "0.0.0-4207",
|
|
61
|
+
"@docusaurus/utils-common": "0.0.0-4207",
|
|
62
|
+
"@docusaurus/utils-validation": "0.0.0-4207",
|
|
63
63
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.0",
|
|
64
64
|
"@svgr/webpack": "^5.5.0",
|
|
65
65
|
"autoprefixer": "^10.3.5",
|
|
@@ -129,5 +129,5 @@
|
|
|
129
129
|
"engines": {
|
|
130
130
|
"node": ">=14"
|
|
131
131
|
},
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "63059ec789f63c76514839ed417d2ef58456666e"
|
|
133
133
|
}
|