Bundles are big
See original GitHub issueI’ve been finding that bundles with cosmjs tend to be pretty big (600k+), much of which appears to be due to the dependency on libsodium.
Here’s an example from a recent (next.js) build:
yarn why libsodium
yarn why v1.22.17
[1/4] Why do we have the module "libsodium"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "libsodium@0.7.9"
info Reasons this module exists
- "@cosmjs#cosmwasm-stargate#@cosmjs#crypto#libsodium-wrappers" depends on it
- Hoisted from "@cosmjs#cosmwasm-stargate#@cosmjs#crypto#libsodium-wrappers#libsodium"
info Disk size without dependencies: "508KB"
info Disk size with unique dependencies: "508KB"
info Disk size with transitive dependencies: "508KB"
info Number of shared dependencies: 0
Done in 0.52s.
It seems cosmjs’s dependency on libsodium comes from this import.
I wonder: is it possible to optimize our use of libsodium to minimize its footprint, or at least make it more amenable to optimization by static analyzers?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Big O Bundlez
Big O Bundlez hair boutique have a variety of items including Bundlez, Frontalz, Closurez, Frontal Wigs and for same day ... BigOBundlez Body...
Read more >Small Bundles, Fast Pages: What To Do With Too Much ...
Large amounts of JavaScript negatively affect site speed in two distinct phases: During page load: big bundles take longer to download. During ...
Read more >JavaScript Bundles Are Too Big : Break Up The Libraries
It is far better to bundle 100+ distribution files than one big fat 200+KB bundle where probably like 5% of features are probably...
Read more >Does my bundle look big in this? - LogRocket Blog
Does my bundle look big in this? Where do we want to get to? The code below is bundled with Rollup. Rollup has...
Read more >How CommonJS is making your bundles larger - web.dev
CommonJS modules are very dynamic, which prevents JavaScript optimizers and bundles perform advanced optimizations over them.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for bringing this up. This ticket triggered many dependency removals in https://github.com/cosmos/cosmjs/milestone/14, the module type discussion in #1004 and the libsodium replacement discussion in #1031. I think with those more specific ticket, we can close here.
Making CosmJS faster and lighter but preserving a wide range of targets will be a continous effort.
Happy for any follow-up input in more specific tickets.
If you want to get rid of libsodium in your application, you can have a look at this trick from Keplr:
This is clearly no ideal for maintenance and it can always happen that your app breaks because CosmJS changes. But right now libsodium is only used for wallet related crypto and Ed25519. So it’s an okay trade-off if your app is tested well, production ready and you read CHANGELOGs.