New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cloneInputAst
option to babel.transformFromAst
#10241
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of this name, since it doesn't tell what it is copying. Maybe cloneInputAst
?
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/24551/ |
That’s a good idea, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR makes it way easier to write codemods using recast (which keepts the original formatting). If we clone the AST, then recast
will see all the output AST nodes as new and completely discard the original source format.
Without this PR, the only way to make it work is to inject the input AST in a pre
or Program
visitor: https://github.com/nicolo-ribaudo/codemods/blob/40e90e3ad6e2db91fd7756bcce68bfefd373a3a3/src/utils.js#L32-L68
cloneInputAst
option to babel.transformFromAst
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8983fe7:
|
@coderaiser I have rebased this PR, since it looks like there were some problems after merging master into this branch. |
@nicolo-ribaudo looks like something wrong on |
It's a node bug, we are investigating it. |
@nicolo-ribaudo Any progress on this :)? |
@coderaiser Can you rebase on |
@JLHwung done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
|
Yeah sorry, we don't run test262 on PRs automatically since often it's not needed. We haven't merged this PR yet just because we are waiting for the next minor release. |
cloneInputAst