This is an example repository of a JavaScript library for the Building tree-shakable library with RollupJS article on the Redd Developer portal.
$ git clone https://github.com/Redd-Developer/rollup-tree-shaking.git
$ cd rollup-tree-shaking
$ yarn install
Running the command below will build the library and the consumer application, and verify that the latter doesn't contain any unused modules from the library.
$ yarn test
$ yarn build
Our library is tree-shakable if it's consumer's build only contains the library's modules that were used in the consumer application.
$ yarn build:consumer
Note: This is not something you need to have as a part of your library's setup. This is a verification step of this article.
Inspect the consumer/build/index.js
to see that the unused modules (b.js
, and its funcB
) are not present in the consumer's build.