Transformers

What are the various transformers?

A transformer is a module with a specific goal that is run against your code to transform it. For example, the es6.arrowFunctions transformer has the very specific goal of transforming ES6 Arrow Functions to the equivalent ES3. This allows transformers to be completely unaware of the other transformations happening so that you can easily chain them together.

ES3

ES5

ES6

ES7 (Experimental)

Disabled by default

These are only usable if you enable staged support. See experimental usage for information.

Other

Optional

Babel also includes some optional transformers for those who want to take their code that extra mile.

These are disabled by default, see usage for instructions on how to enable them.

Usage

require("babel").transform("code", { optional: ["transformerName"] });
$ babel --optional transformerName script.js