web3 lib optimizations
According to https://github.com/web3/web3.js/issues/6861 two biggest packages are Accounts and Eth. Discussed in today's team call: in next major version for main web3 package size reduction:
- Remove reexporting
eth-accounts&walletfrom main web3 package:
-
keep this as part of mono-repo & also on npm so it will be available for users to use, as most of time DApp users inject 3rd party wallet instead of web3-wallet functionality, and for common accounts functions these will be available in this package directly instead of reexported and using via\by main web3.
-
more good UX for using web3-wallet/accounts like when creating web3 instance users can explicitly set provider and wallet as two different objects , this should be documented
-
explore option of creating feature as well for allowing modification of accounts and wallet functions in web3 core via plugins ( like plugins can set providers and modify requests via middleware )
-
Removing reexporting following packages: Eth-Personal, IBAN, NET, and see possibility of same for other non-frequently used packages that can contribute to size reduction.
-
Remove redundant code from web3-eth rpc functions , and define one function that takes rpc function ( string, params, validation schema, .etc ) and generate RPC function
other optimizations from https://github.com/web3/web3.js/issues/6861 :
common : 7.8 %
tx: 4.9%
common and tx adds 12.7% in lib so parts of these if not used should be removed and incase if it cannot be done then this functionality should be implemented in lib instead of as these were moved from ethjs/tx to web3.js. This will help to decrease around 12% size. If removing code that was moved from ethjs/tx is planned , use https://github.com/noble directly for signing in web3 lib.
EDIT by @krzysu: did you mean https://paulmillr.com/noble/ ?
2nd largest package is web3-eth, and
web3_eth.js is 5.4%
RPC method wrappers is 2.4% : this file should be removed and rpc methods should be used directly in web-eth class
web3-errors is 5.4% and in that errors is 4.4% , this should be optimised.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.