Uh oh!
There was an error while loading. Please reload this page.
Make providesModuleNodeModules behavior to be more deterministic. - #5985
Make providesModuleNodeModules behavior to be more deterministic.#5985skevy wants to merge 1 commit into
providesModuleNodeModules behavior to be more deterministic.#5985Conversation
facebook-github-bot
commented
Feb 17, 2016
3666826 to
4c84cfbComparemkonicek
commented
Feb 17, 2016
Wow that's a lot of issues :( https://github.com/facebook/react-native/issues?utf8=%E2%9C%93&q=naming+collision+detected First things I asked people on the JS infra team when I joined RN was why Haste existed at all. The answer is the same system worked really well for us in PHP - you can move files around without having to codemod thousands of files importing them for example. Thanks for doing this as well as #5084. |
skevy
commented
Feb 17, 2016
@mkonicek to be clear, I love Haste. We use it at Exponent on internal projects, and I'm working on a project that let's me use it with Node. However, I think where it shines, and why it works for Facebook, is that it's suited particularly to product code. The issue, and the "hard part", is that we have a packager that (currently) has to understand both systems. I know that it's the goal of people (@spicyj, @cpojer, and others) to remove the magic from the packager. This PR specifically is really meant as a stop gap, and to make the behavior that's currently there make a bit more sense and produce more desirable behavior. The end goal, of course, is that this option wouldn't need to exist at all... |
martinbigio
commented
Feb 17, 2016
Thanks for implementing this so quickly! |
martinbigio
commented
Feb 17, 2016
@facebook-github-bot shipit |
facebook-github-bot
commented
Feb 17, 2016
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1680514035538734/int_phab to review. |
skevy
commented
Feb 17, 2016
@ide lol. |
skevy
commented
Feb 17, 2016
@martinbigio can you hold this for the moment? I need to fix some weird issue with the obj-c/android tests. |
martinbigio
commented
Feb 17, 2016
sure |
ide
commented
Feb 17, 2016
@skevy lol sorry about that. my chrome extension must have gone off -_- |
facebook-github-bot
commented
Feb 17, 2016
@skevy updated the pull request. |
1 similar comment
facebook-github-bot
commented
Feb 17, 2016
@skevy updated the pull request. |
sophiebits
commented
Feb 17, 2016
Does this work if you install fbjs and react-native as siblings? Also, it seems like maybe you could use path.resolve instead of manually concatenating |
skevy
commented
Feb 17, 2016
Ok, @martinbigio, I think if you take a look at this and are OK with it we should be good to go. I refactored @spicyj yes, this works if fbjs and react-native are siblings...because now we guarantee that we're using the version of |
facebook-github-bot
commented
Feb 17, 2016
@skevy updated the pull request. |
skevy
commented
Feb 18, 2016
In a holding pattern on this until facebookarchive/node-haste#33 is resolved and merged...then I'll update this PR accordingly with any RN specific changes (most likely will just be the update to the providesModuleNodeModules option in Resolver). |
facebook-github-bot
commented
Feb 18, 2016
@skevy updated the pull request. |
db82b0d to
e06186fComparefacebook-github-bot
commented
Feb 18, 2016
@skevy updated the pull request. |
1 similar comment
facebook-github-bot
commented
Feb 19, 2016
@skevy updated the pull request. |
bestander
commented
Feb 19, 2016
Any ETA on this one? |
158a40e to
b5c5bd8Comparefacebook-github-bot
commented
Feb 19, 2016
@skevy updated the pull request. |
Currently, the
providesModuleNodeModulesoption allows for specifying an array of package names, that the packager will look for within node_modules, no matter how deep they're nested, and treat them as packages that use the@providesModulepragma.In reality, this is not actually the behavior we want.
NPM, because of how it handles dependencies, can do all kinds of arbitrary nesting of packages when
npm installis run. This causes a problem for how we deal withprovidesModuleNodeModules. Specifically...takefbjs. Currently, React Native relies on using the Haste version offbjs(will be resolved in #5084). Thus if npm installs multiple copies of fbjs...which is a very common thing for it to do (as can be seen by this list of issues: https://github.com/facebook/react-native/issues?utf8=%E2%9C%93&q=naming+collision+detected), we get into a state where the packager fails and says that we have a naming collision.Really, the behavior we want is for the packager to treat only a single copy of a given package, that we specify in the
Resolverin theprovidesModuleNodeModulesoption, as the package that it uses when trying to resolve Haste modules.This PR provides that behavior, by changing
providesModuleNodeModulesfrom a list of strings to a list of objects that have anamekey, specifying the package name, as well as aparentkey. Ifparentis null, it will look for the package at the top level (directly undernode_modules). Ifparentis specified, it will use the package that is nested under that parent as the Haste module.To anyone who reads this PR and is familiar with the differences between npm2 and npm3 -- this solution works under both, given the fact that we are now shipping the NPM Shrinkwrap file with React Native when it's installed through
npm. In both the npm2 and npm3 case, node_modules specified by RN's package.json are nested underneathreact-nativein node_modules, thus allowing us to specify, for example, that we want to use React Native's copy offbjs(not any other copy that may be installed) as the module used by the packager to resolve anyrequiresthat reference a module infbjs.Test Plan:
npm 2
react-native inita new projectnpm install --save skevy/react-native#fix-providesModuleNodeModules react@0.14.5reactandfbjsbeing installed.npm 3
react-native inita new projectnpm install --save skevy/react-native#fix-providesModuleNodeModules react@0.14.5reactandfbjsbeing installed./cc @martinbigio@mkonicek@bestander@davidaurelio@ide