A brief talk about Babel#

What is Babel?#

Babel is a JavaScript compiler or a compilation converter from source code to target code.

  • As you can see from this picture, Babel is divided into three stages, namely parse (parsing), transform (conversion) and generate (generation).

  • First, start from the source code on the far left, which is the code we write daily, which will be analyzed by parse. This parse process will perform some analysis such as lexical analysis and grammatical analysis on our code. The operation finally generates an abstract syntax tree called AST.

  • Then come to transform, where the parsed content is processed according to the rules we specified and converted into a new AST abstract syntax tree.

  • Then come to generate and use our converted AST abstract syntax tree to generate new code, which is the target code.

These are the approximate execution flow of Babel.