@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.
@@ -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, lodash_1.chain)(nameItems)
88
- .groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID; })
89
- .mapValues((idItems) => idItems[0].content)
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
  */
@@ -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)(function () {
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)(function () {
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
- return {
233
- loader: require.resolve(`file-loader`),
234
- options: {
235
- name: fileLoaderFileName(options.folder),
236
- },
237
- };
238
- },
239
- url: (options) => {
240
- return {
241
- loader: require.resolve(`url-loader`),
242
- options: {
243
- limit: urlLoaderLimit,
244
- name: fileLoaderFileName(options.folder),
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
- return {
264
- use: [loaders.url({ folder: 'images' })],
265
- test: /\.(ico|jpg|jpeg|png|gif|webp)(\?.*)?$/,
266
- };
267
- },
268
- fonts: () => {
269
- return {
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
- return {
280
- use: [loaders.url({ folder: 'medias' })],
281
- test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/,
282
- };
283
- },
284
- svg: () => {
285
- return {
286
- test: /\.svg?$/,
287
- oneOf: [
288
- {
289
- use: [
290
- {
291
- loader: '@svgr/webpack',
292
- options: {
293
- prettier: false,
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
- use: [loaders.url({ folder: 'images' })],
311
- },
312
- ],
313
- };
314
- },
315
- otherAssets: () => {
316
- return {
317
- use: [loaders.file({ folder: 'files' })],
318
- test: /\.(pdf|doc|docx|xls|xlsx|zip|rar)$/,
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-4203",
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-4203",
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-4203",
57
+ "@docusaurus/cssnano-preset": "0.0.0-4207",
58
58
  "@docusaurus/react-loadable": "5.5.2",
59
- "@docusaurus/types": "0.0.0-4203",
60
- "@docusaurus/utils": "0.0.0-4203",
61
- "@docusaurus/utils-common": "0.0.0-4203",
62
- "@docusaurus/utils-validation": "0.0.0-4203",
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": "c593f92915e118d87c10015d5db2c42eda4b5ef3"
132
+ "gitHead": "63059ec789f63c76514839ed417d2ef58456666e"
133
133
  }