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

packaging in React Native #391

Closed
mvayngrib opened this issue Jul 30, 2015 · 5 comments
Closed

packaging in React Native #391

mvayngrib opened this issue Jul 30, 2015 · 5 comments

Comments

@mvayngrib
Copy link
Member

"browser" in package.json is too restrictive for environments like react-native, where there is a lot more functionality available. For example, in our project (tradle), we're currently manually changing webtorrent's package.json to allow fs-storage and bittorrent-dht use.

browserify and react-native packager don't currently support the alt browser field (see "chromeapp"), but this would be a great module to lead the way to its support. It'll also be a good way to get a foothold in the React Native community.

I'm proposing to add another mapping to package.json alongside "browser":

"browser": {
  "./lib/fs-storage": false,
  "./lib/server": false,
  "bittorrent-dht/client": false,
  "load-ip-set": false,
  "ut_pex": false
}, 
"react-native": {
// all of the above can probably work in React Native
// though fs-storage will need to lose the fs.existsSync line
}

If this sounds interesting, I can add similar blocks to bittorrent-dht, etc, which can benefit from react-native-udp and react-native-level-fs and other node core shims coming.

@feross
Copy link
Member

feross commented Jul 30, 2015

Have you had any luck using browserify -r udp:react-native-udp script.js to replace all places where udp is required? Or does the "browser" field take precedence here?

I also want to make a chrome extension/app version of webtorrent, and this problem will be important to figure out.

@mvayngrib
Copy link
Member Author

browserify+react-native is not easy today because react native's internal packages break the great laws of require() in the name of brevity. They are moving towards compatibility, and there are hybrid solutions: react-native-webpack-server, which works pretty well with webpack+react-native packager, and react-native-browserify-server, which I adapted from the webpack one, but which is reaaaaallly slow. Basically they split up the work between browserify/webpack and the react-native packager. There may be one or two others.

Re: chromeapp, when we were running in that env, we were also stuck with hacking package.json or configuring browserify. I'd rather see more explicit mappings in package.json though. The "browser" field is a good and widely accepted fallback for a non-desktop environment, but that's really what it is - a fallback. If you are able to make a more env-specific mapping - chromeapp, react-native, firefox app, etc., you should be able to.

@vespakoen
Copy link

Working on supporting this natively: facebookarchive/node-haste#46

@feross
Copy link
Member

feross commented Mar 16, 2016

Cool, will close this issue here.

@feross feross closed this as completed Mar 16, 2016
@lock
Copy link

lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants