Transpilar is a mixture of compiling and translating. In other words, it is a tool to generate a new version of a given code.
In recent years in JavaScript the language has advanced a lot. As browsers slow down and can not keep up with the pace, solutions have begun to emerge for developers to be able to use the new technologies in the code they write, and then at the time of using that code it will be transpiled into a JavaScript version that browsers accept. Babel is the best example of this, and a practical example would be:
var optionsA = {um: 1};
var optionsB = {...optionsA, dois: 2};
console.log(optionsB);
Using future, approved, or transpilated technologies is:
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var optionsA = { um: 1 };
var optionsB = _extends({}, optionsA, { dois: 2 });
console.log(optionsB);
So compatible with ECMAScript 5.
Adding to this the concept of AST , which allows you to analyze the code and its components, then we can transpile not only different versions of JavaScript but also other languages, raw or not.