module.exports = function (babel) {
  var t = babel.types;

  return {
    visitor: {
      Function: function (path) {
        var node = path.node;
        if (! node.async) {
          return;
        }

        node.async = false;

        node.body = t.blockStatement([
          t.expressionStatement(t.stringLiteral("use strict")),
          t.returnStatement(
            t.callExpression(
              t.memberExpression(
                t.identifier("Promise"),
                t.identifier("asyncApply"),
                false
              ),
              [
                t.functionExpression(
                  null, // anonymous
                  node.params.slice(0),
                  node.body
                ),
                t.thisExpression(),
                t.identifier("arguments")
              ]
            )
          )
        ]);
      },

      AwaitExpression: function (path) {
        var node = path.node;
        path.replaceWith(t.callExpression(
          t.memberExpression(
            t.identifier("Promise"),
            t.identifier(node.all ? "awaitAll" : "await"),
            false
          ),
          [node.argument]
        ));
      }
    }
  };
};

@@ -1,8 +1,23 @@
+%22use strict%22;%0A%0A
 module.e
@@ -46,19 +46,21 @@
 el) %7B%0A  
-var
+const
  t = bab
@@ -107,24 +107,40 @@
    Function:
+ %7B%0A        exit:
  function (p
@@ -146,35 +146,39 @@
 path) %7B%0A        
+  
-var
+const
  node = path.nod
@@ -188,16 +188,18 @@
         
+ 
+ 
 if (! no
@@ -220,16 +220,18 @@
         
+  
 return;%0A
@@ -238,16 +238,18 @@
         
+ 
+ 
 %7D%0A%0A     
@@ -255,29 +255,772 @@
     
-node.async = false;%0A%0A
+  // The original function becomes a non-async function that%0A          // returns a Promise.%0A          node.async = false;%0A%0A          const innerFn = t.functionExpression(%0A            null, // anonymous%0A            node.params.slice(0),%0A            node.body%0A          );%0A%0A          if (this.opts.useNativeAsyncAwait) %7B%0A            // The inner function called by Promise.asyncApply should be%0A            // async if we have native async/await support.%0A            innerFn.async = true;%0A          %7D%0A%0A          // Calling the async function with Promise.asyncApply is%0A          // important to ensure that the part before the first await%0A          // expression runs synchronously in its own Fiber, even when%0A          // there is native support for async/await.%0A  
     
@@ -1054,16 +1054,18 @@
 ement(%5B%0A
+  
         
@@ -1130,16 +1130,18 @@
         
+  
 t.return
@@ -1151,16 +1151,18 @@
 tement(%0A
+  
         
@@ -1189,32 +1189,34 @@
 (%0A              
+  
 t.memberExpressi
@@ -1211,32 +1211,34 @@
 mberExpression(%0A
+  
                 
@@ -1270,32 +1270,34 @@
                 
+ 
+ 
 t.identifier(%22as
@@ -1316,32 +1316,34 @@
                 
+  
 false%0A          
@@ -1338,34 +1338,38 @@
 e%0A              
+ 
+ 
 ),
+ %5B
 %0A              %5B
@@ -1367,18 +1367,31 @@
         
-%5B%0A
+    innerFn,%0A  
         
@@ -1400,24 +1400,20 @@
       t.
-function
+this
 Expressi
@@ -1407,32 +1407,34 @@
 .thisExpression(
+),
 %0A               
@@ -1440,94 +1440,81 @@
     
-null, // anonymous%0A                  node.params.slice(0),%0A                  node.body
+t.identifier(%22arguments%22)%0A                %5D%0A              )%0A            )
 %0A   
@@ -1516,32 +1516,27 @@
 )%0A          
-      ),
+%5D);
 %0A           
@@ -1536,119 +1536,206 @@
     
+%7D%0A
       
-  t.thisExpression(),%0A                t.identifier(%22arguments%22)%0A              %5D%0A            )%0A          )
+%7D,%0A%0A      AwaitExpression: function (path) %7B%0A        if (this.opts.useNativeAsyncAwait) %7B%0A          // No need to transform await expressions if we have native%0A          // support for them.
 %0A   
@@ -1739,26 +1739,32 @@
         
-%5D)
+  return
 ;%0A      
 %7D,%0A%0A    
@@ -1751,34 +1751,35 @@
 turn;%0A      
+  
 %7D
-,
 %0A%0A      
 AwaitExpress
@@ -1770,54 +1770,15 @@
     
+ 
-AwaitExpression: function (path) %7B%0A        var
+ const
  nod

Enable native async/await in Node 8.