Skip to content

Commit

Permalink
chore: replace lodash with es-toolkit
Browse files Browse the repository at this point in the history
es-toolkit is a modern lodash alternative that claims to be much faster and lighter, potentially improving Yarn overall performance: https://es-toolkit.slash.page/intro.html
  • Loading branch information
wojtekmaj authored Sep 14, 2024
1 parent fb6d2d6 commit 4809f3a
Show file tree
Hide file tree
Showing 29 changed files with 199 additions and 263 deletions.
318 changes: 119 additions & 199 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
34 changes: 34 additions & 0 deletions .yarn/versions/4251696d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
releases:
"@yarnpkg/core": patch
"@yarnpkg/plugin-constraints": patch
"@yarnpkg/plugin-essentials": patch
"@yarnpkg/plugin-git": patch
"@yarnpkg/plugin-npm": patch
"@yarnpkg/plugin-version": patch
"@yarnpkg/plugin-workspace-tools": patch
"@yarnpkg/sdks": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/builder"
- "@yarnpkg/cli"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
2 changes: 1 addition & 1 deletion packages/acceptance-tests/pkg-tests-specs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@yarnpkg/monorepo": "workspace:^",
"@yarnpkg/parsers": "workspace:^",
"@yarnpkg/pnp": "workspace:^",
"lodash": "^4.17.15",
"es-toolkit": "^1.19.0",
"pkg-tests-core": "workspace:^",
"tar": "^6.0.5",
"tslib": "^2.4.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Manifest} from '@yarnpkg/core';
import {PortablePath, ppath, xfs} from '@yarnpkg/fslib';
import {merge} from 'lodash';
import {merge} from 'es-toolkit/compat';
import {fs, yarn} from 'pkg-tests-core';

const {unpackToDirectory} = fs;
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/config/remark/commandLineHighlight.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {YarnCli, getCli} from '@yarnpkg/cli';
import {parseShell} from '@yarnpkg/parsers';
import type {Definition, Token} from 'clipanion';
import {capitalize} from 'es-toolkit/compat';
import {fromJs} from 'esast-util-from-js';
import {capitalize} from 'lodash';
import type {MdxJsxFlowElement} from 'mdast-util-mdx-jsx';
import type {Parent, Root} from 'mdast';
import type {Transformer} from 'unified';
Expand Down
3 changes: 1 addition & 2 deletions packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
"clsx": "^1.2.1",
"docusaurus-plugin-typedoc-api": "patch:docusaurus-plugin-typedoc-api@npm%3A4.2.0#~/.yarn/patches/docusaurus-plugin-typedoc-api-npm-4.2.0-fb78ec678c.patch",
"dompurify": "^3.0.5",
"es-toolkit": "^1.19.0",
"esast-util-from-js": "^2.0.1",
"esbuild-loader": "^2.20.0",
"fast-glob": "^3.2.2",
"git-url-parse": "^13.1.0",
"github-markdown-css": "^5.1.0",
"jiti": "^1.21.0",
"lodash": "^4.17.15",
"markdown-it": "^13.0.1",
"markdown-it-br": "^1.0.0",
"marked": "^5.1.1",
Expand Down Expand Up @@ -83,7 +83,6 @@
"@docusaurus/types": "^3.4.0",
"@types/dompurify": "^3",
"@types/git-url-parse": "^9.0.0",
"@types/lodash": "^4.14.136",
"@types/markdown-it": "^12.2.3",
"@types/marked": "^5.0.0",
"@types/mdast": "^4.0.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-constraints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@yarnpkg/fslib": "workspace:^",
"clipanion": "^4.0.0-rc.2",
"lodash": "^4.17.15",
"es-toolkit": "^1.19.0",
"tau-prolog": "^0.2.66",
"tslib": "^2.4.0"
},
Expand All @@ -24,7 +24,6 @@
"@yarnpkg/core": "workspace:^"
},
"devDependencies": {
"@types/lodash": "^4.14.136",
"@yarnpkg/builder": "workspace:^",
"@yarnpkg/cli": "workspace:^",
"@yarnpkg/core": "workspace:^",
Expand Down
5 changes: 1 addition & 4 deletions packages/plugin-constraints/sources/constraintUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {Configuration, formatUtils, Manifest, miscUtils, nodeUtils, Project, treeUtils, Workspace} from '@yarnpkg/core';
import {PortablePath} from '@yarnpkg/fslib';
import get from 'lodash/get';
import set from 'lodash/set';
import toPath from 'lodash/toPath';
import unset from 'lodash/unset';
import {get, set, toPath, unset} from 'es-toolkit/compat';

export type ProcessResult = {
manifestUpdates: Map<PortablePath, Map<string, Map<any, Set<nodeUtils.Caller>>>>;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-constraints/sources/tauModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {Project, structUtils} from '@yarnpkg/core';
import {PortablePath} from '@yarnpkg/fslib';
import getPath from 'lodash/get';
import {get as getPath} from 'es-toolkit/compat';
import pl from 'tau-prolog';
import vm from 'vm';

Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-essentials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"ci-info": "^4.0.0",
"clipanion": "^4.0.0-rc.2",
"enquirer": "^2.3.6",
"lodash": "^4.17.15",
"es-toolkit": "^1.19.0",
"micromatch": "^4.0.2",
"semver": "^7.1.2",
"tslib": "^2.4.0",
Expand All @@ -25,7 +25,6 @@
"@yarnpkg/plugin-git": "workspace:^"
},
"devDependencies": {
"@types/lodash": "^4.14.136",
"@types/micromatch": "^4.0.1",
"@types/semver": "^7.1.0",
"@yarnpkg/cli": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-essentials/sources/commands/config/get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {BaseCommand} from '@yarnpkg/cli';
import {Configuration, StreamReport, miscUtils} from '@yarnpkg/core';
import {Command, Option, Usage, UsageError} from 'clipanion';
import getPath from 'lodash/get';
import {get as getPath} from 'es-toolkit/compat';
import {inspect} from 'util';

// eslint-disable-next-line arca/no-default-export
Expand Down
4 changes: 1 addition & 3 deletions packages/plugin-essentials/sources/commands/config/set.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {BaseCommand} from '@yarnpkg/cli';
import {Configuration, StreamReport, MessageName, miscUtils} from '@yarnpkg/core';
import {Command, Option, Usage, UsageError} from 'clipanion';
import cloneDeep from 'lodash/cloneDeep';
import getPath from 'lodash/get';
import setPath from 'lodash/set';
import {cloneDeep, get as getPath, set as setPath} from 'es-toolkit/compat';
import {inspect} from 'util';

// eslint-disable-next-line arca/no-default-export
Expand Down
10 changes: 4 additions & 6 deletions packages/plugin-essentials/sources/commands/config/unset.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {BaseCommand} from '@yarnpkg/cli';
import {Configuration, StreamReport, MessageName} from '@yarnpkg/core';
import {Command, Option, Usage, UsageError} from 'clipanion';
import cloneDeep from 'lodash/cloneDeep';
import hasPath from 'lodash/has';
import unsetPath from 'lodash/unset';
import {BaseCommand} from '@yarnpkg/cli';
import {Configuration, StreamReport, MessageName} from '@yarnpkg/core';
import {Command, Option, Usage, UsageError} from 'clipanion';
import {cloneDeep, has as hasPath, unset as unsetPath} from 'es-toolkit/compat';

// eslint-disable-next-line arca/no-default-export
export default class ConfigUnsetCommand extends BaseCommand {
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@types/semver": "^7.1.0",
"@yarnpkg/fslib": "workspace:^",
"clipanion": "^4.0.0-rc.2",
"es-toolkit": "^1.19.0",
"git-url-parse": "^13.1.0",
"lodash": "^4.17.15",
"semver": "^7.1.2",
"tslib": "^2.4.0"
},
Expand All @@ -21,7 +21,6 @@
},
"devDependencies": {
"@types/git-url-parse": "^9.0.0",
"@types/lodash": "^4.14.136",
"@yarnpkg/core": "workspace:^"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-git/sources/gitUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Configuration, Hooks, Locator, Project, execUtils, httpUtils, miscUtils, semverUtils, structUtils, ReportError, MessageName, formatUtils} from '@yarnpkg/core';
import {Filename, npath, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
import {UsageError} from 'clipanion';
import {capitalize} from 'es-toolkit/compat';
import GitUrlParse from 'git-url-parse';
import capitalize from 'lodash/capitalize';
import querystring from 'querystring';
import semver from 'semver';

Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@yarnpkg/fslib": "workspace:^",
"enquirer": "^2.3.6",
"lodash": "^4.17.15",
"es-toolkit": "^1.19.0",
"semver": "^7.1.2",
"ssri": "^6.0.1",
"tslib": "^2.4.0"
Expand All @@ -20,7 +20,6 @@
"@yarnpkg/plugin-pack": "workspace:^"
},
"devDependencies": {
"@types/lodash": "^4.14.136",
"@types/semver": "^7.1.0",
"@types/ssri": "^6.0.1",
"@yarnpkg/core": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-npm/sources/npmHttpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Configuration, Ident, formatUtils, httpUtils, nodeUtils, StreamReport, s
import {MessageName, ReportError} from '@yarnpkg/core';
import {Filename, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
import {prompt} from 'enquirer';
import pick from 'lodash/pick';
import {pick} from 'es-toolkit/compat';
import semver from 'semver';

import {Hooks} from './index';
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-version/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@yarnpkg/libui": "workspace:^",
"@yarnpkg/parsers": "workspace:^",
"clipanion": "^4.0.0-rc.2",
"es-toolkit": "^1.19.0",
"ink": "^3.0.8",
"lodash": "^4.17.15",
"react": "^16.13.1",
"semver": "^7.1.2",
"tslib": "^2.4.0"
Expand All @@ -24,7 +24,6 @@
"@yarnpkg/plugin-git": "workspace:^"
},
"devDependencies": {
"@types/lodash": "^4.14.136",
"@types/react": "^16.8.0",
"@types/semver": "^7.1.0",
"@yarnpkg/builder": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-version/sources/versionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {PortablePath, npath, ppath, xfs}
import {parseSyml, stringifySyml} from '@yarnpkg/parsers';
import {gitUtils} from '@yarnpkg/plugin-git';
import {UsageError} from 'clipanion';
import omit from 'lodash/omit';
import {omit} from 'es-toolkit/compat';
import semver from 'semver';

// Basically we only support auto-upgrading the ranges that are very simple (^x.y.z, ~x.y.z, >=x.y.z, and of course x.y.z)
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-workspace-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"@yarnpkg/fslib": "workspace:^",
"clipanion": "^4.0.0-rc.2",
"es-toolkit": "^1.19.0",
"micromatch": "^4.0.2",
"p-limit": "^2.2.0",
"tslib": "^2.4.0",
Expand All @@ -21,7 +22,6 @@
"@yarnpkg/plugin-git": "workspace:^"
},
"devDependencies": {
"@types/lodash": "^4.14.136",
"@types/micromatch": "^4.0.1",
"@yarnpkg/builder": "workspace:^",
"@yarnpkg/cli": "workspace:^",
Expand Down
3 changes: 1 addition & 2 deletions packages/yarnpkg-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"cross-spawn": "7.0.3",
"diff": "^5.1.0",
"dotenv": "^16.3.1",
"es-toolkit": "^1.19.0",
"fast-glob": "^3.2.2",
"got": "^11.7.0",
"lodash": "^4.17.15",
"micromatch": "^4.0.2",
"p-limit": "^2.2.0",
"semver": "^7.1.2",
Expand All @@ -44,7 +44,6 @@
"@types/comment-json": "^1.1.1",
"@types/cross-spawn": "6.0.0",
"@types/diff": "^5.0.0",
"@types/lodash": "^4.14.136",
"@types/micromatch": "^4.0.1",
"@types/node": "^18.17.15",
"@types/tar": "^4.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {parseSyml, stringifySyml} from '@y
import {UsageError} from 'clipanion';
import {createHash} from 'crypto';
import {structuredPatch} from 'diff';
import pick from 'lodash/pick';
import {pick} from 'es-toolkit/compat';
import pLimit from 'p-limit';
import semver from 'semver';
import internal from 'stream';
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/Report.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import throttle from 'lodash/throttle';
import {throttle} from 'es-toolkit/compat';
import {PassThrough} from 'stream';
import {StringDecoder} from 'string_decoder';

Expand Down
3 changes: 1 addition & 2 deletions packages/yarnpkg-core/sources/miscUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {PortablePath, npath, xfs} from '@yarnpkg/fslib';
import {UsageError} from 'clipanion';
import isEqual from 'lodash/isEqual';
import mergeWith from 'lodash/mergeWith';
import {isEqual, mergeWith} from 'es-toolkit/compat';
import micromatch from 'micromatch';
import pLimit, {Limit} from 'p-limit';
import semver from 'semver';
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/scriptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {CwdFS, Filename, NativePath, PortablePath} from '@yarnpkg/fslib';
import {xfs, npath, ppath} from '@yarnpkg/fslib';
import {ZipOpenFS} from '@yarnpkg/libzip';
import {execute} from '@yarnpkg/shell';
import capitalize from 'lodash/capitalize';
import {capitalize} from 'es-toolkit/compat';
import pLimit from 'p-limit';
import {PassThrough, Readable, Writable} from 'stream';

Expand Down
3 changes: 1 addition & 2 deletions packages/yarnpkg-sdks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
"chalk": "^3.0.0",
"clipanion": "^4.0.0-rc.2",
"comment-json": "^2.2.0",
"lodash": "^4.17.15",
"es-toolkit": "^1.19.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/comment-json": "^1.1.1",
"@types/lodash": "^4.14.136",
"@yarnpkg/monorepo": "workspace:^",
"@yarnpkg/pnp": "workspace:^"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/yarnpkg-sdks/sources/generateSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {parseSyml, stringifySyml} from '@yarnp
import {PnpApi} from '@yarnpkg/pnp';
import chalk from 'chalk';
import {UsageError} from 'clipanion';
import capitalize from 'lodash/capitalize';
import startCase from 'lodash/startCase';
import {capitalize, startCase} from 'es-toolkit/compat';

import {dynamicRequire} from './dynamicRequire';
import {BASE_SDKS} from './sdks/base';
Expand Down
Loading

0 comments on commit 4809f3a

Please sign in to comment.