es6
file with babel CLIGiven the details below: what's going wrong?
$ node --version
v5.0.0
$ npm --version
3.3.6
$ npm init
$ npm install --save-dev babel-cli
$ echo -e 'import url from "url"\nconsole.log(`2+2=${2+2}`)' > script.js
$ ./node_modules/.bin/babel script.js
import url from "url";
console.log(`2+2=${ 2 + 2 }`);
In other words: I put in ES6 and I get out ES6 (albeit with slightly different spacing, and semicolons added). I'm expecting to see imports converted to requires, and to see my back-ticks disappear.
That is: I want ES5 out.
Babel version 6 ships "without any default transforms". You can read more about the changes in this blog post
To transpile es6 to es5 you will need to do the following:
run npm i --save-dev babel-preset-es2015
Create a .babelrc
file in the root of your project with the following:
{
"presets": ["es2015"]
}
There's a lot of configuration you can do on top of that, but that should atleast get you started.