-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Move react
to peerDependencies
#5813
Conversation
cc @ide |
if (semver.gte(v, '0.21.0') && !pak.dependencies['react']) { | ||
console.log( | ||
chalk.yellow( | ||
'\nYour \'package.json\' file doesn\'t seem to have \'react\' as a dependency.\n' + |
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.
style suggestion: I often use template strings for messages so quotes don't have to be escaped
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.
@ide I was just matching other places in the file. I guess I could update the whole file...are template strings supported everywhere now? (the local-cli isn't run through babel-register)
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.
IIRC they shipped with Node 4
@skevy updated the pull request. |
@skevy updated the pull request. |
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "react-native", | |||
"version": "0.0.0-master", | |||
"version": "0.22.0", |
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 think we want to keep the version here to make it clear we're on master?
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.
This was a remnant of testing in the middle of the night and me being tired. Will fix. :)
Is this still relevant? The CLI is here: https://github.com/facebook/react-native/blob/master/react-native-cli/index.js What happens when people don't run |
return; | ||
} | ||
|
||
this.npmInstall('react', { '--save': true }); |
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.
Does this respect the declared version of React via peerDependencies
(0.14.5)?
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.
very good question, might be worth installing the version we know matches react-native's one, we can get it from RN's package.json's peerDependencies.
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.
+1 to reading the version from RN package.json
I'm not the best person to review this. cc @martinbigio |
…project's dependencies when the react-native version is >= 0.21.0.
@skevy updated the pull request. |
Cool, thanks @skevy! I'll let @martinbigio or @ide merge this as I'm not that familiar with npm. |
I restarted the E2E tests since the failure looked related to the npm repo. Let's get the E2E tests passing and then merge this. We have a bunch of time including a 2-week RC period to shake out issues. |
E2E tests look good. I took a closer look at the Obj-C tests and found that they run the UIExplorer. So @skevy I think we either need to add "npm install react" to travis.yml (hacky solution but has some nice properties, like we install all of RN's dependencies just once) or set up a package.json in each example project and be sure to run something like |
@ide I don't think the obj-c test failed because of this change. It's still installing That's because npm only doesn't install peer deps automatically when it's installing dependencies. When you run |
Snazzy. move fast break things, let's do it |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1964504793775223/int_phab to review. |
1 similar comment
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1964504793775223/int_phab to review. |
Excuse me @ide I think it's "move fast with STABLE INFRA". Get it right. |
In all seriousness though, somebody (@mkonicek?) stop this import. I didn't fix the npm install command in the generator, and would like to do that before this goes to core. |
Eh. nvm. I'll just fix in a follow up diff. This works for now. |
This will get Relay working. We can fix things like getting the react version right shortly after. |
*almost will get Relay working...still waiting on #5084 :( |
9f01f96
Can you elaborate please? @davidaurelio do we need to do anything internally?
@skevy Are you happy with the PR now? Is there a followup we should merge? |
@skevy I'm trying to understand the note about the shrinkwrap file - why not update it as part of this PR? https://github.com/facebook/react-native/blob/master/npm-shrinkwrap.json |
@mkonicek honestly I didn't update the shrinkwrap because I thought that you guys had a process internally that would update the shrinkwrap automatically when deps were changed. I'm not sure where I heard that :) If you don't mind updating it for this change (given that this is already merged in)...and then in the future any PR's I send that change dependencies, I'll make sure I update shrinkwrap. |
The issue with updating shrinkwrap.json (as I understand it) is that FB might not have the correct versions of the modules in trunk, so the shrinkwrap had to be generated by FB. This might be addressed recently by the FB npm package tools. Ideally what would happen is PRs would include npm-shrinkwrap.json, then something inside of FB would run |
This breaks our internal shrinkwrap process @mkonicek @bestander @martinbigio (when using npm3. npm2 is fine) |
@skevy I just created a new app with npm2.
I'm using npm2. When starting the packager using
So it looks like this PR fixed collisions for some use cases but broke them for others (specifically, no one is able to work on their React Native apps if they're using npm 2). |
@skevy tells me this is resolved by facebookarchive/node-haste#33 |
Summary: This PR moves `react` from dependencies to peerDependencies. In general, this would have only been important for those people using packages that depend on `react` and were using [email protected]@3 would automatically de-dupe. However, when facebook#5812 gets merged, dependencies will be scoped to react-native (on both npm@2 & npm@3), thus breaking projects that are using a package like `react-redux` for example, which depends on `react`. There would be two copies of React installed, and due to the use of haste modules in `react`, this would break the packager and cause naming collisions. This PR does three things - 1. Moves the dependency from dependencies to peerDependencies 2. Updates the local-cli to run `npm install react --save` when a new project is initialized. 3. Updates `react-native upgrade` to warn if `react` is not listed in the package.json's dependencies. **Note: This will require a shrinkwrap update.** Closes facebook#5813 Reviewed By: svcscm Differential Revision: D2918380 Pulled By: androidtrunkagent fb-gh-sync-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486 shipit-source-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486
Summary: This PR moves `react` from dependencies to peerDependencies. In general, this would have only been important for those people using packages that depend on `react` and were using [email protected]@3 would automatically de-dupe. However, when #5812 gets merged, dependencies will be scoped to react-native (on both npm@2 & npm@3), thus breaking projects that are using a package like `react-redux` for example, which depends on `react`. There would be two copies of React installed, and due to the use of haste modules in `react`, this would break the packager and cause naming collisions. This PR does three things - 1. Moves the dependency from dependencies to peerDependencies 2. Updates the local-cli to run `npm install react --save` when a new project is initialized. 3. Updates `react-native upgrade` to warn if `react` is not listed in the package.json's dependencies. **Note: This will require a shrinkwrap update.** Closes facebook/react-native#5813 Reviewed By: svcscm Differential Revision: D2918380 Pulled By: androidtrunkagent fb-gh-sync-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486 shipit-source-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486
This PR moves
react
from dependencies to peerDependencies.In general, this would have only been important for those people using packages that depend on
react
and were using [email protected]@3 would automatically de-dupe.However, when #5812 gets merged, dependencies will be scoped to react-native (on both npm@2 & npm@3), thus breaking projects that are using a package like
react-redux
for example, which depends onreact
. There would be two copies of React installed, and due to the use of haste modules inreact
, this would break the packager and cause naming collisions.This PR does three things -
npm install react --save
when a new project is initialized.react-native upgrade
to warn ifreact
is not listed in the package.json's dependencies.Note: This will require a shrinkwrap update.