Manipulating AST with JavaScript using Babel

Tan Li Hau
0 ratings
Hi, I'm Li Hau. I contributed to several open source projects, babel, terser, and I am currently a core maintainer of SvelteWorking on these projects make me realise the importance of knowing about AST and how to manipulate them.

What you are getting

Learning about what is an AST (Abstract Syntax Tree) and how to use it allows you to 

  • Analyse your code
  • Write codemods to quickly refactor your code
  • Be familiar with modern toolings, such as webpack, babel, eslint, ... which uses AST internally.

In this video course, I'm going to show you step-by-step, my personal workflow, writing a codemod to refactor code, by manipulating AST.

I'll show you around, how to use the ASTExplorer, how to quickly prototyping a Babel plugin within the ASTExplorer, and then use it within a script.

Through this video, you'll be able to write a script to manipulate AST yourself.


  • Intro - 0:00
  • Prototyping using ASTExplorer - 02:16
  • Exploring the AST - 07:37
  • Writing the AST transformer - 11:26
  • Setting up the codemod - 25:10
  • Handling scope in the AST - 38:40
  • Ending - 57:37

Duration: 58 minutes

Q & A

After I published the course, I've received some questions, and for the benefit of everyone, I've recorded my answers to each of them:

  • 1. Is there a spec documentation for Babel AST?
  • 2. What is the difference between FunctionDeclaration and FunctionExpression?
  • 3. What if you want to transform a node that is within a context of another node?
  • 4. Is there other ways to replace a node besides replaceWith?
  • 5. Can Babel scope bindings tracked across files?
  • 6. What is Scope and Binding? What can you do with them? How do you update the bindings after you modify the AST?

And if you have more questions, please do send me an email, I'm happy to answer all of them!

Refund policy

If you're not 100% satisfied with the purchase, or it's not what you were expecting, just reply to the download email within 30 days, and you'll get a full refund. No questions asked.


Do I need to know anything about AST?

No. Knowing about AST is not a prerequisite.

Powered by


Manipulating AST with JavaScript using Babel

Enter your info to complete your purchase of Video Course


or pay with
You'll be charged US$15.