title: async / await breaks my Webpack build for AWS Lambda; how can I migrate to Node 8.10?
body: <p><em>Note: this is a Q&amp;A on migrating AWS Lambda Webpack builds from v6.10 to v8.10 — no help is needed, but even better answers are of course always encouraged!</em></p>
  
  <hr>
  
  <p>For a while now I have been a disciple of using Webpack to build my back-end Lambdas after reading James Long's excellent series entitled <em>"Backend Apps with Webpack"</em> (<a href="https://jlongster.com/Backend-Apps-with-Webpack--Part-I" rel="nofollow noreferrer">part 1</a>, <a href="https://jlongster.com/Backend-Apps-with-Webpack--Part-II" rel="nofollow noreferrer">part2</a>, and <a href="https://jlongster.com/Backend-Apps-with-Webpack--Part-III" rel="nofollow noreferrer">part3</a>). </p>
  
  <p>Up until recently, the only version of Node.js that <a href="https://aws.amazon.com/" rel="nofollow noreferrer">Amazon Web Services</a> offered was 6.10; you had to write your Lambda fn in the "callback" style. But on April 2, 2018 <a href="https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/" rel="nofollow noreferrer">AWS announced that 8.10 was now supported</a>, and with it the suggested pattern is async / await which is great! Until it immediately broke my Webpack build. After a bit of debugging, I can break my build just by adding one async fn to the Lambda handler (I don't even need to call it):</p>
  
  <pre><code>async function firstAsync() {
    return true;
  }
  
  exports.handler = async (event) =&gt; {
      // TODO implement
      return 'Hello from Lambda!'
  };
  </code></pre>
  
  <p>To be clear, doing this in the AWS Lambda console is perfectly fine, runs great. Webpack even builds it successfully, but upon uploading to AWS Lambda, I get the following error message: <code>regeneratorRuntime is not defined</code>.  My code is below. What am I needing to do?</p>
  
  <p><strong>webpack.config.js</strong></p>
  
  <pre><code>const nodeExternals = require('webpack-node-externals');
  const path = require('path');
  const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
  const webpack = require('webpack');
  
  const config = {
    entry: './src/index.js',
  
    output: {
      path: path.resolve(__dirname, 'dist'),
      library: 'index',
      libraryTarget: 'commonjs2',
      filename: 'index.js'
    },
    target: 'node', // building for a Node environment
    externals: [nodeExternals()], // in order to ignore all modules in node_modules folder 
    module: {
      rules: [{
        test: /\.(js|jsx)$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['env']
          }
        }
      }]
    },
    plugins: [
      new UglifyJsPlugin()
    ]
  };
  
  module.exports = config;
  </code></pre>
  
  <p><strong>package.json</strong></p>
  
  <pre><code>{
    "name": "lambda-webpack",
    "version": "1.0.0",
    "description": "An empty project scaffold to enable webpack builds in AWS Lambda",
    "main": "index.js",
    "scripts": {
      "build": "webpack",
      "upload": "upload.bat"
    },
    "author": "Geek Stocks®",
    "license": "MIT",
    "devDependencies": {
      "aws-sdk": "^2.179.0",
      "babel-core": "^6.26.0",
      "babel-loader": "^7.1.2",
      "babel-preset-env": "^1.6.1",
      "uglifyjs-webpack-plugin": "^1.1.6",
      "webpack": "^3.10.0",
      "webpack-node-externals": "^1.6.0"
    }
  }
  </code></pre>