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

Package react-scripts is installed as not a dev dependency #2696

Closed
alexeyraspopov opened this issue Jun 30, 2017 · 13 comments
Closed

Package react-scripts is installed as not a dev dependency #2696

alexeyraspopov opened this issue Jun 30, 2017 · 13 comments

Comments

@alexeyraspopov
Copy link
Contributor

alexeyraspopov commented Jun 30, 2017

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

  1. node -v: 8.0.0
  2. npm -v: 5.0.3
  3. yarn --version (if you use Yarn):
  4. npm ls react-scripts (if you haven’t ejected): 1.0.10
  5. create-react-app --version: 1.3.3

Then, specify:

  1. Operating system: macOS Sierra
  2. Browser and version (if relevant):

Steps to Reproduce

nvm use 8
npm install --global create-react-app
create-react-app test-app
cd test-app
cat package.json

Expected Behavior

Package react-scripts should appear in devDependencies section

Actual Behavior

Package react-scripts appears next to react-dom in dependencies section.

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

@yakhinvadim
Copy link

This is intentional and was made in v1.0.8. See #2657

@Timer
Copy link
Contributor

Timer commented Jun 30, 2017

This is intentional as your application relies on polyfills provided by the package, warrantying a dependency.
As a side effect, deploying to Now and Heroku is easier.

@Timer Timer closed this as completed Jun 30, 2017
@alexeyraspopov
Copy link
Contributor Author

@gaearon, what was the reasoning for this change? I found it pretty confusing (so I opened the ticket) since it's expected behavior after 6+ years of using NPM.

@gaearon
Copy link
Contributor

gaearon commented Jun 30, 2017

It fixes deployment issues on some hosting providers that assume only dependencies are needed for the build. The line is also very thin in frontend development. None of them are "runtime" dependencies because we don't have a server and they all get bundled into a single file. So if we were pedantic then we would have to declare everything as devDependencies, including React itself. I just figured that it's not worth conceptual overhead anyway since distinction is largely arbitrary. For example polyfills could be categorised as either.

@alexeyraspopov
Copy link
Contributor Author

It fixes deployment issues on some hosting providers that assume only dependencies are needed for the build.

Couldn't it be done as just a part of Deployment/Troubleshooting part in README then?

@gaearon
Copy link
Contributor

gaearon commented Jul 4, 2017

Sure, but we generally try for more things to work out of the box.

This is a good example of an issue that can be debated endlessly because there's very little technical arguments for and against. I've made a choice there and if you disagree, you can always move those few lines.

@stevenvachon
Copy link

The polyfills should be moved out to a "react-polyfills" package, then. "scripts" does not imply polyfills.

@gaearon
Copy link
Contributor

gaearon commented Aug 6, 2017

What technical problem are you having?

@stevenvachon
Copy link

Semantics.

@gaearon
Copy link
Contributor

gaearon commented Aug 6, 2017

You can move it in your package.json and then there is no problem.

Again, unless you’re building a Node.js app, the most correct semantics would be to put everything into devDependencies including react and any libraries you’re using. But there are practical reasons why this is undesirable so we just went with the opposite approach.

@stevenvachon
Copy link

stevenvachon commented Aug 7, 2017

react is a dependency because it is included in the final build. A polyfill, such as one for something like <details> would be treated the same. Something like babel is not, and is therefore a devDependency. I'd probably put something like babel-polyfill in devDependencies. With that, react-scripts would follow suit.

@jeremy-ww
Copy link

If you are using npm, run this command will move all packages except React into devDependencies.

$ npm i voy -g && voy mg '^(?!react)'

ym-guotao added a commit to ym-guotao/mini-account that referenced this issue Dec 1, 2017
And for the devDependencies issue, I just found this:
facebook/create-react-app#2696
the conclusion is CRA remove devDependencies on purpose.
@justinmeiners
Copy link

justinmeiners commented Jan 16, 2019

@gaearon I can no longer identify which licenses are used in production and which are just for build tools.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants