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

Support Yarn 2 #795

Merged
merged 71 commits into from
Jul 14, 2020
Merged

Support Yarn 2 #795

merged 71 commits into from
Jul 14, 2020

Conversation

danielleadams
Copy link
Contributor

@danielleadams danielleadams commented Jun 26, 2020

This pull request implements support for Yarn 2 usage on Heroku. This is an initial pass at support to collect information on how to best add additional features. This is a first attempt to see how Heroku users approach "no installs".

Fixes #739
Alternative solution to #797

Use case

Heroku is initially supporting repos with Yarn and dependencies checked into the repo in the .yarn directory. Monorepos/workspaces are supported.

Steps that are different

  • Cache will not be restored from previous build
  • Install will not be run, and no subsequent scripts (ie. yarn preinstall and yarn postinstall)
  • Dev dependencies will not be removed/pruned
  • Dependencies will not be cached for next build

Danielle Adams and others added 30 commits April 8, 2020 12:40
warning when yarn 2 and engine package.json
display warning for when .yarnrc file exists
display warning for if .npmrc exists
@danielleadams danielleadams marked this pull request as ready for review June 26, 2020 19:55
@danielleadams danielleadams requested a review from a team as a code owner June 26, 2020 19:55
if [[ "$YARN2" == "true" ]]; then
if [[ "$NODE_MODULES_CACHE" == "true" ]]; then
warn "
WARNING- You are using Yarn 2. The buildpack won't cache, because Yarn 2 does not provide node modules.
Copy link

Choose a reason for hiding this comment

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

It does provide a node_modules folder with the node-modules linker https://yarnpkg.com/configuration/yarnrc#nodeLinker

Though it would be faster to cache the actual cache folder which you can get using yarn config get cacheFolder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This warning message should be reworded - so thanks for pointing this out. However, we're not supporting this yet in this first phase.


if $YARN; then
if [[ "$YARN2" == "true" ]]; then
echo "Using Yarn 2, skipping installations."
Copy link

Choose a reason for hiding this comment

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

yarn install would still need to run for dependencies with a postinstall script when using PnP and to create the node_modules folder when using the node-modules linker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right - thanks for pointing this out. The assumption is that the install scripts will not be run for now since install is not run. I made a note in the PR description. We will eventually want to support this, of course, but not in this first draft.

Copy link

Choose a reason for hiding this comment

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

Alright, keep in mind any dependency with a postinstall script wont work. So for example core-js wont be found

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we'll be working on that and keep that in mind. This is a priority. Thanks for the review!

@danielleadams danielleadams force-pushed the feature/yarn2-support branch 4 times, most recently from 8ec552c to 0ea2091 Compare July 13, 2020 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yarn 2 does not work
4 participants