cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
647 stars 332 forks source link

Find strategy to remove libsodium being bundled #1478

Open ValarDragon opened 1 year ago

ValarDragon commented 1 year ago

Currently libsodium is brought in for 2 imports:

But neither of these code utilities are used by most apps. I cant even see usage of these within cosmJS. This is causing a large import to appear in our bundles. (190kb gzipped, 500kb after parsing)

I'm new to the JS ecosystem, so these are two options I see right now:

This seems from my (very not robust) testing, to not be handled with tree-shaking in turbo right now, for an app that uses stargate queries.

webmaster128 commented 1 year ago

Thanks for bringing this up. How do you feel about https://github.com/cosmos/cosmjs/issues/1479?

ValarDragon commented 1 year ago

That sounds great to me! Would love for these to just be deleted from the codebase

paulmillr commented 1 year ago

there's argon2 implementation in noble/hashes which is already bundled, but unused - wasm version can be removed

ed25519 would be almost free if you switch from elliptic to noble/curves, which exposes both secp256k1 and ed25519 with shared code