Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🌳πŸ₯€ A tiny codemod for tree shaking (experimental) 🌳πŸ₯€

Notifications You must be signed in to change notification settings

magicmark/tiny-treeshaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

21 Commits

Repository files navigation

🌳πŸ₯€ tiny-treeshaker

A really (ε‰Šι™€) bad (ε‰Šι™€γ“γ“γΎγ§) tiny tree shaker (experimental)

Why?

This is a bare-bones tree shaking codemod that can be adapted for targeting specific use cases.

(I made this cos i'm writing a seperate codemod for a migration I'm working on. The migration removes callsites to a bunch of random helper functions - which now eslint complains about, and I need to remove. Hence this tree shaking codemod.)

Existing solutions are very fancy pants and try and target everything and require complex setups. I want to only target a known set of things to tree shake away. (allowlist vs denylist).

The goal of this is to be:

  • small as possible (while still being "correct". This won't shake away things you use, but may not shake away everything you don't use.)
  • simple to understand / extend / chop and change as needed

Usage

  • Clone this repo
  • Install jscodeshift
  • Run with the CLI (e.g. jscodeshift --transform /path/to/tiny-treeshaker/src/index.mjs ...)

Work in progress

This doesn't shake everything away just yet (sorry!), but gets most of the common cases (i.e. enough to be used when targeting a specific thing)

What you should probably use instead

About

🌳πŸ₯€ A tiny codemod for tree shaking (experimental) 🌳πŸ₯€

Topics

Resources

Stars

Watchers

Forks

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /