Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !8460
Something went wrong while fetching comments. Please try again.

Fix --use-pnp for Yarn 2

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Nick McCurdy requested to merge github/fork/nickmccurdy/use-pnp into master 5 years ago
  • Overview 3
  • Commits 2
  • Pipelines 0
  • Changes 1

The --use-pnp flag will break Yarn 2 because PnP has been enabled by default and the flag has been removed. This improves user experience by automatically ignoring the flag for Yarn 2, and explaining that it won't be needed in the future.

I've tested this with Yarn 1 and it works normally, though Yarn 2 has a different installation linking system that I couldn't get to work with create-react-app locally.

Compare
  • master (base)

and
  • latest version
    07af204a
    2 commits, 2 years ago

1 file
+ 18
- 4

    Preferences

    File browser
    Compare changes
packages/create-react-app/createReactApp.js
+ 18
- 4
  • View file @ 07af204a

  • Edit in single-file editor

  • Open in Web IDE


@@ -269,17 +269,26 @@ function createApp(
}
} else if (usePnp) {
const yarnInfo = checkYarnVersion();
if (!yarnInfo.hasMinYarnPnp) {
if (yarnInfo.yarnVersion) {
if (yarnInfo.yarnVersion) {
if (!yarnInfo.hasMinYarnPnp) {
console.log(
chalk.yellow(
`You are using Yarn ${yarnInfo.yarnVersion} together with the --use-pnp flag, but Plug'n'Play is only supported starting from the 1.12 release.\n\n` +
`Please update to Yarn 1.12 or higher for a better, fully supported experience.\n`
)
);
// 1.11 had an issue with webpack-dev-middleware, so better not use PnP with it (never reached stable, but still)
usePnp = false;
}
if (!yarnInfo.hasMaxYarnPnp) {
console.log(
chalk.yellow(
'The --use-pnp flag is no longer necessary with yarn 2 and will be deprecated and removed in a future release.\n'
)
);
// 2 supports PnP by default and breaks when trying to use the flag
usePnp = false;
}
// 1.11 had an issue with webpack-dev-middleware, so better not use PnP with it (never reached stable, but still)
usePnp = false;
}
}
@@ -783,7 +792,9 @@ function checkNpmVersion() {
function checkYarnVersion() {
const minYarnPnp = '1.12.0';
const maxYarnPnp = '2.0.0';
let hasMinYarnPnp = false;
let hasMaxYarnPnp = false;
let yarnVersion = null;
try {
yarnVersion = execSync('yarnpkg --version')
@@ -791,6 +802,7 @@ function checkYarnVersion() {
.trim();
if (semver.valid(yarnVersion)) {
hasMinYarnPnp = semver.gte(yarnVersion, minYarnPnp);
hasMaxYarnPnp = semver.lt(yarnVersion, maxYarnPnp);
} else {
// Handle non-semver compliant yarn version strings, which yarn currently
// uses for nightly builds. The regex truncates anything after the first
@@ -799,6 +811,7 @@ function checkYarnVersion() {
if (trimmedYarnVersionMatch) {
const trimmedYarnVersion = trimmedYarnVersionMatch.pop();
hasMinYarnPnp = semver.gte(trimmedYarnVersion, minYarnPnp);
hasMaxYarnPnp = semver.lt(trimmedYarnVersion, maxYarnPnp);
}
}
} catch (err) {
@@ -806,6 +819,7 @@ function checkYarnVersion() {
}
return {
hasMinYarnPnp: hasMinYarnPnp,
hasMaxYarnPnp: hasMaxYarnPnp,
yarnVersion: yarnVersion,
};
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
CLA Signed stale
2
CLA Signed stale
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: facebook/create-react-app!7461
Source branch: github/fork/nickmccurdy/use-pnp

Menu

Explore Projects Groups Snippets