Skip to content

Instantly share code, notes, and snippets.

@cef62
Created November 20, 2015 17:05
Show Gist options
  • Save cef62/2be155a44b8fbae3b80a to your computer and use it in GitHub Desktop.
Save cef62/2be155a44b8fbae3b80a to your computer and use it in GitHub Desktop.
How to config babel 6 to transpile async/await (2015-11-20)

Currently Babel 6 require its polyfill to transpile async/await. Must be explicitly installed and required in order to get async/await working.

package.json

"devDependencies": {
    "babel-core": "^6.0.20",
    "babel-polyfill": "^6.0.16",
    "babel-preset-es2015": "^6.0.15",
    "babel-preset-stage-0": "^6.0.15"
}

.babelrc

{
    "presets": [ "es2015", "stage-0" ]
}

app.js

"use strict";

export default async function foo() {
  var s = await bar();
  console.log(s);
}

function bar() {
  return "bar";
}

Main entry file

require('babel-core/register');
require('babel-polyfill');

require('./app.js')();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment