JavaScript: Yarn 3.1 reviews workspace architecture
A new minor version of the Yarn JavaScript package manager is available in version 3.1. The alternative to npm follows the semantic version and so there is no change to the break. However, the new version adapts the SDK to accommodate a significant change in Visual Studio Code 1.61 and above.
Extended workspace syntax
Yarn 3.1 reviews and adds to the workspace architecture workspace:^
And workspace:~
added. So far already workspace:*
It was available, its rows were replaced at the time of publication with the corresponding rows from the target workspace. However, if there is an insert character (caret, ^
) instead of the exact range, this was only possible in the model workspace:^x.y.z
This yarn was updated throughout the repository after publication. The resulting merge conflicts should be reduced by the new syntax. This should simplify cross-referencing in monorepos in particular, as most packages are to be released.
In a particular case, the syntax is also available in the file peerDependencies
-So :
{
"peerDependencies": {
"@my/other-package": "workspace:^"
}
}
In addition to the new flag --since
Added, indicating yarn workspaces list
And yarn workspaces foreach
can be applied. As a result, commands are applied only to packages modified with respect to the master or master branch, depending on which branches are present. However, the Yarn team describes this new option as “still a bit experimental,” especially when used with the software. -R,--recursive
Uses.
Other changes
It includes the new version of Yarn Node.js – recently released in version 17 – thanks to the beta tool Corepack. It is intended to build a bridge between Node.js and package managers and supports Yarn and pnp, but not npm.
Using ECMAScripts (ESMs) with the Loader Hook API, which is not yet stable, is also experimental in Yarn 3.1. ESM support should be automatically enabled when any of the packages in the dependency tree contain an icon "type": "module"
– in the dependency tree. It can also be turned on or off manually in settings (pnpEnableEsmLoader: true
).
All of the new features in Yarn 3.1 can be found in the developer post and changelog on GitHub.
“Organizer. Social media geek. General communicator. Bacon scholar. Proud pop culture trailblazer.”