https://github.com/magicmark/tiny-treeshaker
🌳🥤 A tiny codemod for tree shaking (experimental) 🌳🥤
https://github.com/magicmark/tiny-treeshaker
codemod javascript jscodeshift
Last synced: 7 months ago
JSON representation
🌳🥤 A tiny codemod for tree shaking (experimental) 🌳🥤
- Host: GitHub
- URL: https://github.com/magicmark/tiny-treeshaker
- Owner: magicmark
- Created: 2021-06-20T03:47:32.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-10T10:45:22.000Z (almost 5 years ago)
- Last Synced: 2025-04-07T06:36:02.509Z (about 1 year ago)
- Topics: codemod, javascript, jscodeshift
- Language: JavaScript
- Homepage:
- Size: 64.5 KB
- Stars: 94
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🌳🥤 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](https://github.com/facebook/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
- https://github.com/coderaiser/putout
- https://github.com/smeijer/unimported