Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1d28dc6

Browse files
authoredSep 13, 2024··
chore: replace lodash with es-toolkit
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
1 parent 58475b9 commit 1d28dc6

File tree

29 files changed

+209
-269
lines changed

29 files changed

+209
-269
lines changed
 

‎.pnp.cjs

+119-200
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

‎.yarn/versions/4251696d.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
releases:
2+
"@yarnpkg/core": patch
3+
"@yarnpkg/plugin-constraints": patch
4+
"@yarnpkg/plugin-essentials": patch
5+
"@yarnpkg/plugin-git": patch
6+
"@yarnpkg/plugin-npm": patch
7+
"@yarnpkg/plugin-version": patch
8+
"@yarnpkg/plugin-workspace-tools": patch
9+
"@yarnpkg/sdks": patch
10+
11+
declined:
12+
- "@yarnpkg/plugin-compat"
13+
- "@yarnpkg/plugin-dlx"
14+
- "@yarnpkg/plugin-exec"
15+
- "@yarnpkg/plugin-file"
16+
- "@yarnpkg/plugin-github"
17+
- "@yarnpkg/plugin-http"
18+
- "@yarnpkg/plugin-init"
19+
- "@yarnpkg/plugin-interactive-tools"
20+
- "@yarnpkg/plugin-link"
21+
- "@yarnpkg/plugin-nm"
22+
- "@yarnpkg/plugin-npm-cli"
23+
- "@yarnpkg/plugin-pack"
24+
- "@yarnpkg/plugin-patch"
25+
- "@yarnpkg/plugin-pnp"
26+
- "@yarnpkg/plugin-pnpm"
27+
- "@yarnpkg/plugin-stage"
28+
- "@yarnpkg/plugin-typescript"
29+
- "@yarnpkg/builder"
30+
- "@yarnpkg/cli"
31+
- "@yarnpkg/doctor"
32+
- "@yarnpkg/extensions"
33+
- "@yarnpkg/nm"
34+
- "@yarnpkg/pnpify"

‎packages/acceptance-tests/pkg-tests-specs/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@
1313
"directory": "packages/acceptance-tests/pkg-tests-specs"
1414
},
1515
"devDependencies": {
16-
"@types/lodash": "^4.14.136",
1716
"@types/tar": "^4.0.4",
1817
"@yarnpkg/cli": "workspace:^",
1918
"@yarnpkg/core": "workspace:^",
2019
"@yarnpkg/fslib": "workspace:^",
2120
"@yarnpkg/monorepo": "workspace:^",
2221
"@yarnpkg/parsers": "workspace:^",
2322
"@yarnpkg/pnp": "workspace:^",
24-
"lodash": "^4.17.15",
23+
"es-toolkit": "^1.18.0",
2524
"pkg-tests-core": "workspace:^",
2625
"tar": "^6.0.5",
2726
"tslib": "^2.4.0"
2827
},
2928
"engines": {
3029
"node": ">=18.12.0"
30+
},
31+
"dependencies": {
32+
"es-toolkit": "^1.18.0"
3133
}
3234
}

‎packages/acceptance-tests/pkg-tests-specs/sources/plugins/plugin-typescript.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Manifest} from '@yarnpkg/core';
22
import {PortablePath, ppath, xfs} from '@yarnpkg/fslib';
3-
import {merge} from 'lodash';
3+
import {merge} from 'es-toolkit/compat';
44
import {fs, yarn} from 'pkg-tests-core';
55

66
const {unpackToDirectory} = fs;

‎packages/docusaurus/config/remark/commandLineHighlight.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {YarnCli, getCli} from '@yarnpkg/cli';
22
import {parseShell} from '@yarnpkg/parsers';
33
import type {Definition, Token} from 'clipanion';
4+
import {capitalize} from 'es-toolkit/compat';
45
import {fromJs} from 'esast-util-from-js';
5-
import {capitalize} from 'lodash';
66
import type {MdxJsxFlowElement} from 'mdast-util-mdx-jsx';
77
import type {Parent, Root} from 'mdast';
88
import type {Transformer} from 'unified';

‎packages/docusaurus/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
"clsx": "^1.2.1",
3636
"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",
3737
"dompurify": "^3.0.5",
38+
"es-toolkit": "^1.18.0",
3839
"esast-util-from-js": "^2.0.1",
3940
"esbuild-loader": "^2.20.0",
4041
"fast-glob": "^3.2.2",
4142
"git-url-parse": "^13.1.0",
4243
"github-markdown-css": "^5.1.0",
4344
"jiti": "^1.21.0",
44-
"lodash": "^4.17.15",
4545
"markdown-it": "^13.0.1",
4646
"markdown-it-br": "^1.0.0",
4747
"marked": "^5.1.1",
@@ -83,7 +83,6 @@
8383
"@docusaurus/types": "^3.4.0",
8484
"@types/dompurify": "^3",
8585
"@types/git-url-parse": "^9.0.0",
86-
"@types/lodash": "^4.14.136",
8786
"@types/markdown-it": "^12.2.3",
8887
"@types/marked": "^5.0.0",
8988
"@types/mdast": "^4.0.3",

‎packages/plugin-constraints/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"@yarnpkg/fslib": "workspace:^",
1717
"clipanion": "^4.0.0-rc.2",
18-
"lodash": "^4.17.15",
18+
"es-toolkit": "^1.18.0",
1919
"tau-prolog": "^0.2.66",
2020
"tslib": "^2.4.0"
2121
},
@@ -24,7 +24,6 @@
2424
"@yarnpkg/core": "workspace:^"
2525
},
2626
"devDependencies": {
27-
"@types/lodash": "^4.14.136",
2827
"@yarnpkg/builder": "workspace:^",
2928
"@yarnpkg/cli": "workspace:^",
3029
"@yarnpkg/core": "workspace:^",

‎packages/plugin-constraints/sources/constraintUtils.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {Configuration, formatUtils, Manifest, miscUtils, nodeUtils, Project, treeUtils, Workspace} from '@yarnpkg/core';
22
import {PortablePath} from '@yarnpkg/fslib';
3-
import get from 'lodash/get';
4-
import set from 'lodash/set';
5-
import toPath from 'lodash/toPath';
6-
import unset from 'lodash/unset';
3+
import {get, set} from 'es-toolkit/compat';
4+
5+
function toPath(value: any): Array<string> {
6+
return Array.isArray(value) ? value : value.match(/([^[.\]])+/g);
7+
}
78

89
export type ProcessResult = {
910
manifestUpdates: Map<PortablePath, Map<string, Map<any, Set<nodeUtils.Caller>>>>;
@@ -218,7 +219,7 @@ export function applyEngineReport(project: Project, {manifestUpdates, reportedEr
218219
}
219220

220221
if (typeof newValue === `undefined`)
221-
unset(manifest, fieldPath);
222+
set(manifest, fieldPath, undefined);
222223
else
223224
set(manifest, fieldPath, newValue);
224225

‎packages/plugin-constraints/sources/tauModule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import {Project, structUtils} from '@yarnpkg/core';
44
import {PortablePath} from '@yarnpkg/fslib';
5-
import getPath from 'lodash/get';
5+
import {get as getPath} from 'es-toolkit/compat';
66
import pl from 'tau-prolog';
77
import vm from 'vm';
88

‎packages/plugin-essentials/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ci-info": "^4.0.0",
1414
"clipanion": "^4.0.0-rc.2",
1515
"enquirer": "^2.3.6",
16-
"lodash": "^4.17.15",
16+
"es-toolkit": "^1.18.0",
1717
"micromatch": "^4.0.2",
1818
"semver": "^7.1.2",
1919
"tslib": "^2.4.0",
@@ -25,7 +25,6 @@
2525
"@yarnpkg/plugin-git": "workspace:^"
2626
},
2727
"devDependencies": {
28-
"@types/lodash": "^4.14.136",
2928
"@types/micromatch": "^4.0.1",
3029
"@types/semver": "^7.1.0",
3130
"@yarnpkg/cli": "workspace:^",

‎packages/plugin-essentials/sources/commands/config/get.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {BaseCommand} from '@yarnpkg/cli';
22
import {Configuration, StreamReport, miscUtils} from '@yarnpkg/core';
33
import {Command, Option, Usage, UsageError} from 'clipanion';
4-
import getPath from 'lodash/get';
4+
import {get as getPath} from 'es-toolkit/compat';
55
import {inspect} from 'util';
66

77
// eslint-disable-next-line arca/no-default-export

‎packages/plugin-essentials/sources/commands/config/set.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import {BaseCommand} from '@yarnpkg/cli';
22
import {Configuration, StreamReport, MessageName, miscUtils} from '@yarnpkg/core';
33
import {Command, Option, Usage, UsageError} from 'clipanion';
4-
import cloneDeep from 'lodash/cloneDeep';
5-
import getPath from 'lodash/get';
6-
import setPath from 'lodash/set';
4+
import {cloneDeep, get as getPath, set as setPath} from 'es-toolkit/compat';
75
import {inspect} from 'util';
86

97
// eslint-disable-next-line arca/no-default-export

‎packages/plugin-essentials/sources/commands/config/unset.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {BaseCommand} from '@yarnpkg/cli';
2-
import {Configuration, StreamReport, MessageName} from '@yarnpkg/core';
3-
import {Command, Option, Usage, UsageError} from 'clipanion';
4-
import cloneDeep from 'lodash/cloneDeep';
5-
import hasPath from 'lodash/has';
6-
import unsetPath from 'lodash/unset';
1+
import {BaseCommand} from '@yarnpkg/cli';
2+
import {Configuration, StreamReport, MessageName} from '@yarnpkg/core';
3+
import {Command, Option, Usage, UsageError} from 'clipanion';
4+
import {cloneDeep, has as hasPath, set as setPath} from 'es-toolkit/compat';
75

86
// eslint-disable-next-line arca/no-default-export
97
export default class ConfigUnsetCommand extends BaseCommand {
@@ -73,7 +71,7 @@ export default class ConfigUnsetCommand extends BaseCommand {
7371
? cloneDeep(current)
7472
: {...current};
7573

76-
unsetPath(clone, this.name);
74+
setPath(clone, this.name, undefined);
7775
return clone;
7876
});
7977

‎packages/plugin-git/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"@types/semver": "^7.1.0",
1212
"@yarnpkg/fslib": "workspace:^",
1313
"clipanion": "^4.0.0-rc.2",
14+
"es-toolkit": "^1.18.0",
1415
"git-url-parse": "^13.1.0",
15-
"lodash": "^4.17.15",
1616
"semver": "^7.1.2",
1717
"tslib": "^2.4.0"
1818
},
@@ -21,7 +21,6 @@
2121
},
2222
"devDependencies": {
2323
"@types/git-url-parse": "^9.0.0",
24-
"@types/lodash": "^4.14.136",
2524
"@yarnpkg/core": "workspace:^"
2625
},
2726
"repository": {

‎packages/plugin-git/sources/gitUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {Configuration, Hooks, Locator, Project, execUtils, httpUtils, miscUtils, semverUtils, structUtils, ReportError, MessageName, formatUtils} from '@yarnpkg/core';
22
import {Filename, npath, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
33
import {UsageError} from 'clipanion';
4+
import {capitalize} from 'es-toolkit/compat';
45
import GitUrlParse from 'git-url-parse';
5-
import capitalize from 'lodash/capitalize';
66
import querystring from 'querystring';
77
import semver from 'semver';
88

‎packages/plugin-npm/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"@yarnpkg/fslib": "workspace:^",
1212
"enquirer": "^2.3.6",
13-
"lodash": "^4.17.15",
13+
"es-toolkit": "^1.18.0",
1414
"semver": "^7.1.2",
1515
"ssri": "^6.0.1",
1616
"tslib": "^2.4.0"
@@ -20,7 +20,6 @@
2020
"@yarnpkg/plugin-pack": "workspace:^"
2121
},
2222
"devDependencies": {
23-
"@types/lodash": "^4.14.136",
2423
"@types/semver": "^7.1.0",
2524
"@types/ssri": "^6.0.1",
2625
"@yarnpkg/core": "workspace:^",

‎packages/plugin-npm/sources/npmHttpUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Configuration, Ident, formatUtils, httpUtils, nodeUtils, StreamReport, s
22
import {MessageName, ReportError} from '@yarnpkg/core';
33
import {Filename, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
44
import {prompt} from 'enquirer';
5-
import pick from 'lodash/pick';
5+
import {pick} from 'es-toolkit/compat';
66
import semver from 'semver';
77

88
import {Hooks} from './index';

‎packages/plugin-version/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"@yarnpkg/libui": "workspace:^",
1313
"@yarnpkg/parsers": "workspace:^",
1414
"clipanion": "^4.0.0-rc.2",
15+
"es-toolkit": "^1.18.0",
1516
"ink": "^3.0.8",
16-
"lodash": "^4.17.15",
1717
"react": "^16.13.1",
1818
"semver": "^7.1.2",
1919
"tslib": "^2.4.0"
@@ -24,7 +24,6 @@
2424
"@yarnpkg/plugin-git": "workspace:^"
2525
},
2626
"devDependencies": {
27-
"@types/lodash": "^4.14.136",
2827
"@types/react": "^16.8.0",
2928
"@types/semver": "^7.1.0",
3029
"@yarnpkg/builder": "workspace:^",

‎packages/plugin-version/sources/versionUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {PortablePath, npath, ppath, xfs}
33
import {parseSyml, stringifySyml} from '@yarnpkg/parsers';
44
import {gitUtils} from '@yarnpkg/plugin-git';
55
import {UsageError} from 'clipanion';
6-
import omit from 'lodash/omit';
6+
import {omit} from 'es-toolkit/compat';
77
import semver from 'semver';
88

99
// 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)

‎packages/plugin-workspace-tools/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"dependencies": {
1111
"@yarnpkg/fslib": "workspace:^",
1212
"clipanion": "^4.0.0-rc.2",
13+
"es-toolkit": "^1.18.0",
1314
"micromatch": "^4.0.2",
1415
"p-limit": "^2.2.0",
1516
"tslib": "^2.4.0",
@@ -21,7 +22,6 @@
2122
"@yarnpkg/plugin-git": "workspace:^"
2223
},
2324
"devDependencies": {
24-
"@types/lodash": "^4.14.136",
2525
"@types/micromatch": "^4.0.1",
2626
"@yarnpkg/builder": "workspace:^",
2727
"@yarnpkg/cli": "workspace:^",

‎packages/yarnpkg-core/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"cross-spawn": "7.0.3",
2424
"diff": "^5.1.0",
2525
"dotenv": "^16.3.1",
26+
"es-toolkit": "^1.18.0",
2627
"fast-glob": "^3.2.2",
2728
"got": "^11.7.0",
28-
"lodash": "^4.17.15",
2929
"micromatch": "^4.0.2",
3030
"p-limit": "^2.2.0",
3131
"semver": "^7.1.2",
@@ -44,7 +44,6 @@
4444
"@types/comment-json": "^1.1.1",
4545
"@types/cross-spawn": "6.0.0",
4646
"@types/diff": "^5.0.0",
47-
"@types/lodash": "^4.14.136",
4847
"@types/micromatch": "^4.0.1",
4948
"@types/node": "^18.17.15",
5049
"@types/tar": "^4.0.4",

‎packages/yarnpkg-core/sources/Project.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {parseSyml, stringifySyml} from '@y
44
import {UsageError} from 'clipanion';
55
import {createHash} from 'crypto';
66
import {structuredPatch} from 'diff';
7-
import pick from 'lodash/pick';
7+
import {pick} from 'es-toolkit/compat';
88
import pLimit from 'p-limit';
99
import semver from 'semver';
1010
import internal from 'stream';

‎packages/yarnpkg-core/sources/Report.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import throttle from 'lodash/throttle';
1+
import {throttle} from 'es-toolkit/compat';
22
import {PassThrough} from 'stream';
33
import {StringDecoder} from 'string_decoder';
44

‎packages/yarnpkg-core/sources/miscUtils.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {PortablePath, npath, xfs} from '@yarnpkg/fslib';
22
import {UsageError} from 'clipanion';
3-
import isEqual from 'lodash/isEqual';
4-
import mergeWith from 'lodash/mergeWith';
3+
import {isEqual, mergeWith} from 'es-toolkit/compat';
54
import micromatch from 'micromatch';
65
import pLimit, {Limit} from 'p-limit';
76
import semver from 'semver';

‎packages/yarnpkg-core/sources/scriptUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {CwdFS, Filename, NativePath, PortablePath} from '@yarnpkg/fslib';
22
import {xfs, npath, ppath} from '@yarnpkg/fslib';
33
import {ZipOpenFS} from '@yarnpkg/libzip';
44
import {execute} from '@yarnpkg/shell';
5-
import capitalize from 'lodash/capitalize';
5+
import {capitalize} from 'es-toolkit/compat';
66
import pLimit from 'p-limit';
77
import {PassThrough, Readable, Writable} from 'stream';
88

‎packages/yarnpkg-sdks/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
"chalk": "^3.0.0",
1818
"clipanion": "^4.0.0-rc.2",
1919
"comment-json": "^2.2.0",
20-
"lodash": "^4.17.15",
20+
"es-toolkit": "^1.18.0",
2121
"tslib": "^2.4.0"
2222
},
2323
"devDependencies": {
2424
"@types/comment-json": "^1.1.1",
25-
"@types/lodash": "^4.14.136",
2625
"@yarnpkg/monorepo": "workspace:^",
2726
"@yarnpkg/pnp": "workspace:^"
2827
},

‎packages/yarnpkg-sdks/sources/generateSdk.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {parseSyml, stringifySyml} from '@yarnp
44
import {PnpApi} from '@yarnpkg/pnp';
55
import chalk from 'chalk';
66
import {UsageError} from 'clipanion';
7-
import capitalize from 'lodash/capitalize';
8-
import startCase from 'lodash/startCase';
7+
import {capitalize, startCase} from 'es-toolkit/compat';
98

109
import {dynamicRequire} from './dynamicRequire';
1110
import {BASE_SDKS} from './sdks/base';

0 commit comments

Comments
 (0)
Please sign in to comment.