{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/5985","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/5985/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/5985/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/5985/events","html_url":"https://github.com/facebook/react-native/pull/5985","id":134345228,"number":5985,"title":"Make `providesModuleNodeModules` behavior to be more deterministic.","user":{"login":"skevy","id":131916,"avatar_url":"https://avatars.githubusercontent.com/u/131916?v=3","gravatar_id":"","url":"https://api.github.com/users/skevy","html_url":"https://github.com/skevy","followers_url":"https://api.github.com/users/skevy/followers","following_url":"https://api.github.com/users/skevy/following{/other_user}","gists_url":"https://api.github.com/users/skevy/gists{/gist_id}","starred_url":"https://api.github.com/users/skevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skevy/subscriptions","organizations_url":"https://api.github.com/users/skevy/orgs","repos_url":"https://api.github.com/users/skevy/repos","events_url":"https://api.github.com/users/skevy/events{/privacy}","received_events_url":"https://api.github.com/users/skevy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7"},{"url":"https://api.github.com/repos/facebook/react-native/labels/GH%20Review:%20review-needed","name":"GH Review: review-needed","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2016-02-17T17:23:34Z","updated_at":"2016-02-17T21:44:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/react-native/pulls/5985","html_url":"https://github.com/facebook/react-native/pull/5985","diff_url":"https://github.com/facebook/react-native/pull/5985.diff","patch_url":"https://github.com/facebook/react-native/pull/5985.patch"},"body":"Currently, the `providesModuleNodeModules` option 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 `@providesModule` pragma.\r\n\r\nIn reality, this is not actually the behavior we want.\r\n\r\nNPM, because of how it handles dependencies, can do all kinds of arbitrary nesting of packages when `npm install` is run. This causes a problem for how we deal with `providesModuleNodeModules`. Specifically...take `fbjs`. Currently, React Native relies on using the Haste version of `fbjs` (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.\r\n\r\nReally, the behavior we want is for the packager to treat only a *single* copy of a given package, that we specify in the `Resolver` in the `providesModuleNodeModules` option, as the package that it uses when trying to resolve Haste modules.\r\n\r\nThis PR provides that behavior, by changing `providesModuleNodeModules` from a list of strings to a list of objects that have a `name` key, specifying the package name, as well as a `parent` key. If `parent` is null, it will look for the package at the top level (directly under `node_modules`). If `parent` is specified, it will use the package that is nested under that parent as the Haste module.\r\n\r\nTo 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 underneath `react-native` in node_modules, thus allowing us to specify, for example, that we want to use React Native's copy of `fbjs` (not any other copy that may be installed) as the module used by the packager to resolve any `requires` that reference a module in `fbjs`.\r\n\r\nTest Plan:\r\n\r\n##### npm 2\r\n1) `react-native init` a new project\r\n2) Using npm@2, `npm install --save skevy/react-native#fix-providesModuleNodeModules react@0.14.5`\r\n3) Observe the project compiling correctly, despite multiple copies of `react` and `fbjs` being installed.\r\n\r\n##### npm 3\r\n1) `react-native init` a new project\r\n2) Using npm@3, `npm install --save skevy/react-native#fix-providesModuleNodeModules react@0.14.5`\r\n3) Observe the project compiling correctly, despite multiple copies of `react` and `fbjs` being installed.\r\n\r\n/cc @martinbigio @mkonicek @bestander @davidaurelio @ide"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/185421847","html_url":"https://github.com/facebook/react-native/pull/5985#issuecomment-185421847","issue_url":"https://api.github.com/repos/facebook/react-native/issues/5985","id":185421847,"user":{"login":"facebook-github-bot","id":6422482,"avatar_url":"https://avatars.githubusercontent.com/u/6422482?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook-github-bot","html_url":"https://github.com/facebook-github-bot","followers_url":"https://api.github.com/users/facebook-github-bot/followers","following_url":"https://api.github.com/users/facebook-github-bot/following{/other_user}","gists_url":"https://api.github.com/users/facebook-github-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook-github-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook-github-bot/subscriptions","organizations_url":"https://api.github.com/users/facebook-github-bot/orgs","repos_url":"https://api.github.com/users/facebook-github-bot/repos","events_url":"https://api.github.com/users/facebook-github-bot/events{/privacy}","received_events_url":"https://api.github.com/users/facebook-github-bot/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T21:44:12Z","updated_at":"2016-02-17T21:44:12Z","body":"@skevy updated the pull request."}}