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

fix(react-scripts): add missing peer dependency react and update react-refresh-webpack-plugin #9872

Merged
merged 5 commits into from
Jan 13, 2021

Conversation

merceyz
Copy link
Contributor

@merceyz merceyz commented Oct 23, 2020

What's the problem this PR addresses?

  • react-scripts has a missing peer dependency on react
  • react-scripts depends on a version of @pmmmwh/react-refresh-webpack-plugin which doesn't resolve the imports it injects causing projects to rely on hoisting to bring react-refresh to the root node_modules folder which is not guaranteed.
  • The templates lack a dependency on eslint-config-react-app making it also rely on hoisting.
    Delayed for another time

Read https://yarnpkg.com/advanced/rulebook#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies for more in depth information about hoisting.

Fixes https://github.com/yarnpkg/berry/runs/1299440256#step:5:132
Fixes #9446
Fixes pnpm/pnpm#2957
Closes #9671

How did you fix it?

@facebook-github-bot
Copy link

Hi @merceyz!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, 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.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@merceyz merceyz marked this pull request as draft October 23, 2020 20:00
@merceyz merceyz changed the title fix(react-scripts): add missing peer dependency react fix(react-scripts): add missing peer dependency react and update react-refresh-webpack-plugin Oct 23, 2020
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@arcanis
Copy link
Contributor

arcanis commented Nov 11, 2020

Ping @iansu? It causes both our CRA and Storybook tests to fail, which decreases our coverage

@iansu iansu added this to the 4.0.1 milestone Nov 11, 2020
@iansu iansu modified the milestones: 4.0.1, 4.0.2 Nov 23, 2020
@merceyz merceyz mentioned this pull request Nov 24, 2020
@iansu
Copy link
Contributor

iansu commented Jan 6, 2021

@arcanis @merceyz we discussed this issue in the maintainers meeting today. In general we're fine with this change. Adding the react peer dependency and the dependency on @pmmmwh/react-refresh-webpack-plugin in react-scripts is no problem.

The eslint-config-react-app one is a bit problematic though. If we were to include it in the template and someone created a new project the versions would match in react-scripts and their project. But if they later updated react-scripts (which is how we recommend people upgrade) then the versions would no longer match. The ESLint config also has a number of peer dependencies which might have to be added to the template and we'd like to avoid that.

We are open to ideas on how to make this work.

@arcanis
Copy link
Contributor

arcanis commented Jan 6, 2021

Awesome, thanks 🙏

The eslint-config-react-app one is a bit problematic though. [...] We are open to ideas on how to make this work.

Understandable. I can see two alternatives, what do you think?:

Peer deps

  • move the eslint configuration into react-scripts (for instance react-scripts/eslint.js)
  • add a peer dependency on react-scripts to eslint-config-react-app
  • turn eslint-config-react-app into module.exports = require('react-scripts/eslint')
  • add eslint-config-react-app as dependency on the template

Require.resolve

  • add a react-scripts/eslint-config.js like this: module.exports = require.resolve('eslint-config-react-app')
  • rename the template .eslintrc.json into .eslintrc.js
  • turn ["react-app"] into [require('react-scripts/eslint-config')]

Note that we can also do a bit of both: move eslint-config-react-app inside react-scripts and use the exported require.resolve trick to provide the right path to the eslintrc.

@merceyz
Copy link
Contributor Author

merceyz commented Jan 13, 2021

@iansu Alright, I've reverted the eslint changes so that can be tackled in a seperate PR to allow the other changes to be merged

@iansu iansu merged commit a504e9d into facebook:master Jan 13, 2021
@iansu
Copy link
Contributor

iansu commented Jan 13, 2021

@merceyz Thanks!

@arcanis I'm discussing these options with the other maintainers to see what they think. I don't think we want to move the ESLint config into react-scripts though because it is used on its own in other projects.

@merceyz merceyz deleted the merceyz/dependency-issues branch January 13, 2021 23:56
blackarctic added a commit to blackarctic/create-react-app that referenced this pull request Apr 29, 2021
* Fix noFallthroughCasesInSwitch/jsx object is not extensible (facebook#9921)

Co-authored-by: Konstantin Simeonov <[email protected]>

* Add logo license to README

* Remove trailing space in reportWebVitals.ts (facebook#10040)

* docs: add React Testing Library as a library requiring jsdom (facebook#10052)

Co-authored-by: Ian Schmitz <[email protected]>

* Increase Workbox's maximumFileSizeToCacheInBytes (facebook#10048)

* Create FUNDING.yml

* replace inquirer with prompts (facebook#10083)

- remove `react-dev-utils/inquirer` public import

* Prepare 4.0.1 release

* Prepare 4.0.1 release

* Publish

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* chore: bump web-vital dependency version (facebook#10143)

* chore: bump typescript version (facebook#10141)

Co-authored-by: Ian Schmitz <[email protected]>

* Add TypeScript 4.x as peerDependency to react-scripts(facebook#9964)

* remove chalk from formatWebpackMessages (facebook#10198)

* Upgrade @svgr/webpack to fix build error (facebook#10213)

Co-authored-by: Ian Schmitz <[email protected]>

* Improve vendor chunk names in development (facebook#9569)

* Update postcss packages (facebook#10003)

Co-authored-by: Ian Schmitz <[email protected]>

* Recovered some integration tests (facebook#10091)

* Upgrade sass-loader (facebook#9988)

* Move ESLint cache file into node_modules (facebook#9977)

Co-authored-by: Ian Schmitz <[email protected]>

* Revert "Update postcss packages" (facebook#10216)

This reverts commit 580ed5d.

* Remove references to Node 8 (facebook#10214)

* fix(react-scripts): add missing peer dependency react and update react-refresh-webpack-plugin (facebook#9872)

* Update using-the-public-folder.md (facebook#10314)

Some library --> Some libraries

* docs: add missing override options for Jest config (facebook#9473)

* Fix CI tests (facebook#10217)

* appTsConfig immutability handling by immer (facebook#10027)

Co-authored-by: mad-jose <[email protected]>

* Add support for new BUILD_PATH advanced configuration variable (facebook#8986)

* Add opt-out for eslint-webpack-plugin (facebook#10170)

* Prepare 4.0.2 release

* Publish

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* tests: update test case to match the description (facebook#10384)

* Bump webpack-dev-server 3.11.0 -> 3.11.1 (facebook#10312)

Resolves facebook#10084 security vulnerability in websocket-driver library version 0.5.6, imported transitively by sockjs

* Upgrade eslint-webpack-plugin to fix opt-out flag (facebook#10590)

* update immer to 8.0.1 to address vulnerability (facebook#10412)

Resolves facebook#10411

Bumps immer version to 8.0.1 to address the prototype pollution
vulnerability with the current 7.0.9 version.

* Prepare 4.0.3 release

* Update CHANGELOG

* Publish

 - [email protected]
 - [email protected]
 - [email protected]

Co-authored-by: Ryota Murakami <[email protected]>
Co-authored-by: Konstantin Simeonov <[email protected]>
Co-authored-by: Ian Sutherland <[email protected]>
Co-authored-by: sho90 <[email protected]>
Co-authored-by: Anyul Rivas <[email protected]>
Co-authored-by: Ian Schmitz <[email protected]>
Co-authored-by: Jeffrey Posnick <[email protected]>
Co-authored-by: Evan Bacon <[email protected]>
Co-authored-by: Sahil Purav <[email protected]>
Co-authored-by: Hakjoon Sim <[email protected]>
Co-authored-by: Chris Shepherd <[email protected]>
Co-authored-by: Jason Williams <[email protected]>
Co-authored-by: Jabran Rafique⚡️ <[email protected]>
Co-authored-by: John Ruble <[email protected]>
Co-authored-by: Morten N.O. Nørgaard Henriksen <[email protected]>
Co-authored-by: Sergey Makarov <[email protected]>
Co-authored-by: EhsanKhaki <[email protected]>
Co-authored-by: Kristoffer K <[email protected]>
Co-authored-by: Aviv Hadar <[email protected]>
Co-authored-by: Tobias Büschel <[email protected]>
Co-authored-by: mad-jose <[email protected]>
Co-authored-by: mad-jose <[email protected]>
Co-authored-by: Andrew Hyndman <[email protected]>
Co-authored-by: Brody McKee <[email protected]>
Co-authored-by: James George <[email protected]>
Co-authored-by: Dion Woolley <[email protected]>
Co-authored-by: Walker Clem <[email protected]>
wombleton pushed a commit to AurorNZ/create-react-app that referenced this pull request Jun 1, 2021
@benderillo
Copy link

@iansu @arcanis
This is probably an old thread but I don't know where to start digging and it is the end of 2022 but people are still having troubles with new yarn and create-react-app.

Here is the problem:
running yarn create react-app my-app with latest yarn (say v3.2.3) creates an app that is not in working state.
Try to run it and make any changes and you get an error that "react-app" eslint extension is not found.

So far the most sensible workaround was to install eslint-config-react-app and modifying .yarnrc.yml to explicitly tell react-scripts to use it. Like explained here: #10463 (comment)

It works but the fact that people have to google for a solution is wrong: not everyone will find it, others will find wrong solutions, etc.

I am a bit puzzled what happened with the discussion here about eslint-config-react-app.

  • Is there a plan to solve it officially so users won't have to scratch their heads figuring it out on their own?
  • Perhaps there is a documentation update needed to reflect the current "broken" state of things?

abhiisheek pushed a commit to abhiisheek/create-react-app that referenced this pull request May 19, 2023
abhiisheek pushed a commit to abhiisheek/create-react-app that referenced this pull request May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants