feat(perf) - de-duplicate chalk dependency #6784
Open
+50
−35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.Full bundle graph
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 up from v
3.0.0
.The diff for 3.0.0 to 4.0.0 is here. 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 - 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 .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 asiife
, 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