Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’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:

Screen_Shot_2021-10-18_at_9 17 42_AM
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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

webmaster128commented, Feb 8, 2022

Thank you for bringing this up. This ticket triggered many dependency removals in, 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.

webmaster128commented, Jan 21, 2022

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.

Read more comments on GitHub >

github_iconTop 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 -
CommonJS modules are very dynamic, which prevents JavaScript optimizers and bundles perform advanced optimizations over them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found