HSLdevcom / react-native-proto

A prototype app in React Native
5 stars 0 forks source link

Investigate running NodeJS / Express locally #33

Open tuukka opened 7 years ago

tuukka commented 7 years ago

This would help e.g. running Digitransit UI locally.

0is1 commented 7 years ago

Well, there's some hacks that try to enable node.js core modules and their dependencies in RN see: https://github.com/mvayngrib/rn-nodeify or https://github.com/philikon/ReactNativify

But there are limitations and concerns like

So I'm not so convinced about this approach.

And I'm not sure if it's even possible to run modules like express in RN, even in theory? Because for example http module is rewritten by https://github.com/jhiesey/stream-http and you don't obviously have there things like http.createServer (what you need with express) because RN runtime is basically Safari/Chrome browser.

wswoodruff commented 7 years ago

@0is1 Have you tried using babel-plugin-rewrite-require or babel-plugin-module-alias to let you require browserify Node package shims? Since babel is separate from react-native it seemed like the best solution to me. Here's and example with rewrite-require: https://github.com/philikon/ReactNativify/issues/4#issuecomment-312136794

and here's an example with module-alias: https://github.com/wswoodruff/strangeluv-native/blob/master/.babelrc

wswoodruff commented 7 years ago

As for running Express locally, not sure how that would benefit you guys.