Skip to content

Commit

Permalink
support react-native field with fallback to browser field
Browse files Browse the repository at this point in the history
Summary: React Native is a lot more powerful an environment than the browser, so we need an alternate mapping, as specified [here](https://github.com/defunctzombie/node-browser-resolve#browser-field)

An example:
```js
{
  "browser": {
     "./lib/server": false
   },
   "react-native": {
     "dgram": "react-native-udp",
     "fs": "react-native-level-fs"
   },
   "chromeapp": {
     "dgram": "chrome-dgram",
     "fs": "level-filesystem"
   }
}
```

on the other hand, if "react-native" is not present in package.json, you should fall back to "browser"

other than the one (nesting) test added, the tests are unchanged, just done for both "react-native" and "browser"

(I've implemented [react-native-udp](https://npmjs.org/package/react-native-udp) and [react-native-level-fs](https://npmjs.org/package/react-native-level-fs), but they obviously don't belong in the traditional "browser" field as they won't run anywhere except in React Native.)
Closes facebook/react-native#2208

Reviewed By: svcscm

Differential Revision: D2691236

Pulled By: vjeux

fb-gh-sync-id: 34041ed50bda4ec07f31d1dc50dcdfa428af2512
  • Loading branch information
mvayngrib authored and facebook-github-bot-2 committed Nov 24, 2015
1 parent 8638b66 commit e88322d
Show file tree
Hide file tree
Showing 2 changed files with 519 additions and 332 deletions.
Loading

0 comments on commit e88322d

Please sign in to comment.