Creating a tree shakable library with rollup Creating a tree shakable library with rollup vue.js vue.js

Creating a tree shakable library with rollup


There are some interesting pitfalls with tree shaking that this article covers that you might be interested in.

Other than that - does your build tooling for your consumer app support pure es modules and have tree shaking capabilities? If so, then i would just make sure your exported files are not doing any 'side-effecty' things that might confuse rollup.

To be on the safe side i would offer direct imports to for each of your components as well as one main index.js that exports them. At least you're giving people who are paranoid of shipping unused code the option ie -

import { Anchor } from "red-components-with-rollup/Anchor";