Error in uglifyjs after upgrading to webpack 3

Do you want to request a feature or report a bug?
bug

What is the current behavior?

Bundle.js generated, but uglifyjs make no sense and error

ERROR in assets/js/app.js from UglifyJs
Unexpected token: name (foo) [assets/js/app.js:83,4]
Child html-webpack-plugin for "index.html":
       [0] ./node_modules/.2.28.0@html-webpack-plugin/lib/loader.js!./src/index.html 721 bytes {0} [built]
       [2] (webpack)/buildin/global.js 509 bytes {0} [built]
       [3] (webpack)/buildin/module.js 517 bytes {0} [built]
        + 1 hidden module

If the current behavior is a bug, please provide the steps to reproduce.

// webpack.config
plugins: [
  new webpack.optimize.UglifyJsPlugin(),
]

// bundle.js
...
function _asyncToGenerator(fn) { ... }
let foo = (() => { // line 83
    var _ref = _asyncToGenerator(function* () {
        return 'foo';
    });

    return function foo() {
        return _ref.apply(this, arguments);
    };
})();

let obj = foo();
obj.then(res => alert(res), res => console.log(res));

// app.js
import { foo } from './helper'
let obj = foo()
obj.then(res => console.log(res))

// helper.js
export async function foo() {
    return 'foo';
}

...

What is the expected behavior?

no error as when running webpack 2

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

nodejs: 6.10.0
webpack: 3.0.0
os: mac

Author: Fantashit

1 thought on “Error in uglifyjs after upgrading to webpack 3

Comments are closed.