Skip to content

Commit

Permalink
refactor(v2): remove duplicated lodash dependencies and import only w…
Browse files Browse the repository at this point in the history
…hat needed (#4361)

Co-authored-by: slorber <lorber.sebastien@gmail.com>
  • Loading branch information
armano2 and slorber committed Mar 9, 2021
1 parent bac512b commit e6261af
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 142 deletions.
11 changes: 1 addition & 10 deletions package.json
Expand Up @@ -75,16 +75,7 @@
"@types/fs-extra": "^9.0.6",
"@types/jest": "^26.0.20",
"@types/loader-utils": "^1.1.3",
"@types/lodash.camelcase": "^4.3.6",
"@types/lodash.flatmap": "^4.5.6",
"@types/lodash.groupby": "^4.6.6",
"@types/lodash.has": "^4.5.6",
"@types/lodash.isplainobject": "^4.0.6",
"@types/lodash.isstring": "^4.0.6",
"@types/lodash.kebabcase": "^4.1.6",
"@types/lodash.pick": "^4.4.6",
"@types/lodash.pickby": "^4.6.6",
"@types/lodash.sortby": "^4.6.6",
"@types/lodash": "^4.14.168",
"@types/node": "^14.14.22",
"@types/prismjs": "^1.16.2",
"@types/prompts": "^2.0.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-init/package.json
Expand Up @@ -25,7 +25,7 @@
"chalk": "^4.1.0",
"commander": "^5.1.0",
"fs-extra": "^9.1.0",
"lodash.kebabcase": "^4.1.1",
"lodash": "^4.17.20",
"prompts": "^2.4.0",
"semver": "^7.3.4",
"shelljs": "^0.8.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-init/src/index.ts
Expand Up @@ -11,7 +11,7 @@ import {execSync} from 'child_process';
import prompts, {Choice} from 'prompts';
import path from 'path';
import shell from 'shelljs';
import kebabCase from 'lodash.kebabcase';
import {kebabCase} from 'lodash';

function hasYarn(): boolean {
try {
Expand Down
7 changes: 1 addition & 6 deletions packages/docusaurus-plugin-content-docs/package.json
Expand Up @@ -36,12 +36,7 @@
"import-fresh": "^3.2.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3",
"lodash": "^4.17.19",
"lodash.flatmap": "^4.5.0",
"lodash.groupby": "^4.6.0",
"lodash.pick": "^4.4.0",
"lodash.pickby": "^4.6.0",
"lodash.sortby": "^4.6.0",
"lodash": "^4.17.20",
"remark-admonitions": "^1.2.1",
"shelljs": "^0.8.4",
"utility-types": "^3.10.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/docusaurus-plugin-content-docs/src/sidebars.ts
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import flatMap from 'lodash.flatmap';
import fs from 'fs-extra';
import importFresh from 'import-fresh';
import {
Expand All @@ -18,7 +17,7 @@ import {
SidebarItemCategory,
SidebarItemType,
} from './types';
import {mapValues, flatten, difference} from 'lodash';
import {mapValues, flatten, flatMap, difference} from 'lodash';
import {getElementsAround} from '@docusaurus/utils';

type SidebarItemCategoryJSON = SidebarItemBase & {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-pages/package.json
Expand Up @@ -26,7 +26,7 @@
"globby": "^11.0.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3",
"lodash": "^4.17.19",
"lodash": "^4.17.20",
"minimatch": "^3.0.4",
"remark-admonitions": "^1.2.1",
"slash": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/package.json
Expand Up @@ -38,7 +38,7 @@
"copy-text-to-clipboard": "^3.0.0",
"infima": "0.2.0-alpha.19",
"joi": "^17.4.0",
"lodash": "^4.17.19",
"lodash": "^4.17.20",
"parse-numeric-range": "^1.2.0",
"postcss": "^7.0.2",
"prism-react-renderer": "^1.1.1",
Expand Down
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import merge from 'lodash/merge';
import {merge} from 'lodash';

const {ThemeConfigSchema, DEFAULT_CONFIG} = require('../validateThemeConfig');

Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-search-algolia/package.json
Expand Up @@ -22,7 +22,7 @@
"clsx": "^1.1.1",
"eta": "^1.12.1",
"joi": "^17.4.0",
"lodash": "^4.17.19"
"lodash": "^4.17.20"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/docusaurus-utils/package.json
Expand Up @@ -27,8 +27,6 @@
"intl": "^1.2.5",
"intl-locales-supported": "^1.8.12",
"lodash": "^4.17.20",
"lodash.camelcase": "^4.3.0",
"lodash.kebabcase": "^4.1.1",
"resolve-pathname": "^3.0.0"
},
"engines": {
Expand Down
4 changes: 1 addition & 3 deletions packages/docusaurus-utils/src/index.ts
Expand Up @@ -9,8 +9,7 @@ import chalk from 'chalk';
import path from 'path';
import matter from 'gray-matter';
import {createHash} from 'crypto';
import camelCase from 'lodash.camelcase';
import kebabCase from 'lodash.kebabcase';
import {camelCase, kebabCase, mapValues} from 'lodash';
import escapeStringRegexp from 'escape-string-regexp';
import fs from 'fs-extra';
import {URL} from 'url';
Expand All @@ -22,7 +21,6 @@ import {

// @ts-expect-error: no typedefs :s
import resolvePathnameUnsafe from 'resolve-pathname';
import {mapValues} from 'lodash';
import areIntlLocalesSupported from 'intl-locales-supported';

const fileHash = new Map();
Expand Down
4 changes: 0 additions & 4 deletions packages/docusaurus/package.json
Expand Up @@ -84,10 +84,6 @@
"joi": "^17.4.0",
"leven": "^3.1.0",
"lodash": "^4.17.20",
"lodash.flatmap": "^4.5.0",
"lodash.has": "^4.5.2",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"mini-css-extract-plugin": "^0.8.0",
"module-alias": "^2.2.2",
"nprogress": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/commands/start.ts
Expand Up @@ -11,7 +11,7 @@ import chokidar from 'chokidar';
import express from 'express';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import path from 'path';
import debounce from 'lodash/debounce';
import {debounce} from 'lodash';
import openBrowser from 'react-dev-utils/openBrowser';
import {prepareUrls} from 'react-dev-utils/WebpackDevServerUtils';
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/html-tags/htmlTags.ts
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import isPlainObject from 'lodash.isplainobject';
import {isPlainObject} from 'lodash';
import {HtmlTagObject} from '@docusaurus/types';
import htmlTags from 'html-tags';
import voidHtmlTags from 'html-tags/void';
Expand Down
4 changes: 1 addition & 3 deletions packages/docusaurus/src/server/routes.ts
Expand Up @@ -11,9 +11,7 @@ import {
removeSuffix,
simpleHash,
} from '@docusaurus/utils';
import has from 'lodash.has';
import isPlainObject from 'lodash.isplainobject';
import isString from 'lodash.isstring';
import {has, isPlainObject, isString} from 'lodash';
import {stringify} from 'querystring';
import {
ChunkRegistry,
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/utils.ts
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import flatMap from 'lodash.flatmap';
import {flatMap} from 'lodash';
import {RouteConfig} from '@docusaurus/types';

// Recursively get the final routes (routes with no subroutes)
Expand Down
2 changes: 1 addition & 1 deletion packages/lqip-loader/package.json
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"file-loader": "^6.2.0",
"loader-utils": "^1.2.3",
"lodash.sortby": "^4.7.0",
"lodash": "^4.17.20",
"node-vibrant": "^3.1.5",
"sharp": "^0.27.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/lqip-loader/src/utils.js
Expand Up @@ -7,7 +7,7 @@

// @ts-check

const sortBy = require('lodash.sortby');
const {sortBy} = require('lodash');

/**
* toBase64
Expand Down
107 changes: 6 additions & 101 deletions yarn.lock
Expand Up @@ -3466,77 +3466,12 @@
"@types/node" "*"
"@types/webpack" "*"

"@types/lodash.camelcase@^4.3.6":
version "4.3.6"
resolved "https://registry.yarnpkg.com/@types/lodash.camelcase/-/lodash.camelcase-4.3.6.tgz#393c748b70cd926fc629e6502a9d0929f217d5fd"
integrity sha512-hd/TEuPd76Jtf1xEq85CHbCqR+iqvs5IOKyrYbiaOg69BRQgPN9XkvLj8Jl8rBp/dfJ2wQ1AVcP8mZmybq7kIg==
dependencies:
"@types/lodash" "*"

"@types/lodash.flatmap@^4.5.6":
version "4.5.6"
resolved "https://registry.yarnpkg.com/@types/lodash.flatmap/-/lodash.flatmap-4.5.6.tgz#5f1ea80cebe403f0fbfcc1b5ad75cd09dd8b5785"
integrity sha512-ELNrUL9q+MB7AACaHivWIsKDFDgYhHE3/svXhqvDJgONtn2c467Cy87nEb7CEDvfaGCPv91lPaW596I8s5oiNQ==
dependencies:
"@types/lodash" "*"

"@types/lodash.groupby@^4.6.6":
version "4.6.6"
resolved "https://registry.yarnpkg.com/@types/lodash.groupby/-/lodash.groupby-4.6.6.tgz#4d9b61a4d8b0d83d384975cabfed4c1769d6792e"
integrity sha512-kwg3T7Ia63KtDNoQQR8hKrLHCAgrH4I44l5uEMuA6JCbj7DiSccaV4tNV1vbjtAOpX990SolVthJCmBVtRVRgw==
dependencies:
"@types/lodash" "*"

"@types/lodash.has@^4.5.6":
version "4.5.6"
resolved "https://registry.yarnpkg.com/@types/lodash.has/-/lodash.has-4.5.6.tgz#d94d3f0b45ced2ae76d632080daf70e9b76e29eb"
integrity sha512-SpUCvze0uHilQX/mt4K/cak5OQny1pVfz3pJx6H70dE3Tvw9s7EtlMK+vY6UBS+PQgETDfv6vhwoa3FPS2wrhg==
dependencies:
"@types/lodash" "*"

"@types/lodash.isplainobject@^4.0.6":
version "4.0.6"
resolved "https://registry.yarnpkg.com/@types/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#757d2dcdecbb32f4452018b285a586776092efd1"
integrity sha512-8G41YFhmOl8Ck6NrwLK5hhnbz6ADfuDJP+zusDnX3PoYhfC60+H/rQE6zmdO4yFzPCPJPY4oGZK2spbXm6gYEA==
dependencies:
"@types/lodash" "*"

"@types/lodash.isstring@^4.0.6":
version "4.0.6"
resolved "https://registry.yarnpkg.com/@types/lodash.isstring/-/lodash.isstring-4.0.6.tgz#1534d0c19a2ad79caa17558a298e366893ffd08c"
integrity sha512-uUGvF9G1G7jQ5H42Y38GA9rZmUoY8wI/OMSwnW0BZA+Ra0uxzpuQf4CixXl3yG3TvF6LjuduMyt1WvKl+je8QA==
dependencies:
"@types/lodash" "*"
"@types/lodash@^4.14.168":
version "4.14.168"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008"
integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q==

"@types/lodash.kebabcase@^4.1.6":
version "4.1.6"
resolved "https://registry.yarnpkg.com/@types/lodash.kebabcase/-/lodash.kebabcase-4.1.6.tgz#07b07aeca6c0647836de46f87a3cdfff72166c8e"
integrity sha512-+RAD9pCAa8kuVyCYTeDNiwBXwD/0u0p+hos3NSqD+tXTjJextbfF3farfYB+ssAKgEssoewXEtBsfwBpsI7gsA==
dependencies:
"@types/lodash" "*"

"@types/lodash.pick@^4.4.6":
version "4.4.6"
resolved "https://registry.yarnpkg.com/@types/lodash.pick/-/lodash.pick-4.4.6.tgz#ae4e8f109e982786313bb6aac4b1a73aefa6e9be"
integrity sha512-u8bzA16qQ+8dY280z3aK7PoWb3fzX5ATJ0rJB6F+uqchOX2VYF02Aqa+8aYiHiHgPzQiITqCgeimlyKFy4OA6g==
dependencies:
"@types/lodash" "*"

"@types/lodash.pickby@^4.6.6":
version "4.6.6"
resolved "https://registry.yarnpkg.com/@types/lodash.pickby/-/lodash.pickby-4.6.6.tgz#3dc39c2b38432f7a0c5e5627b0d5c0e3878b4f35"
integrity sha512-NFa13XxlMd9eFi0UFZFWIztpMpXhozbijrx3Yb1viYZphT7jyopIFVoIRF4eYMjruWNEG1rnyrRmg/8ej9T8Iw==
dependencies:
"@types/lodash" "*"

"@types/lodash.sortby@^4.6.6":
version "4.7.6"
resolved "https://registry.yarnpkg.com/@types/lodash.sortby/-/lodash.sortby-4.7.6.tgz#eed689835f274b553db4ae16a4a23f58b79618a1"
integrity sha512-EnvAOmKvEg7gdYpYrS6+fVFPw5dL9rBnJi3vcKI7wqWQcLJVF/KRXK9dH29HjGNVvFUj0s9prRP3J8jEGnGKDw==
dependencies:
"@types/lodash" "*"

"@types/lodash@*", "@types/lodash@^4.14.53":
"@types/lodash@^4.14.53":
version "4.14.149"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.149.tgz#1342d63d948c6062838fbf961012f74d4e638440"
integrity sha512-ijGqzZt/b7BfzcK9vTrS6MFljQRPn5BFWOx8oE0GYxribu6uV+aA9zZuXI1zc/etK9E8nrgdoF2+LgUw7+9tJQ==
Expand Down Expand Up @@ -12775,11 +12710,6 @@ lodash.filter@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace"
integrity sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4=

lodash.flatmap@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz#ef8cbf408f6e48268663345305c6acc0b778702e"
integrity sha1-74y/QI9uSCaGYzRTBcaswLd4cC4=

lodash.flatten@^4.2.0, lodash.flatten@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
Expand All @@ -12805,16 +12735,6 @@ lodash.get@^4.4.2:
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=

lodash.groupby@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.groupby/-/lodash.groupby-4.6.0.tgz#0b08a1dcf68397c397855c3239783832df7403d1"
integrity sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E=

lodash.has@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862"
integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=

lodash.isempty@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"
Expand Down Expand Up @@ -12845,16 +12765,6 @@ lodash.isplainobject@^4.0.6:
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=

lodash.isstring@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"
integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=

lodash.kebabcase@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36"
integrity sha1-hImxyw0p/4gZXM7KRI/21swpXDY=

lodash.map@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
Expand All @@ -12880,11 +12790,6 @@ lodash.pick@^4.2.1, lodash.pick@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"
integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=

lodash.pickby@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff"
integrity sha1-feoh2MGNdwOifHBMFdO4SmfjOv8=

lodash.reduce@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b"
Expand Down Expand Up @@ -12915,7 +12820,7 @@ lodash.some@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"
integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=

lodash.sortby@^4.6.0, lodash.sortby@^4.7.0:
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
Expand Down

0 comments on commit e6261af

Please sign in to comment.