EddyVerbruggen / EddyVerbruggen/nativescript-nodeify
crypto-browserify shim is not usable
- Dominant language
- JavaScript
- Stars
- 93
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
I would like to use the `crypto-browserify` module in my code, which should theoretically be possible as this module is fully supported in the browser. Unfortunately, upon loading my app I receive the following error:
```
System.err: ReferenceError: process is not defined
System.err: File: "file:///data/data/com.myapp/files/app/tns_modules/readable-stream/readable.js, line: 2, column: 4
```
I have done a bit of investigative work on this. Here is the chain of imports that lead to this error:
* My app:
* imports `crypto-browserify`
* imports `create-hash`
* imports `ripemd160`
* imports `hash-base`
* imports `stream` -> converted to `stream-browserify`
* imports [`readable-stream`](https://www.npmjs.com/package/readable-stream)
`readable-stream` defines a `browser` field in its [`package.json`](https://github.com/nodejs/readable-stream/blob/master/package.json):
```json
"browser": {
"util": false,
"./readable.js": "./readable-browser.js",
"./writable.js": "./writable-browser.js",
"./duplex.js": "./duplex-browser.js",
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
},
```
However, it would seem that the `nativescript-nodeify` library is ignoring this and falling back to the node.js file, which then fails due to the missing `process` global.
I found this line in the patch script:
https://github.com/EddyVerbruggen/nativescript-nodeify/blob/97df5cc31c2104b698522c45e688badffe5b2d25/patch-npm-packages.js#L73
If I'm reading the code correctly, this script is unable to handle a `browser` field that is an object. Is that correct?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.