Why use yarn as a dependency in Polymer 3.0?

189 views
Skip to first unread message

Mark

unread,
Oct 1, 2017, 10:30:14 AM10/1/17
to Polymer
I was reading Polymer's 3.0 Preview documentation and see that they've announced that yarn is a dependency. 

Why? instead of just using NPM 5, which does a lot of the same things yarn does?
In the summit, they have said that they needed a  package manager to:
  1. Manages dependencies
  2. Resolves version conflicts
  3. Supports a flat dependency tree
  4. Has an active community

AFAIK, npm already does this in later versions. So why use yarn which is unnecessary?
I get that yarn may be the hot dependency manager today but a lot of people are fine with just using npm. 

craig.je...@gmail.com

unread,
Oct 18, 2017, 11:16:40 AM10/18/17
to Polymer
Specifically, NPM 5 does not accomplish #3 of your list. I've heard that they are working on enabling that in a future release but for now the only package manager based off of the npm registry that can handle flat dependency trees is yarn.

Justin Fagnani

unread,
Oct 18, 2017, 5:45:42 PM10/18/17
to craig.je...@gmail.com, Polymer
On Wed, Oct 18, 2017 at 8:16 AM, <craig.je...@gmail.com> wrote:
Specifically, NPM 5 does not accomplish #3 of your list.

This is exactly right
 

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/2e9f6920-4a45-4c84-9a5d-7208653c98ba%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

deos...@gmail.com

unread,
Oct 26, 2017, 1:58:40 AM10/26/17
to Polymer


On Thursday, October 19, 2017 at 3:15:42 AM UTC+5:30, Justin Fagnani wrote:
On Wed, Oct 18, 2017 at 8:16 AM, <craig.je...@gmail.com> wrote:
Specifically, NPM 5 does not accomplish #3 of your list.

This is exactly right
 
I've heard that they are working on enabling that in a future release but for now the only package manager based off of the npm registry that can handle flat dependency trees is yarn.

On Sunday, October 1, 2017 at 9:30:14 AM UTC-5, Mark wrote:
I was reading Polymer's 3.0 Preview documentation and see that they've announced that yarn is a dependency. 

Why? instead of just using NPM 5, which does a lot of the same things yarn does?
In the summit, they have said that they needed a  package manager to:
  1. Manages dependencies
  2. Resolves version conflicts
  3. Supports a flat dependency tree
  4. Has an active community

AFAIK, npm already does this in later versions. So why use yarn which is unnecessary?
I get that yarn may be the hot dependency manager today but a lot of people are fine with just using npm. 

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.

craig.je...@gmail.com

unread,
Oct 26, 2017, 8:03:22 AM10/26/17
to Polymer
That article is unfortunately worded. npm v3 did not have a true flat dependency structure, but a rather a flatter dependency structure. The article referenced gives a good overview of what npm v3 achieved (https://docs.npmjs.com/how-npm-works/npm3). Basically, it installs flat unless there are conflicting versions, then it installs nested. This does not work for front-end dependencies well because you can possibly load two versions of the same library to the client, or you load only one version of a library and it breaks another library because it expected a different version.

Polymer v3 requires a truly flat dependency tree where there are never nested dependencies. When there are conflicting versions of a dependency, a 'resolution' is needed to decide which single version to install. This was achieved in bower through the 'resolutions' key (https://github.com/bower/spec/blob/master/json.md#resolutions). Currently npm does not have an equal feature, but yarn does (https://yarnpkg.com/en/docs/selective-version-resolutions).

Mark

unread,
Oct 26, 2017, 8:17:39 AM10/26/17
to Polymer
yarn does not have flat dependencies by default so it most certainly has a nested dependency tree. It does provide a "flat mode", but imo this is just a step to allow manual resolution. The problem with Polymer relying on yarn's flat mode is that it forces lower level dependencies into the flat tree structure and breaks projects that contain packages that rely on npm's nested tree structure.

Mark

unread,
May 19, 2018, 12:29:29 PM5/19/18
to Polymer
Hmm, it looks like they've removed the yarn requirement from Polymer 3. I don't seem to see it anywhere on the Polymer 3 quick start/installation pages

gregory....@gmail.com

unread,
May 19, 2018, 9:39:34 PM5/19/18
to Polymer
Good, because just a few days ago, it DID mention yarn somewhere, and as a new user, I was a bit confused, because it didn't mention it everywhere. ;^) (I can't find any mention of yarn anywhere now either)

Mark

unread,
May 21, 2018, 10:28:32 AM5/21/18
to gregory....@gmail.com, Polymer

Eh—scratch that. It appears you still need to use yarn once you start using polymer specific components like the paper- ones. See the comment I’ve made on the Polymer 3 slack channel.


On Sat, May 19, 2018 at 9:39 PM <gregory....@gmail.com> wrote:
Good, because just a few days ago, it DID mention yarn somewhere, and as a new user, I was a bit confused, because it didn't mention it everywhere. ;^) (I can't find any mention of yarn anywhere now either)

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages