Skip to content

Instantly share code, notes, and snippets.

@fairchild
Last active December 29, 2015 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fairchild/938ef79ccc2b2a75a65d to your computer and use it in GitHub Desktop.
Save fairchild/938ef79ccc2b2a75a65d to your computer and use it in GitHub Desktop.
simple example of getting babel 6 running
{
"presets": ["es2015"]
}

to run,

npm start

You can not use ES6 import syntax in the same file you register in, so, require it, and then you can use import in the required files.

Alternativley, you could have require babel from the command line instead and load the file directly node -r babel-register hello.js

import webpack from 'webpack'
console.log('hello babel world')
require('babel-polyfill')
require('babel-register')
require('./hello')
{
"name": "babel-strap",
"version": "0.1.0",
"description": "sample repo to show how to setup babel6 and webpack",
"main": "index.js",
"scripts": {
"start": "BABEL_DISABLE_CACHE=1 node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"babel",
"webpack",
"es6",
"example"
],
"author": "Michael Fairchild",
"license": "MIT",
"devDependencies": {
"babel": "^6.3.26",
"babel-core": "^6.3.26",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.3.13",
"webpack": "^1.12.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment