bitauth / libauth

An ultra-lightweight, zero-dependency TypeScript library for Bitcoin Cash, Bitcoin, and Bitauth applications.
https://libauth.org
MIT License
274 stars 53 forks source link

Is running inside a browser really supported? #114

Closed mariusk closed 8 months ago

mariusk commented 8 months ago

The docs state that it is, and recommends a builder/bundler etc. I'm using vite, and when importing libauth in an otherwise working project I get:

[vite] ✘ [ERROR] Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
[vite]     node_modules/@bitauth/libauth/build/lib/crypto/default-crypto-instances.js:6:53:
[vite]       6 │ ... [sha1, sha256, sha512, ripemd160, secp256k1] = await Promise.all([
[vite]         ╵                                                    ~~~~~

So is it supporte, and if so, what is needed to get it working?

kzKallisti commented 8 months ago

For vite: https://www.npmjs.com/package/vite-plugin-top-level-await

mariusk commented 8 months ago

Thanks, with some messing around with the vite config that works.