Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use yarn instead of npm #8621

Closed
epixa opened this issue Oct 11, 2016 · 16 comments
Closed

Use yarn instead of npm #8621

epixa opened this issue Oct 11, 2016 · 16 comments
Assignees
Labels
blocked build dev Team:Operations Team label for Operations Team

Comments

@epixa
Copy link
Contributor

epixa commented Oct 11, 2016

Facebook just released yarn, which offers some key benefits over npm that aim to solve problems we're currently struggling with. Specifically:

  • It's deterministic
  • It uses diffable lock files to fix dependencies instead of shrinkwrap
  • It has first-class support for cached dependencies, so we don't have to rely on the npm registry itself for builds
  • It verifies checksums, so we know whether the installed dependencies are exactly what they're suppose to be

We can/would continue to use npm as our download registry, so if we ever had issues with yarn, switching back to npm would be a minor task.

@epixa epixa added the discuss label Oct 11, 2016
@w33ble
Copy link
Contributor

w33ble commented Oct 11, 2016

$ time npm install
...
real 1m0.739s
user 0m58.002s
sys 0m19.500s

$ du -sh node_modules
141M node_modules


$ time yarn
...
real 0m29.598s
user 0m23.574s
sys 0m14.129s

$ du -sh node_modules
129M node_modules

That time drops to about 11s once the cache is populated. Not bad!

@spalger
Copy link
Contributor

spalger commented Oct 17, 2016

We talked about this collectively and decided that yarn makes sense for installs, but there are a few issues that will need to be resovled:

@spalger spalger removed the discuss label Oct 17, 2016
@tbragin tbragin added the dev label Oct 19, 2016
@epixa epixa added blocked Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Oct 24, 2016
@tylersmalley
Copy link
Contributor

yarn run fixed in v0.16

@tylersmalley
Copy link
Contributor

tylersmalley commented Nov 4, 2016

We should also look into useing --cache-folder to persist the tar'd packages to the repository. This should alleviate some of the pains of committing node_modules to the repository with the benefits of actually doing so.

@w33ble
Copy link
Contributor

w33ble commented Nov 4, 2016

We should also look into useing --cache-folder to persist the tar'd packages to the repository

I thought the lock file was supposed to be enough to keep things consistent. What does checking in the tars give us, besides not having to download all that stuff every time?

@tylersmalley
Copy link
Contributor

By lock file do you mean the shrinkwrap? We're currently pinning packages to specific versions in the package.json which I don't necessarily feel is the correct approach.

By committing the packages, it would make it much easier and faster to switch branches. We could also go back to using package version ranges.

@w33ble
Copy link
Contributor

w33ble commented Nov 4, 2016

I meant the yarn.lock file, since this is about using yarn. I'm guessing we're going to commit that file as well, otherwise there's little point. As I understand it, that lock file would effectively allow us to go back to version ranges, but would effectively make yarn pin the versions for us based on when then committed lock file was created.

By committing the packages, it would make it much easier and faster to switch branches. We could also go back to using package version ranges.

The lock files gives us the later.

Would users still need to run yarn [install] to get package changes? I think the answer is yes, but I'm pretty sure you're right that they'd get all the package updates much, much faster since there's nothing to actually download, yarn would just re-link things. Is that the main perk then, faster switching between module versions in various branches?

@spalger
Copy link
Contributor

spalger commented Nov 4, 2016

Is that the main perk then, faster switching between module versions in various branches?

It will trim 1+ minutes off of every CI build

@w33ble
Copy link
Contributor

w33ble commented Nov 4, 2016

It will trim 1+ minutes off of every CI build

Compared to npm3, or compared to yarn without the checked in cache-folder?

@spalger
Copy link
Contributor

spalger commented Nov 4, 2016

npm3, might not be a whole lot quicker than a warmed up yarn cache

@epixa
Copy link
Contributor Author

epixa commented Nov 5, 2016

The one thing I can think of that it gives us is guaranteed consistency of the dependency source code. No pulled dependencies (e.g. leftpad), for example.

In any case, I think we should probably treat that as a separate issue to pulling yarn in for the sake of locking. It's an additional feature we'd have at our disposal at least.

@w33ble
Copy link
Contributor

w33ble commented Nov 7, 2016

The one thing I can think of that it gives us is guaranteed consistency of the dependency source code.

This would protect us from packages disappearing from their source, npm or otherwise. As for consistency, I thought that the lock file gave us that as well. Isn't that what all the checksumming stuff does?

Note that I'm not trying to be contrary here, I don't really have an issue checking in the cache folder. I'm genuinely curious about this stuff.

@epixa
Copy link
Contributor Author

epixa commented Nov 7, 2016

@w33ble Yeah, you're right about consistency there. Yarn's lock file would catch a change in source code for a given version, so it can guarantee consistency in that way, but at best it can really just error when something is wrong. The cache would make us more resilient to that sort of problem by relying on the original source when we first get it set up.

I'm not 100% sold on checking in the deps for what it's worth, so we're both just trying to make the situation clear.

@epixa epixa added Team:Operations Team label for Operations Team build and removed Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Mar 18, 2017
@tylersmalley
Copy link
Contributor

@spalger, we no longer use @bigfunger/decompress-zip so that can be checked off.

@Mpdreamz
Copy link
Member

yarn on windows should be faster too now: yarnpkg/yarn#3234

@epixa
Copy link
Contributor Author

epixa commented May 27, 2017

I reverted this PR, so I'm reopening this. See #11637 (comment)

@epixa epixa reopened this May 27, 2017
@spalger spalger self-assigned this May 31, 2017
@tylersmalley tylersmalley self-assigned this Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked build dev Team:Operations Team label for Operations Team
Projects
None yet
Development

No branches or pull requests

6 participants