ethereumjs-monorepo icon indicating copy to clipboard operation
ethereumjs-monorepo copied to clipboard

v7: test tree-shaking thoroughly

Open paulmillr opened this issue 2 years ago • 5 comments

v7 is near and it would be great to test / optimize tree-shaking with ESM. I've used the following approach to reduce bundle size by 20%:

  1. Create input.js with some basic imports. Execute the command
npm init -y
npm i esbuild
npx esbuild --bundle input.js --outfile=output.js
  1. Check output.js and see which imports are unnecessary.
  2. Add PURE annotations and executable closures to pure exports which look impure to bundlers. This one may be important. See https://github.com/paulmillr/noble-curves/commit/ff5b231e31a2785fdce0e5e55b380a3b303aac64
  3. Build again and check for improvements.

paulmillr avatar May 22 '23 10:05 paulmillr

That makes a lot of sense, thanks for the instruction on this to get started! 🤩

Short procedural note: we have now merged the develop-v7 branch into master (so now basically all we do (unless it goes to maintenance-v6) will make it into the breaking releases, so the target: develop-v7 label is now obsolete.

Will re-label here a bit and delete this label and generally do a quick PR on the docs to make this more clear!

holgerd77 avatar May 22 '23 11:05 holgerd77

Will give this an "urgent" label, would be really nice if someone plays around with this a bit before we are doing the (pre-)releases. 🧑🏽‍💻

holgerd77 avatar Jul 10 '23 09:07 holgerd77

Please let me know if there is anything I can jump in and help with. Happy to contribute

roninjin10 avatar Jul 23 '24 09:07 roninjin10

Please let me know if there is anything I can jump in and help with. Happy to contribute

Thanks, that's nice, guess we are fine right now, we are already causing enough merge conflicts for one another by doing these insane change-the-apis-of-our-most-used-functions-throughout-the-whole-monorepo PRs concurrently! 😂

holgerd77 avatar Jul 23 '24 17:07 holgerd77

🤣

roninjin10 avatar Jul 23 '24 17:07 roninjin10