Package management client hits 1.0
Facebook, known for telling tales about users it doesn't have, has spun another sort of yarn.
Yarn is an alternative to npm (Node Package Manager), the default package manager for Node.js installations.
Yarn and npm, as client applications, connect to the npm registry, home to almost half a million packages, to fetch however many bundles of code are required by the application in question.
According to Facebook, there are now more than 175,000 projects on GitHub that use Yarn and the software now handles over 3 billion package downloads a month.
"Yarn's main focus when we launched almost a year ago was stability, resiliency, and performance," said Facebook engineers Burak Yiğit Kaya, Christoph Nakazawa, and Maël Nison in a blog post.
They claim that large companies like Twitter and Microsoft have used the software and reduced package install times by a factor of five.
In addition to speed, Yarn's main reason for being is to make the installations more reliable and reproducible through the inclusion of lockfiles. These files limit installed dependences to a specific version, in order to make every install result in the same file structure – in the
node_modules folder – across all machines.
Yarn's deterministic approach to package management has particular appeal to devops automation, where scripts demand consistent behavior.
Version 1.0 of Yarn adds some new bells and whistles. A feature called Workspaces is designed to make life easier for companies that prefer a single large code repository, to avoid dependency synchronization problems, over distributed repositories.
Workspaces allows users to gather dependences listed in multiple
package.json files and install them in subfolders of a single root
package.json file, under a single lock file. To ensure that current code gets used across all projects, Yarn builds symlinks between Workspaces that depend on each other.
Yarn includes a new auto-merge mechanism, to resolve lockfile merge conflicts that may arise after the
yarn install command.
In addition, there's a selective version resolution feature designed to handle situations where layers of dependencies delay the availability of patched code. Instead of waiting for a direct dependency to be updated or forking code for a fix, the resolution field in
package.json files can demand specific versions of sub-dependencies.
Kaya, Nakazawa, and Nison say they hope to make Yarn more useful for providing some assurance that packages are safe. They say they're planning to work with npm to add two-factor authentication to Yarn to enhance package security, which has proven to be something of an issue for npm.