-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
fix(create-react-app): improve Yarn 2+ support #12366
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
base: main
Are you sure you want to change the base?
Conversation
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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
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
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}`; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@iansu Ping. I think it is important to improve user experience for Yarn 2+ users |
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+. Howeveryarn dlx
cli command which become available in Yarn 2+ only gets routed to Yarn 2+ bycorepack
.When the user has
corepack
enabled and executesyarn 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 intopackageManager
field ofpackage.json
in the generated app.corepack
usespackageManager
field and routes all theyarn ...
command to the Yarn version specified in this field.Credits should go to @merceyz for the
process.env.npm_config_user_agent
idea.