cosmjs: Cosmjs incompatibility with ES2018
Hi everyone, I’m trying to create a new rn project including cosmjs. After the inclusion, if I try to use part of the packages included on cosmjs all works like a charm. However, if I try to import the tendermint-rpc package or the stargate one, the inclusion fails. Giving a few debugging, I saw that the issue is linked to BigInt, which is on this repo, included as a native call (since it is available from ES10).
ReferenceError: Can't find variable: BigInt
Maybe I’m missing something. Is there anyone who could help in including and using cosmjs (fully) inside a React Native project?
Useful information
React native version: 0.68.2 Tested with both cosmjs version: 0.24.0-alpha.25 and latest
Thank you.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 26 (11 by maintainers)
@Giorgionocera Hey man, could you provide a demo that rn uses part of the packages included on cosmjs and it works well. THX! I cannot run rn with cosmjs.
Hi there, after the release of RN 0.70.0, they added support to BigInt in Hermes. Now it is also possible to use the latest releases of CosmJS, to facilitate the creation of an RN project with CosmJS, I have created a template for the react-native CLI.
It is obviously an open source template! You all can use it, and, most importantly, can contribute in improving it!
@Giorgionocera Hello, how to introduce all this package?
But looking back to cosmjs main page it says “Our current Javascript target standard is ES2018” so we should fix it in the main version. Upgrading the target standard from 2018 to 2020 seems a big jump all together. Either recompile from @noble/hashes up using the babel transform or reverting to the previously used (or a new one) hashing library. This is indeed not even an issue related with React Native itself is just that the supported ES standard is different from the supposed officially supported standard.
Maybe you can create a Webpack debug bundle, this contains all dependency code in one file. Thenuse text search for
bigint/BigInt.I think that we are going to get them eventually so going forward I don’t see any problem with starting to use BigInt but as we don’t know when we should fix that in this version first. I will investigate the problem further and get back to you
Could you provide all error output you can get using the latest CosmJS release? As far as I can tell, we don’t use BigInt/bigint directly. It might be a dependency though.
From CosmJS 0.30.0 onwards we target es2020 and make use of BigInt in more and more places. Happy to hear that there are solutins emerging for the React Native ecosystem.
@Giorgionocera I’ll try, thanks for the reply
At least for me that’s the full console log from application start. I have to mention that it happens on the stargate branch of the library. proto-sign for examples works (with rn-nodeify) just fine.
I have the same issue. The full error is:
And I think it could be (but I’m not sure) a dependency because the only place I could find BigInt is the .pnp.cjs file at root generated by yarn. Maybe the package using it has a fallback compatibility mode and the library just needs to be compiled for both environment (the one supporting BigInt and the one that does not).