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

Move "react" to be a peer dependency #5541

Closed
ide opened this issue Jan 26, 2016 · 10 comments
Closed

Move "react" to be a peer dependency #5541

ide opened this issue Jan 26, 2016 · 10 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@ide
Copy link
Contributor

ide commented Jan 26, 2016

By moving "react" out of "dependencies" and into "peerDependencies" this unlocks the next level of universal code sharing. Packages like react-redux can have a peer dependency on the same copy of "react" that's used by RN. Short of abusing npm 3's package flattening, I believe this is the proper way forward.

Example package.json:

{
  "dependencies": {
    "react": "^0.14.0",
    "react-native": "^0.20.0",
    "react-redux": "^4.0.0"
  }
}

... and that's it. This would be a breaking change, but the fix is very simple (add "react" to the app's dependencies). With the fbjs patches landing, this will be hopefully the final step to compatibility with React Redux, Relay, and the greater React ecosystem.

@mangogogos
Copy link
Contributor

Definite +1!

@ide
Copy link
Contributor Author

ide commented Jan 26, 2016

This is going to require a bit of work. These are the steps:

  • Move "react" to peerDeps
  • Make react-native-cli add "react" to the dependencies in the package.json file it generates. This is a breaking change to the CLI but I think we have to do it. cc @vjeux
    • Side note: react-native-cli should check for updates to itself and let you know if you need to npm install -g again.
  • Figure out how to run the example projects like UIExplorer. I think the correct but annoying solution is to give each example project its own package.json file that depends on react and react-native.

@vjeux
Copy link
Contributor

vjeux commented Jan 26, 2016

react-native init

Does
npm install react-native
./node_modules/react-native/cli.js install

So we can run arbitrary script that's going to add a peer dependency after the fact and re-run npm install without changing the shell

@ide
Copy link
Contributor Author

ide commented Jan 26, 2016

Nice, that makes things a lot smoother...

@vjeux
Copy link
Contributor

vjeux commented Jan 26, 2016

Yeah, @frantic did a good job designing the global cli such that it is future proof :)

@Proyoyo
Copy link

Proyoyo commented Feb 9, 2016

May I know when this fix will probably be released?

@frantic
Copy link
Contributor

frantic commented Feb 9, 2016

@Proyoyo see #5813

@janicduplessis
Copy link
Contributor

#5813 landed and will be released in 0.22

@janicduplessis
Copy link
Contributor

@facebook-github-bot close

@facebook-github-bot
Copy link
Contributor

@janicduplessis tells me to close this issue. If you think it should still be opened let us know why.

@facebook-github-bot facebook-github-bot added the Ran Commands One of our bots successfully processed a command. label Mar 20, 2016
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants