Yangshun Tay
Yangshun Tay

Reputation: 53169

Is Yarn a wrapper over npm?

I'm aware of the benefits that Yarn brings about and what it does that npm doesn't. I do have some doubts however:

Upvotes: 4

Views: 1439

Answers (2)

jsdario
jsdario

Reputation: 6833

No, it is a rewrite.

Rather than continue building infrastructure around the npm client, we decided to try looking at the problem more holistically. What if instead we attempted to build a new client that addressed the core issues we were experiencing? Sebastian McKenzie in our London office started hacking on this idea and we quickly became excited about its potential.

-- https://code.facebook.com/posts/1840075619545360

It offers the same API (without some shortcuts if you notice). This is (I am guessing) because the original interface was simple enough and to ensure adoption.

It is much faster, solves typical problems of npm (undeterministic deploys mainly). This can be only achieved with a top-down rewrite, they also changed how deps are installed (fetch, calculate, download, link) so the logic is different.

The downsides of this approach is that it requires a huge amount of work. Normally you would just PR over the main repo, but given they wanted a whole different thing and Facebook has the means, they decided going solo.

Another big downside is that its benefits won't be immediately available for all the npm older users, since it is not an upgrade and it does not come installed with node.

Upvotes: 6

Yangshun Tay
Yangshun Tay

Reputation: 53169

I had a look at Yarn's source code and found that there was custom code written for each command: https://github.com/yarnpkg/yarn/tree/master/src/cli/commands.

I guess the downside to this approach is that in future when npm adds new commands, the Yarn team would have to track the changes and manually implement them.

Upvotes: 0

Related Questions