Commit 2c69552
authored
feat(perf) - de-duplicate chalk dependency (#6784)
## What's the problem this PR addresses?
π Hello! I was randomly looking at the `@yarnpkg/cli` bundle, and
esbuild reported a few warnings (when building locally in the repo, and
inspecting on https://esbuild.github.io/analyze/ ).
One of these warnings, was that there are some duplicated external
libraries - such as `chalk`.

<details><summary>Full bundle graph</summary>
<img
src="https://github.com/user-attachments/assets/99133d9b-5bbf-4390-84ab-b608ef301501"
/>
</details>
The savings from this PR are tiny (a few kb), but worth doing :)
## What does this PR do
This PR bumps chalk to consistently be [v4.1.2
](https://github.com/chalk/chalk/releases/tag/v4.0.0) up from v `3.0.0`.
The diff for 3.0.0 to 4.0.0 is
[here](chalk/chalk@v3.0.0...v4.0.0). The only
relevant breaking change is dropping node 8 support, which should
suffice for yarn (current engines of yarn is set to 18).
> [!NOTE]
> I didn't opt for [v5
](https://github.com/chalk/chalk/releases/tag/v5.0.0)- as it's esm only,
and may require some config tweaking. V5 **is** a smaller bundle though,
~half the size!
/aside - It would be a larger bundle saving to remove the dependency
entirely to something like https://www.npmjs.com/package/picocolors -
but that's potentially a larger piece of work, as `@yarnpkg/shell` [uses
some bespoke colors
](https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-shell/sources/index.ts#L815-L815).
I tried to bump ink, as they've made some improvements too - but it
seems they expect tools to bundle with an `esm` format - wheras yarn is
currently bundling as `iife`, so would require decent patching or
upstream changes ( I couldn't get either to work just yet).
## How did you fix it?
`yarn upgrade-interactive` to specify v4 of chalk :)
Note that yarn upgrade-interactive is difficult to use when using
workspaces, until #3260 (or similar) are closed. Similarly reported in
#2591 #3281.
## Checklist
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.1 parent bee82ef commit 2c69552
File tree
10 files changed
+52
-37
lines changed- .yarn
- cache
- versions
- packages
- yarnpkg-builder
- yarnpkg-core
- sources
- yarnpkg-sdks
- yarnpkg-shell
10 files changed
+52
-37
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5780 | 5780 | | |
5781 | 5781 | | |
5782 | 5782 | | |
5783 | | - | |
| 5783 | + | |
5784 | 5784 | | |
5785 | 5785 | | |
5786 | 5786 | | |
| |||
5866 | 5866 | | |
5867 | 5867 | | |
5868 | 5868 | | |
5869 | | - | |
| 5869 | + | |
5870 | 5870 | | |
5871 | 5871 | | |
5872 | 5872 | | |
| |||
6092 | 6092 | | |
6093 | 6093 | | |
6094 | 6094 | | |
6095 | | - | |
| 6095 | + | |
6096 | 6096 | | |
6097 | 6097 | | |
6098 | 6098 | | |
| |||
6630 | 6630 | | |
6631 | 6631 | | |
6632 | 6632 | | |
6633 | | - | |
| 6633 | + | |
6634 | 6634 | | |
6635 | 6635 | | |
6636 | 6636 | | |
| |||
6649 | 6649 | | |
6650 | 6650 | | |
6651 | 6651 | | |
6652 | | - | |
| 6652 | + | |
6653 | 6653 | | |
6654 | 6654 | | |
6655 | 6655 | | |
| |||
7948 | 7948 | | |
7949 | 7949 | | |
7950 | 7950 | | |
7951 | | - | |
7952 | | - | |
7953 | | - | |
7954 | | - | |
7955 | | - | |
7956 | | - | |
7957 | | - | |
7958 | | - | |
7959 | | - | |
7960 | | - | |
7961 | 7951 | | |
7962 | 7952 | | |
7963 | 7953 | | |
| |||
0 commit comments