fix(v2): use lodash instead of array-map-polyfill (#2490)

This commit is contained in:
Alexey Pyltsyn 2020-04-01 20:08:22 +03:00 committed by GitHub
parent 1577ab98e9
commit 686c8ae27d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 12 deletions

View file

@ -27,5 +27,5 @@ module.exports = {
transform: {
'^.+\\.[jt]sx?$': 'babel-jest',
},
setupFiles: ['./jest/stylelint-rule-test.js', 'array-flat-polyfill'],
setupFiles: ['./jest/stylelint-rule-test.js'],
};

View file

@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import _ from 'lodash';
import fs from 'fs-extra';
import importFresh from 'import-fresh';
import {
@ -105,12 +106,12 @@ function normalizeItem(item: SidebarItemRaw): SidebarItem[] {
];
}
if (isCategoryShorthand(item)) {
return normalizeCategoryShorthand(item).flatMap(normalizeItem);
return _.flatMap(normalizeCategoryShorthand(item), normalizeItem);
}
switch (item.type) {
case 'category':
assertIsCategory(item);
return [{...item, items: item.items.flatMap(normalizeItem)}];
return [{...item, items: _.flatMap(item.items, normalizeItem)}];
case 'link':
assertIsLink(item);
return [item];
@ -133,7 +134,7 @@ function normalizeSidebar(sidebars: SidebarRaw): Sidebar {
? sidebar
: normalizeCategoryShorthand(sidebar);
acc[sidebarId] = normalizedSidebar.flatMap(normalizeItem);
acc[sidebarId] = _.flatMap(normalizedSidebar, normalizeItem);
return acc;
},

View file

@ -41,7 +41,6 @@
"@babel/runtime": "^7.7.4",
"@docusaurus/utils": "^2.0.0-alpha.49",
"@endiliey/static-site-generator-webpack-plugin": "^4.0.0",
"array-flat-polyfill": "^1.0.1",
"babel-loader": "^8.0.6",
"babel-plugin-dynamic-import-node": "^2.3.0",
"cache-loader": "^4.1.0",

View file

@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
import 'array-flat-polyfill';
export {build} from './commands/build';
export {start} from './commands/start';
export {swizzle} from './commands/swizzle';

View file

@ -3196,11 +3196,6 @@ array-find-index@^1.0.1:
resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1"
integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=
array-flat-polyfill@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/array-flat-polyfill/-/array-flat-polyfill-1.0.1.tgz#1e3a4255be619dfbffbfd1d635c1cf357cd034e7"
integrity sha512-hfJmKupmQN0lwi0xG6FQ5U8Rd97RnIERplymOv/qpq8AoNKPPAnxJadjFA23FNWm88wykh9HmpLJUUwUtNU/iw==
array-flatten@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"