🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

tree-shake

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree-shake

Test if a package is 100% tree-shakeable

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
13
18.18%
Maintainers
1
Weekly downloads
 
Created
Source

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?

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

More resources on JS modules

Please feel free to ask any question/ submit PR!

Keywords

tree-shake

FAQs

Package last updated on 15 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts