Yarn, a new JavaScript package manager released by Facebook and Google

3 min reading
User Experience / 28 November 2016
Yarn, a new JavaScript package manager released by Facebook and Google
Yarn, a new JavaScript package manager released by Facebook and Google

BBVA API Market

Yarn is the new JavaScript package installer and dependency manager released by Facebook in collaboration with other big tech players such as Google. It introduces changes in dependency management and task execution as well as some performance improvements.

When working with JavaScript technology, the most logical approach for developers is to frequently install new packages in this programming language to then be able to launch certain projects. For this type of action, some managers enable seamless installation of these libraries with a single command line. For example, npm (Node Package Manager) is the most popular JavaScript package manager among developers that use Node.js, the cross-platform, open-source execution environment by server layer. Node.js is one of the technologies that has been able to bring JavaScript language from front-end to back-end.

The idea behind these JavaScript package managers is that developers can share millions of small pieces of code that can be reused in different projects, sparing them from wasting time writing code for basic elements. By downloading and installing a package or library, this can be avoided.

Between the added elements and those that are a part of the developer’s own programming there are some dependencies (to some extent, they all fit together like engine parts). JavaScript package managers release developers from the hard work of managing these code dependencies, allowing them to focus on what really matters: creating reliable products and services.

Yarn, the new market player

As an alternative to npm (possibly the most popular JavaScript package manager among the developer community), we now have a solution that may attain success if we consider its promoters: Facebook, Google, Exponent and Tilde. This alternative is called Yarn and it has drawn a lot of attention not only for its creators, but also due to the change in the approach to package download and installation, as well as dependency management.

For years, Facebook used the npm client to install and manage JavaScript packages in its own code but it has acknowledged that “consistency, security and performance issues” rose exponentially with the increase of the code volume and the number of engineers and programmers involved. For this reason, they decided to develop their own JavaScript package manager that would allow them to “manage our dependencies more reliably.”

Key differences between npm and Yarn

npm and Yarn show some major differences that result from the work of Facebook and its partners on the new JavaScript package manager

Yarn doesn’t work this way. This new manager uses certain blocking files that work on the dependencies installed in certain code versions to ensure that node_modules has the same file structure irrespective of the project and the developers that have accessed the programming base. Yarn generates a certain level of unity in the entire process albeit there are some changes. In any case, npm also includes the command npm shrinkwrap to block certain versions of different packages and their descendants within the hierarchical directory node_modules. The problem arises when there are changes to packages that are no longer inside what npm calls “semantic versioning” (semver).

Yarn’s new installation and control process consists of various steps:

– Resolution: Yarn resolves the dependencies among JavaScript packages and libraries by submitting record requests and reviewing each dependency that has already been processed within the directory.

– Fletching: Then, Yearn reviews the overall directory in the cache memory and checks that the JavaScript package or library that you wish to download was not installed before. If it finds out that the package was not installed before, it downloads the package and installs it in the cache so that the same dependency is not installed and processed again in the future.

– Linking: Lastly, Yarn copies all files from the cache memory to node_modules of the local directory so that developers may start working with the JavaScript package.

Are you interested in financial APIs? Discover all the APIs we can offer you at BBVA

 

 

 

 

It may interest you