ethereumjs / ethereumjs-monorepo

Monorepo for the Ethereum VM TypeScript Implementation
2.57k stars 746 forks source link

v7: test tree-shaking thoroughly #2718

Open paulmillr opened 1 year ago

paulmillr commented 1 year ago

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.
holgerd77 commented 1 year ago

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 commented 1 year ago

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. 🧑🏽‍💻

roninjin10 commented 1 month ago

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

holgerd77 commented 1 month ago

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! 😂

roninjin10 commented 1 month ago

🤣