Do not transpile file to use babel

1

Trying to learn the new things that ES6 brings, I am following steps to transpile my first file, but I can not get it; I do not see any error, nothing bad appears when trying to do the operation.

I am following the steps on the page, and follows the same way

npm install -g babel-cli

npm install --save-dev babel-cli

All it does is create a file identical to the one I want to transpile, but with the output name that I want to place.

babel --watch archivo_es6.js --out-file archivo_es5.js

Code

let saludo;

saludo = 'hola
mundo';

console.log(saludo);
    
asked by Pedro Miguel Pimienta Morales 05.07.2017 в 17:23
source

1 answer

2

The code is correct you will only have to add use strict to the beginning of the file to be able to use the pa

Babel has the ability to transpile different versions of ES but you have to define what version you want to do it through the presets to transpile from es6 to es5 first you have to install the es2015 preset      npm install --save-dev babel-preset-es2015

Then create a file .babelrc here you can put all the settings and preset that you occupy.

    {
       "presets": ["es2015"]
    }

And execute the babel --watch archivo_es6.js --out-file archivo_es5.js command again and the result is as follows.

    
answered by 05.07.2017 в 18:54