What is Babel?

Babel is a tool to help us transpile newer versions of JavaScript code such as ES6 into older versions of JavaScript — it even helps you transpile TypeScript.

Babel reads the source code based on the configs you define for it and compiles newer JavaScript features such as arrow functions or optional chaining. This happens with Babel’s three major tools:

  • First, Babel’s parser takes the JavaScript code and converts it to an Abstract Syntax Tree (AST) which is the structure of the source code understandable by the computer
  • Next, Babel’s traverser takes the AST, explores it and modify it to the intended code we defined in our Babel configs
  • Lastly, Babel’s generator will translate the modified AST back to the regular code

#babel #javascript #web-development

Babel vs. SWC: Why You Should use SWC (and not Babel)
20.75 GEEK