Skip to content

Switch to Yarn#15485

Merged
kimjoar merged 26 commits intoelastic:masterfrom
spalger:implement/yarn
Jan 10, 2018
Merged

Switch to Yarn#15485
kimjoar merged 26 commits intoelastic:masterfrom
spalger:implement/yarn

Conversation

@spalger
Copy link
Copy Markdown
Contributor

@spalger spalger commented Dec 7, 2017

Resubmission of #8621

Closes #8621

This PR includes a vendored version of Yarn built from yarnpkg/yarn#5059.

@spalger spalger added the WIP Work in progress label Dec 7, 2017
@spalger spalger force-pushed the implement/yarn branch 7 times, most recently from 99a870c to c7de861 Compare December 8, 2017 00:21
package.json Outdated
Copy link
Copy Markdown
Contributor Author

@spalger spalger Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By loosening our required versions (in package.json, yarn.lock makes them strict) we allow yarn to flatten our node_modules more. This is good for efficiency, but also necessary for some of our dependencies

With strict versions in Kibana yarn was installing 12 copies of moment.

# find node_modules -path '*node_modules/moment'
node_modules/moment-timezone/node_modules/moment
node_modules/statehood/node_modules/moment
node_modules/moment
node_modules/hapi/node_modules/moment
node_modules/libesvm/node_modules/moment
node_modules/grunt-esvm/node_modules/moment
node_modules/inert/node_modules/moment
node_modules/bunyan/node_modules/moment
node_modules/vision/node_modules/moment
node_modules/h2o2/node_modules/moment
node_modules/even-better/node_modules/moment
node_modules/makelogs/node_modules/moment

This caused bugs and test failures because we rely on moment having the same internal state everywhere, especially in moment-timezone, but moment-timezone depends on moment@^2.6.0. With npm this a satisfied by our dependency on moment@2.13.0, but yarn attempts to get the latest version of moment it can for moment-timezone, causing it to install moment@2.19.3 into moment-timezone/node_modules. When Kibana and moment-timezone depend on a ^ version of moment they both get the most recent version, installed once in the root node_modules directory.

With looser versions, yarn installs one version of moment

node_modules/moment

Overall, with strict versions kibana installs 2521 modules (88k files) and with looser versions kibana installs 2296 modules (82k files). A decent win.

@kimjoar
Copy link
Copy Markdown
Contributor

kimjoar commented Dec 9, 2017

I've got a PR in to fix the blocker: yarnpkg/yarn#5059. Let's see if it's accepted.

@kimjoar kimjoar changed the title switch to yarn Switch to yarn Dec 9, 2017
@kimjoar kimjoar changed the title Switch to yarn Switch to Yarn Dec 9, 2017
@tylersmalley tylersmalley self-requested a review December 13, 2017 18:39
@tylersmalley tylersmalley removed their request for review December 26, 2017 17:28
@tylersmalley
Copy link
Copy Markdown
Member

@spalger, un-assigning myself until the yarn PR is merged.

@spalger
Copy link
Copy Markdown
Contributor Author

spalger commented Jan 8, 2018

NOTE: need to verify that grunt licenses:csv_report produces the same output with yarn and npm

@kimjoar
Copy link
Copy Markdown
Contributor

kimjoar commented Jan 9, 2018

I made some review fixes, plus I locked some versions specifically in the yarn.lock file so we don't have several versions of angular, moment, etc

@kimjoar
Copy link
Copy Markdown
Contributor

kimjoar commented Jan 9, 2018

Discussed with @spalger, went with resolutions instead, to make sure we force one specific version of Angular, React, Moment.

e.g. because of the outdated React packages right now we get this warning because of forcing this:

warning Resolution field "react@16.0.0" is incompatible with requested version "react@^15.6.2"

@kimjoar
Copy link
Copy Markdown
Contributor

kimjoar commented Jan 10, 2018

jenkins, test this

The currently vendored version of Yarn contains the bugfix in
https://github.com/yarnpkg/yarn/pull/5059, which handles optional dependencies.

To build a new Yarn bundle, check out that pull requst and run:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request

To build a new Yarn bundle, check out that pull requst and run:

```
yarn run build-bundle
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can omit run

###
### downloading yarn
###
yarnVersion="$(node -e "console.log(String(require('./package.json').engines.yarn || '').replace(/^[^\d]+/,''))")"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be using tasks/vendor/yarn-1.3.2-with-ignore-fix.js or am I missing something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should probably do that. I'll fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to need to put this back once yarnpkg/yarn#5059 is merged but 🤷‍♂️

@tylersmalley
Copy link
Copy Markdown
Member

tylersmalley commented Jan 10, 2018

Some more pros, like we need more...

  • bundle size reduction of 6.8% (74913714 vs 69813592 bytes)
  • file count reduction of 7.47% (54408 vs 50344)

Copy link
Copy Markdown
Contributor Author

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kimjoar kimjoar removed the v5.6.6 label Jan 10, 2018
@kimjoar kimjoar merged commit 0fde087 into elastic:master Jan 10, 2018
kimjoar pushed a commit to kimjoar/kibana that referenced this pull request Jan 10, 2018
* switch to yarn

* cleanup misc references to npm

* [yarn] loosen dependency ranges so yarn will merge more deps

* fix linting error now that moment uses ESM

* [licenses] font-awesome changed the format of its license id

* Use local yarn

* Misc fixes

* eslintignore built yarn file

* Remove mkdir which doesn't do what it should do

* Check build without upgrading lots of versions

* Fix license check

* too many moments

* Better description

* Review fixes

* Lock to angular@1.6.5

* More specific version locks

* Revert "More specific version locks"

This reverts commit 11ef811.

* Revert "Lock to angular@1.6.5"

This reverts commit 3ade68c.

* rm yarn.lock; yarn

* Forcing a specific version of React, Angular, Moment

* Using vendored version of yarn in ci

* Use --frozen-lockfile

* fixes
kimjoar added a commit that referenced this pull request Jan 10, 2018
* Switch to Yarn (#15485)

* switch to yarn

* cleanup misc references to npm

* [yarn] loosen dependency ranges so yarn will merge more deps

* fix linting error now that moment uses ESM

* [licenses] font-awesome changed the format of its license id

* Use local yarn

* Misc fixes

* eslintignore built yarn file

* Remove mkdir which doesn't do what it should do

* Check build without upgrading lots of versions

* Fix license check

* too many moments

* Better description

* Review fixes

* Lock to angular@1.6.5

* More specific version locks

* Revert "More specific version locks"

This reverts commit 11ef811.

* Revert "Lock to angular@1.6.5"

This reverts commit 3ade68c.

* rm yarn.lock; yarn

* Forcing a specific version of React, Angular, Moment

* Using vendored version of yarn in ci

* Use --frozen-lockfile

* fixes

* Update lockfile
@spalger spalger deleted the implement/yarn branch January 10, 2018 18:34
@spalger
Copy link
Copy Markdown
Contributor Author

spalger commented Jan 10, 2018

6.2/6.x: a817517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v6.2.0 v7.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants