Consensys / web3js-quorum

30 stars 21 forks source link

Large bundle size #47

Open mfolnovic opened 2 years ago

mfolnovic commented 2 years ago

Having import Web3Quorum from "web3js-quorum"; increases bundle size by a lot.

In my project, before importing it, bundle size was 396.68 KiB / gzip: 115.09 KiB. After importing it, bundle size increased to 1649.67 KiB / gzip: 472.42 KiB.

System information

Client type: Besu Bundler: Rollup

Expected behaviour

Bundle size shouldn't increase that much.

Actual behaviour

Bundle size increases by ~1.2MB uncompressed.

Steps to reproduce the behaviour

In any example project, try building it with and without importing web3-quorum.

mfolnovic commented 2 years ago

I assume the issue is that you are publishing raw source, instead of bundling it (cjs/umd/esm)?

If that's true, I guess this is also why I'm having issues with using web3js-quorum after bundling everything:

Uncaught TypeError: Object prototype may only be an Object or null: undefined
    at Function.create (<anonymous>)
    at privateSubscription.js:234:40
    at index.fed4010a.js:1:637
    at main.tsx:10:1

image

mfolnovic commented 2 years ago

I've managed to make it work by adding build step in web3js-quorum and using bundled library.

Would you be interested in PR that adds this, modeled on how web3.js does it: https://github.com/ChainSafe/web3.js/blob/1.x/webpack.config.js ?