Simple client-side project for learning ES6
This tutorial is for those who are not familiar with nodejs, but wants to get started with ES6.
ES6 is not fully supported by all the browsers. So Babel is required to transcompile your ES6 code to ES5, but you don’t need to set up a server side for this. All you need is Babel Standalone
NOTE: Only for learning purposes.
Let us get started
Step 1 : Download Babel Standalone
Step 2 : Create a folder babel-simple and create subfolders app and lib. Copy downloaded babel script to lib. Now the folder structure will be
Step 3 : Create main.js in babel-simple/app.
Step 4 : Create main.css in babel-simple/app
Step 5 : Create index.html in babel-simple. Please note that text/babel
is the type of the script tag that loads main.js.
That’s it. You are ready. Open index.html in a browser.
If your browser is giving cross origin errors, use Firefox, or you can set up a minimal server with nodejs and http-server.
Output
What you can do with this
- Get started with ES6
- Learn basics
- Write single module ES6 app
What you can’t do with this
- Code cannot be split
- Modules cannot be loaded
- Not able to directly debug
UPDATE: For setting up an ES6 project with support for loading modules at runtime, please see the post ES6 , Babel and JSPM - The Super Combo #1