Skip to content

Conversation

spanishpear
Copy link
Contributor

@spanishpear spanishpear commented May 4, 2025

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.

{1BA9255A-15DD-48DC-9A9E-D8183671F486}

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 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

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@spanishpear
Copy link
Contributor Author

Ah, I left a type error in - will fix it when I'm back at my laptop!

RDIL
RDIL previously approved these changes May 7, 2025
Copy link
Member

@RDIL RDIL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@RDIL
Copy link
Member

RDIL commented May 7, 2025

Looks like the chalk type changed slightly, feel free to ping me once it's fixed

@spanishpear
Copy link
Contributor Author

@RDIL thanks for your patience, just fixed up those types ❤️

@spanishpear spanishpear requested a review from RDIL May 16, 2025 13:41
@RDIL RDIL added this pull request to the merge queue May 16, 2025
Merged via the queue into yarnpkg:master with commit 2c69552 May 16, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants