tree-shake
Test if a package is 100% tree-shakeable
Last updated 3 months ago by iggredible .
mit · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tree-shake 
SYNC missed versions from official npm registry.

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!

Current Tags

  • 1.0.5                                ...           latest (3 months ago)

6 Versions

  • 1.0.5                                ...           3 months ago
  • 1.0.4                                ...           4 months ago
  • 1.0.3                                ...           4 months ago
  • 1.0.2                                ...           4 months ago
  • 1.0.1                                ...           4 months ago
  • 1.0.0                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 6
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |