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

Support Yarn #898

Merged
merged 2 commits into from
Nov 17, 2016
Merged

Support Yarn #898

merged 2 commits into from
Nov 17, 2016

Conversation

fson
Copy link
Contributor

@fson fson commented Oct 12, 2016

Yarn is a new fast, reliable and secure alternative to the npm client.

This pull request adds support for Yarn in Create React App. See discussion in #896.

In the create-react-app command, we try to install packages using Yarn. If Yarn is not installed, we use npm instead. In react-scripts, we detect if the project is using Yarn by checking if a yarn.lock file exists. If the project is using Yarn, all the instructions are displayed with Yarn commands and Yarn is used to install packages in init and eject scripts.

@fson
Copy link
Contributor Author

fson commented Oct 12, 2016

Note: We'll probably want to hold off publishing a version with Yarn enabled until this issue with scripts has been fixed. Currently, with Yarn v0.15.1, the package.json scripts work when it's been installed with npm install -g yarnpkg, but not when it was installed with npm install -g yarn.

@gaearon
Copy link
Contributor

gaearon commented Oct 13, 2016

There was also some issue about optionalDeps not getting installed. We need to make sure fsevents at least tries to get installed, or watcher will be slow.

@fson fson mentioned this pull request Oct 19, 2016
@kentcdodds
Copy link
Contributor

The issues @fson referenced has been fixed I believe. I'm not sure about the fsevents issue however. Anyone know? I'd love to have this support added.

In the `create-react-app` command, try to install packages using Yarn.
If Yarn is not installed, use npm instead.

In `react-scripts`, detect if the project is using Yarn by checking if
a `yarn.lock` file exists. If the project is using Yarn, display all
the instructions with Yarn commands and use Yarn to install packages
in `init` and `eject` scripts.
Run tests both with and without Yarn installed.
@fson
Copy link
Contributor Author

fson commented Oct 29, 2016

Rebased the changes and tested with Yarn 0.16.1. Everything seems to be working now!

I believe the fsevents issue @gaearon was referring to was about optional dependencies not installing (yarnpkg/yarn#628)? It was fixed in yarnpkg/yarn#789. I checked node_modules after installing packages with Yarn and fsevents is there.

screen shot 2016-10-29 at 12 58 06

screen shot 2016-10-29 at 13 00 58

@fson fson added this to the 0.8.0 milestone Oct 29, 2016
@vjeux
Copy link
Contributor

vjeux commented Oct 29, 2016

How long does it take to run create-react-app before and after this pull request?

@gaearon
Copy link
Contributor

gaearon commented Oct 29, 2016

(We'll also want to compare with and without bundledDeps, see #986)

@fson
Copy link
Contributor Author

fson commented Oct 29, 2016

I did a quick benchmark of the time it took to run create-react-app, both with a clean cache and then a second app with a warm cache:

Install method Time
npm 77.1s
npm (2nd app) 68.7s
yarn 49.1s
yarn (2nd app) 25.5s

Here's how I tested:

npm install -g npm@3.10.9 yarn@0.16.1

npm install -g create-react-app@0.6.0
npm cache clean
time create-react-app my-npm-app
time create-react-app my-npm-app-2

npm install -g create-react-app@0.6.0-alpha.e756d73a
yarn cache clean
time create-react-app my-yarn-app --scripts-version 0.7.0-alpha.e756d73a
time create-react-app my-yarn-app-2 --scripts-version 0.7.0-alpha.e756d73a

@gaearon
Copy link
Contributor

gaearon commented Nov 17, 2016

@fson Feel free to merge and release!

@fson fson merged commit bcc469c into facebook:master Nov 17, 2016
@fson fson deleted the yarn branch November 17, 2016 20:55
@fson
Copy link
Contributor Author

fson commented Nov 17, 2016

I'll try to get the next release with this in it out in the next few days.

eXtreme added a commit to eXtreme/create-react-app that referenced this pull request Nov 18, 2016
* pull2:
  Support Yarn (facebook#898)
  Fix chrome tab reuse (facebook#1035)
  Remove unnecessary transform plugins for object spread to work (facebook#1052)
  Clears the usage of react-jsx-source & react-jsx-self (facebook#992)
  Update babel-present-env and use node: 'current' as target (facebook#1051)
  Remove redundant `function` from export statement (facebook#996)
  Add Gatsby to alternatives (facebook#995)
  Allow webpack 2 as peerDependency in react-dev-utils (facebook#963)
  Remove custom babel-loader cache dir config (facebook#983)
  Check for presence of folders before continuing eject. Closes facebook#939. (facebook#951)
  Fixes facebook#952 (facebook#953)
  Always build before deploying to gh-pages (facebook#959)
  Add collectCoverageFrom option to collect coverage on files without any tests. (facebook#961)
  Catch and noop call to open web browser. (facebook#964)
  Gently nudge users towards https by default (facebook#974)
  Enable compression on webpack-dev-server (facebook#966) (facebook#968)
  Add next.js to Alternatives
  Point people to npm Windows instructions
  Encourage people to try recent npm

# Conflicts:
#	packages/react-scripts/config/webpack.config.dev.js
#	packages/react-scripts/package.json
#	packages/react-scripts/utils/createJestConfig.js
jarlef pushed a commit to jarlef/create-react-app that referenced this pull request Nov 28, 2016
In the `create-react-app` command, try to install packages using Yarn.
If Yarn is not installed, use npm instead.

In `react-scripts`, detect if the project is using Yarn by checking if
a `yarn.lock` file exists. If the project is using Yarn, display all
the instructions with Yarn commands and use Yarn to install packages
in `init` and `eject` scripts.
alexdriaguine pushed a commit to alexdriaguine/create-react-app that referenced this pull request Jan 23, 2017
In the `create-react-app` command, try to install packages using Yarn.
If Yarn is not installed, use npm instead.

In `react-scripts`, detect if the project is using Yarn by checking if
a `yarn.lock` file exists. If the project is using Yarn, display all
the instructions with Yarn commands and use Yarn to install packages
in `init` and `eject` scripts.
@aligajani
Copy link

aligajani commented Feb 6, 2017

Okay so do we support yarn yet? Can't see anything on the README.md

@tbillington
Copy link

tbillington commented Feb 6, 2017

I just saw the benchmarks now. It's a little misleading because it will vary largely depending on the machine. With my old mac air is over 2 minutes (linking took 95%) with fully cached deps for a clean install, while as it's less than half that to install on npm even with downloading everything.

Not saying this means it shouldn't use yarn, I definitely prefer it, but it's not always faster 🙂 , especially on lower end machines.

@vjeux
Copy link
Contributor

vjeux commented Feb 6, 2017

@tbillington you should raise this issue on the yarn repo, I'm pretty sure that they would like to hear this data point and potentially try to figure out why it was so slow in this case.

@gaearon
Copy link
Contributor

gaearon commented Feb 6, 2017

I’m optimistic about yarnpkg/yarn#2620, a lot of linking time is due to duplicates.

randycoulman pushed a commit to CodingZeal/create-react-app that referenced this pull request May 8, 2017
In the `create-react-app` command, try to install packages using Yarn.
If Yarn is not installed, use npm instead.

In `react-scripts`, detect if the project is using Yarn by checking if
a `yarn.lock` file exists. If the project is using Yarn, display all
the instructions with Yarn commands and use Yarn to install packages
in `init` and `eject` scripts.
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants