You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Parse JS SDK is not really compatible with NativeScript. There is no obvious workaround for this, as it is caused by conflicts with at least crypto-js, and possibly other modules/implementation details. Ideally, there would be compatibility equivalent to that for react-native.
The first part of the problem appears to be due to odd behaviours in crypto-js, which is now "smarter" but is still attempting to provide many functions for many environments -- far more than is actually needed by Parse. Because this is happening deeply within nested dependencies, it is more or less impossible to work around. crypto-browserify does not help, as it is not maintained, and it too pulls in node modules in the service of other functions which Parse doesn't even need.
With react-native, this is not an issue, as special RN modules provide encryption. There are equivalents for NativeScript, so a similar path could be followed.
By the way, I very much doubt this is the whole of the problem. Even when I do mask out crypto, using the browser base results in attempting to inject <script> elements (which doesn't work). The Parse.JS SDK is very coupled to the environment in ways that make it challenging to connect it to anything apart from a browser, node, or React Native.
When using const Parse = require('parse'), even with crypto-browserify, the build fails along the following lines:
WARNING in ./node_modules/bn.js/lib/bn.js 56:15-39
Module not found: Error: Can't resolve 'buffer' in '/Users/stuart/git/repo-native/node_modules/bn.js/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "buffer": false }
@ ./node_modules/create-ecdh/browser.js 2:9-25
@ ./node_modules/create-ecdh/index.js 3:31-51
@ ./node_modules/crypto-browserify/index.js 46:0-43
@ ./node_modules/crypto-js/core.js 53:22-39
@ ./node_modules/crypto-js/enc-utf8.js 4:37-54
@ ./node_modules/parse/lib/browser/CryptoController.js 8:6-35
@ ./node_modules/parse/lib/browser/Parse.js 12:47-76
@ ./node_modules/parse/index.js 1:0-50
@ ./app/app.ts 9:14-30
Feature / Enhancement Description
Somehow, Parse.JS ought to be able to work within NativeScript. There are several paths:
Parallel to and similar to that for React Native -- feels clunky and fuels growth in complexity -- not even convinced that this whole custom build thing is wise anyway
Better initialization, so the crypto libs can be skipped/tweaked before loading, so that we don't load the whole of CryptoJS first and cause build errors before we can get the point of adding custom implementations
Some well-documented way to add webpack configs to create a viable environment
I'd very much prefer not to have to make code changes, and already the react-native support feels overly like stretching responsibility. A truly isomorphic package wouldn't need it. However, I don't know how to even start that. The actual crypto requirement footprint (AFAICT, AES encryption and decryption only) is tiny compared to the effort involved in getting the code to load.
However, if anyone has a recommended approach, I am willing to put effort into implementing something and assembling a pull request.
Example Use Case
Using Parse.JS in a NativeScript app. Any NativeScript app.
Alternatives / Workarounds
I have been unable to devise a reasonable workaround, due to the complexity of juggling webpack, crypto-js, and some others, all of which are attempting to be a little too clever by half.
3rd Party References
No obvious third-party references. But this is frustrating, as it is tantalizingly well-supported for React Native.
The text was updated successfully, but these errors were encountered:
I had the same idea, the current SDK is modular so you can add custom implementations for most of the adapters / controllers. If you want to start a PR, get the test suite to pass for react-native build. I posted an issue here if you can get this to work then the SDK can work for any JS framework. Your initialization idea is something I didn’t consider
New Feature / Enhancement Checklist
Current Limitation
The Parse JS SDK is not really compatible with NativeScript. There is no obvious workaround for this, as it is caused by conflicts with at least
crypto-js
, and possibly other modules/implementation details. Ideally, there would be compatibility equivalent to that forreact-native
.The first part of the problem appears to be due to odd behaviours in
crypto-js
, which is now "smarter" but is still attempting to provide many functions for many environments -- far more than is actually needed by Parse. Because this is happening deeply within nested dependencies, it is more or less impossible to work around.crypto-browserify
does not help, as it is not maintained, and it too pulls in node modules in the service of other functions which Parse doesn't even need.With react-native, this is not an issue, as special RN modules provide encryption. There are equivalents for NativeScript, so a similar path could be followed.
By the way, I very much doubt this is the whole of the problem. Even when I do mask out
crypto
, using the browser base results in attempting to inject<script>
elements (which doesn't work). The Parse.JS SDK is very coupled to the environment in ways that make it challenging to connect it to anything apart from a browser, node, or React Native.When using
const Parse = require('parse')
, even withcrypto-browserify
, the build fails along the following lines:Feature / Enhancement Description
Somehow, Parse.JS ought to be able to work within NativeScript. There are several paths:
I'd very much prefer not to have to make code changes, and already the react-native support feels overly like stretching responsibility. A truly isomorphic package wouldn't need it. However, I don't know how to even start that. The actual crypto requirement footprint (AFAICT, AES encryption and decryption only) is tiny compared to the effort involved in getting the code to load.
However, if anyone has a recommended approach, I am willing to put effort into implementing something and assembling a pull request.
Example Use Case
Using Parse.JS in a NativeScript app. Any NativeScript app.
Alternatives / Workarounds
I have been unable to devise a reasonable workaround, due to the complexity of juggling webpack, crypto-js, and some others, all of which are attempting to be a little too clever by half.
3rd Party References
No obvious third-party references. But this is frustrating, as it is tantalizingly well-supported for React Native.
The text was updated successfully, but these errors were encountered: