Introduction to Transpiling

suggest change

Examples

ES6/ES2015 to ES5 (via Babel):

This ES2015 syntax

// ES2015 arrow function syntax 
[1,2,3].map(n => n + 1);

is interpreted and translated to this ES5 syntax:

// Conventional ES5 anonymous function syntax 
[1,2,3].map(function(n) {   
    return n + 1; 
});

CoffeeScript to JavaScript (via built-in CoffeeScript compiler):

This CoffeeScript

# Existence:
alert "I knew it!" if elvis?

is interpreted and translated to JavaScript:

if (typeof elvis !== "undefined" && elvis !== null) {
  alert("I knew it!");
}

How do I transpile?

Most compile-to-JavaScript languages have a transpiler built-in (like in CoffeeScript or TypeScript). In this case, you may just need to enable the language’s transpiler via config settings or a checkbox. Advanced settings can also be set in relation to the transpiler.

Babel is the usual transpiler from newer ECMAScript syntax to older syntax. It does not polyfill new library features such as Promise or Map. Those still need a separate polyfill.


Why should I transpile?

The most cited benefits include:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents