First create a folder:
Then CD into that folder through CMD
Then do the follow in command-line
npm init
npm install -g babel-cli
npm install babel-preset-es2015–save-dev
Then create app.js.es6 file
Then use this example code:
class Person {
constructor(name) {
this.name = name;
}
greet(){
return "Hello I am ${this.name}";
}
}
let person = new Person("Tyler");
console.log(person.greet());
babel app.js.es6 –presets2015 | clip
Clip copies the string from commandline. Then you should get the follow code output:
"use strict";
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Person = (function () {
function Person(name) {
_classCallCheck(this, Person);
this.name = name;
}
_createClass(Person, [{
key: "greet",
value: function greet() {
return "Hello I am ${this.name}";
}
}]);
return Person;
})();
var person = new Person("Tyler");
console.log(person.greet());
Now we want to create an index.html file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h2>ES2015</h2>
<script src="app.js"></script>
</body>
</html>
babel app.js.es6 –presets es2015 > 5
Now we are going to create a file called .bablrc this file will shorten the command to compile the babel file
Next we type in this code to make compiling es2015 javascript faster.
babel app.js.es6 > app.js

https://github.com/JasonDeving/babel2015windowssetup