scrtlabs / secret.js

The JavaScript SDK for Secret Network
https://secretjs.scrt.network
MIT License
75 stars 40 forks source link

Build to ES module / enable tree shaking #110

Open egasimus opened 2 years ago

egasimus commented 2 years ago

The current dist/browser.js is a monolithic minified CJS bundle.

It is my understanding that this format is only preferable if including SecretJS through a <script> tag -- but when using most forms of frontend build systems (Webpack, etc.) it prevents dead code elimination, considerably inflating the final bundle downloaded by the browser. In my case, secretjs@1.4.3 (and the similarly packaged web3@1.8.0) account for nearly half the total bundle size - and we use just a few methods from the the bank and compute APIs...

I suggest it would be beneficial if the browser field in package.json pointed to an unminified and/or sourcemapped ESM build instead. That way the library users could do their own optimization.

Screenshot from 2022-10-11 03-05-39

assafmo commented 1 year ago

Would love any contribution you can offer!