Skip to content

Conversation

@benjamn
Copy link
Contributor

@benjamn benjamn commented Dec 17, 2013

The https://github.com/benjamn/recast package is similar in spirit to falafel, but it has more convenient tools for checking AST node types and creating new AST nodes, which helps simplify the big if-statement in custom.js and also makes it easier to create the replacement Literal nodes.

If that's not something you particularly care about, then feel free to close this pull request. Just thought I'd make the suggestion!

@andreypopp
Copy link
Contributor

+1 on this.

From recast README:

The magic of Recast is that it reprints only those parts of the syntax tree that you modify.

So this means that in a lot of cases envify won't change formatting and line numbers!

@hughsk
Copy link
Owner

hughsk commented Dec 17, 2013

Ah, fantastic - a few of my transforms have been using escodegen and the reformatting can be pretty frustrating. I'll have a proper look at the changes after work and then it should be good to merge :) It'll probably warrant bumping envify up to 1.0.0 too. Thanks @benjamn!

@benjamn
Copy link
Contributor Author

benjamn commented Dec 17, 2013

Glad you like it! Whatever you decide here, I'm curious to know how recast works for you (for this or anything else).

hughsk added a commit that referenced this pull request Dec 18, 2013
Use Recast for AST modification in custom.js
@hughsk hughsk merged commit 40f67b3 into hughsk:master Dec 18, 2013
@hughsk
Copy link
Owner

hughsk commented Dec 18, 2013

Looks great, merging and publishing to 1.0.0. Thanks again :) recast seems like a nice alternative to falafel, especially with source map support. I'm gonna have a closer look at using it for my other transforms soon, will let you know if I run into anything!

benjamn added a commit to benjamn/react that referenced this pull request Dec 22, 2013
This version uses Recast for source transformation:
hughsk/envify#4
toptaldev92 pushed a commit to toptaldev92/react_project that referenced this pull request Jul 28, 2021
This version uses Recast for source transformation:
hughsk/envify#4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants