Yarn 3.0 — What’s New?
Yarn was created by Facebook in 2016 as an alternate option to NPM(at that time, an improvement too). If you haven’t heard about Yarn, here’s some background:
Breaking Changes
Let’s start with the most important changes(a.k.a breaking changes) in the Yarn Infrastructure:
- Dropped support for Node 10
- Plugins can’t access
yup
- The
enableImmutableInstalls
options will now default totrue
- The
initVersion
andinitLicense
configuration options have been removed.initFields
should be used instead - Yarn will now generate
.pnp.cjs
files (instead of.pnp.js
) when using PnP, regardless of what thetype
field inside the manifest is set to. - The virtual folder (used to disambiguate peer dependencies) is renamed to
__virtual__
to$$virtual
As you can see, most of these changes are internal changes. You can check the rest of them here
Performance
A couple of changes have been made regarding some of the largest resource consumptions in Yarn. Installs have been improved (which makes Yarn faster than PnP in some scenarios, quite impressive!). Progress bars are rendered less often, which might help performances on some terminals. The catch files are now in zip
instead oftgz
which impacts cold install performance.
Bug Fixes
- Yarn now has a governance model
- Peer dependencies depending on their own parent are now properly hoisted by
node-modules
linker - Boolean values will be properly interpreted when specified inside the configuration file via the
${ENV_VAR}
syntax. - Should any of
preinstall
,install
,postinstall
fail, the remaining scripts will be skipped. - The git: protocol will now default to fetching HEAD (rather than the hardcoded master).
- The
SIGTERM
signal will now be propagated to child processes.
I haven’t listed all the bugs here, check this out to learn more
ESBuild Support
Yarn now uses esbuild to generate yarn bundles to improve compatibility with the Plug ’n’ Play installs. The result is the new esbuild-plugin-pnp module which lets you transparently build your code using the default Yarn installation mode. It’s still new so there may be some bugs. While this won’t change much for most end-users, the move to ESBuild also provided decent build speed improvements (around 6x faster).
Future Releases
A few features that were initially planned to be rolled out for 3.0 have been pushed back to the next minor release. Here are some of them:
- Corepack Integration
- ESM support under PnP mode
- Built-in CLI completion
- More Performance Improvements
Checkout the migration guide if you want to update your code!
That’s all for this article guys! I hope you liked it and learned something new today. Follow me on twitter and don’t forget to like this article! Bye 🤟
Credits — changelog and article of a yarn maintainer