kentcdodds / kentcdodds/slice-js
Don't parse the code again when we have the AST
- Dominant language
- JavaScript
- Stars
- 17
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Like [here](https://github.com/kentcdodds/slice-js/blob/1599643fd384c1699f5c82c834656c5ba54ad1c0/src/slice-code/index.js#L29) and [here](https://github.com/kentcdodds/slice-js/blob/1599643fd384c1699f5c82c834656c5ba54ad1c0/src/slice-code/index.js#L37). In those cases the previous call to `babel.transform` returns an object that has the AST which we could transform directly with `transformFromAst`. But I had trouble doing that for some reason...
Another thing that would be cool to figure out, but I had trouble is if we could apply all the plugins at the same time, or at least the dead code elimination ones....
Contributor guide
Research direction
Start in src/slice-code/index.js at the two linked calls around lines 29 and 37. Inspect the AST returned by babel.transform and the use of transformFromAst; done means the existing AST is transformed without parsing the code again. The separate idea of applying plugins together is noted but not scoped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100