react-native doesn't want crypto set to an empty module (#14)

React-Native is sort of like a browser, sort of a native environment. On react-native we don't have the browser's crypto implementation, so we need to require react-native-crypto. We can rewrite the module requirement to do that using the extraNodeModules feature in rn-cli.config.js, but the metro packager assumes that if there's a "browser" field in package.json that it's relevant to react-native libraries unless there's also a "react-native" field. Hurray.

Anyway, this silly little patch tells metro not to replace crypto with an empty module but actually to use whatever you currently have crypto set to (which is not solved here, so you'll still have to do that.)
This commit is contained in:
Peter van Hardenberg 2018-03-19 10:58:24 -07:00 committed by Mathias Buus
parent 4e1c69ba13
commit c81ef709d1

View File

@ -17,6 +17,9 @@
"browser": {
"crypto": false
},
"react-native": {
"crypto": "crypto"
},
"scripts": {
"browser": "browserify test.js | browser-run",
"browser-manual": "browserify test.js | browser-run -p 1234",