In a new post at the madewithlove blog, Geoffrey Dhuyvetters explains how you can organize your code so a bundler can make it as small as possible.

As an author of (open source) packages, I think you have the responsibility to protect the bundle size of your package consumer. When you publish a package that exports a whole range of modules (for example lodash, ramda, date-fns…) you want to make sure the package is exported in such a way that the consumer of your package (mostly bundlers) can optimize size.

https://madewithlove.be/optimizing-javascript-packages-for-tree-shaking/