Skip to content

Conversation

larixer
Copy link

@larixer larixer commented May 5, 2022

Yarn 2+ getting started instructions advise to use Yarn 2+ via corepack. corepack is shipped with the latest versions of Node 14.x, 16.x and future Node versions. corepack uses Yarn 1.x by default for all the CLI commands that are available only in Yarn 1.x or both in Yarn 1.x and Yarn 2+. However yarn dlx cli command which become available in Yarn 2+ only gets routed to Yarn 2+ by corepack.

When the user has corepack enabled and executes yarn dlx create-react-app, he naturally should expect that the initialized React app will use Yarn 2+. This PR is devoted to make this happen.

The PR gets Yarn version from process.env.npm_config_user_agent and stores it into packageManager field of package.json in the generated app. corepack uses packageManager field and routes all the yarn ... command to the Yarn version specified in this field.

Credits should go to @merceyz for the process.env.npm_config_user_agent idea.

@larixer larixer requested review from iansu and mrmckeb as code owners May 5, 2022 07:01
@facebook-github-bot
Copy link

Hi @larixer!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

1 similar comment
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

};

if (yarnInfo.hasMaxYarnPnp) {
packageJson.packageManager = `yarn@${yarnInfo.yarnVersion}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking the packageManager field should be set regardless of package manager and/or version.

Copy link
Author

Choose a reason for hiding this comment

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

I want to make this change focused on improving Yarn 2+ support, without affecting Yarn 1.x and other package managers at all

@larixer
Copy link
Author

larixer commented May 6, 2022

Note, the CI failures seem unrelated to this PR:
image

@larixer
Copy link
Author

larixer commented May 20, 2022

@iansu Ping. I think it is important to improve user experience for Yarn 2+ users

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

Successfully merging this pull request may close these issues.

3 participants