originalgremlin / react-native-browser-builtins

Browser altenatives to built-in node.js modules for React Native.
MIT License
6 stars 3 forks source link

using a browserify working npm package into react-native? #1

Open ramsestom opened 8 years ago

ramsestom commented 8 years ago

Hi

I am trying to use this npm package into react-native: https://github.com/node-xmpp/node-xmpp/tree/master/packages/node-xmpp-client but it do not work as is raise some exception (Like: Requiring unknown module "crypto") This package is supposed to be working in browsers with browserify though. So do you think using react-native-browser-builtins I could make it work into react-native? Does react-native-browser-builtins allow to bring all browserify functionnalities into react-native? If so, how should I include it into my react-native app? Thanks for your help

originalgremlin commented 8 years ago

Hi ramsestom. Yes, the hope is that this package will allow you to use anything that can be browserified in react-native. The packages I use for my own work are all okay, but there are literally thousands of npm packages out there that I haven't tried - including node-xmpp-client. Try including "react-native-browser-builtins": "^2.0.1" in your package.json file. That should allow the react-native packager to find all the polyfills required to make your node modules work.

ramsestom commented 8 years ago

Thanks for your prompt reply. I included the dependency line into my package.json file and performed an npm install but I still have this error: Requiring unknown module "crypto".If you are sure the module is there, try restarting the packager or running "npm install". Do I need to do something else apart from declaring react-native-browser-builtins as a dependency? (like a requiere somewhere in my main component class or something?)

EDIT: I just saw in one of your commit a reference to stanza.io . Are you successfully using it in react-native? If yes do you have a small example of a react-native app using it (just an app that perform a login to an XMPP server)? Because I am trying to use a js XMPP library inside react-native (already tried strophe.js with no success because it rely on the "document" and "window" DOM elements that are not correctly supported by react-native) and I am now trying node-xmpp but stanza.io could be a good solution too...

originalgremlin commented 8 years ago

Sorry, but I can't get it to work with node-xmpp-client or stanza.io either. At one point we were using stanza.io successfully with react native before we switched to a non-xmpp chat protocol. This library depends fairly heavily on how the react-native packager searches for and interprets "@provides" commands. The packager is poorly documented and has a tendency to change its internals without notice. I can see that the last time I updated it was for react-native 0.17, and the current version is 0.30. I'd almost expect something to go haywire since then. My advice is to try stanza.io.

MattFoley commented 7 years ago

Have there been any updates here? Will this library allow support for stanza.io in the current version of React Native, or any versions more recent than 0.17?

philikon commented 7 years ago

See https://github.com/philikon/ReactNativify for an approach to getting many third party Node modules to work in React Native.