Is it possible to convert Babylon parsed AST back to source code after modification?

523 views Asked by At

I was trying to modify JavaScript source code by:

  1. parse source code with @babel/babylon and get the AST
  2. traverse AST with babel-traverse and do some modifications where needed
  3. turn AST back to JavaScript source code

The first two steps is pretty simple. But I stuck on turning AST back to source code.

I did some search, and only find examples to transform AST down to lower version JavaScript code.

Any suggestions?

0

There are 0 answers