JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q48209F
  • License mit

Test if a package is 100% tree-shakeable

Package Exports

  • tree-shake

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tree-shake) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Tree-shake

Inspired by agadoo lib

Is your project 100% tree-shakeable?

With treeshake, you can find out which files and code lines that are not tree-shakeable.

Usage

Simply run npx treeshake in your project root. Make sure you have your entry point defined in package.json under either "module" or "main".

Upon running, you'll get notification whether your code is 100% tree-shakeable or not. If not, it will tell which file(s) are causing/ affected by side-effects and the codes that caused it.

********** reading files **********

     tree88shakey
  TREESHAKEtRe eSha
 kETREESHaKetreeshAKE
TreeShakEY o0o tREeSHAKE
    Es6  /T r eesHakeY
      \///  /Thanks
        \//////
         |||||
         |||||
         |||||
   .....//||||\....
Awesome! Your code is 100% tree-shakeable!

or

********** reading files **********
Unshaken files:

/path/to/your/file.js

/another/path/to/your/file.js

********** reading codes **********
Unshaken codes:
console.log("Side-effects");

********** Finished Reading **********

How do I make my project tree-shakeable?

  1. Use ES6's import and export
  2. As much as possible, not have side-effects

More resources on JS modules


Please feel free to ask any question/ submit PR!