2

I currently have this

ready : function(){
    bus.$on('a-data', (param) => {
        this.name = param.name;
        this.age = param.age;
    })
},

While this particular code run when uglifyjs is disabled, when enabled it throws the following error

SyntaxError: Unexpected token: operator (>)

Here's my uglify config

new webpack.optimize.UglifyJsPlugin({
    minimize: true,
    sourceMap: false,
    compress: {
        warnings: false,
        sequences: true,
        dead_code: true,
        conditionals: true,
        booleans: true,
        unused: true,
        if_return: true,
        join_vars: true,
        drop_console: true
    }
}))

I can't seem to understand why it's not working. Any ideas?

highFlyingSmurfs
  • 2,989
  • 2
  • 15
  • 28

1 Answers1

9

UglifyJS does not have ES6/Harmony support built in yet.

They have an open GitHub issue for tracking the status of that feature.


This is usually not an issue because most people tend to run their ES6 code through Babel first for back compatibility with old browsers, and the result of that would pass through Uglify.

CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138
  • though i ran all my codes through Babel. Then, I am using uglify :/ – highFlyingSmurfs Sep 05 '16 at 11:58
  • What babel presets are you using? If you use the es2015 presets, babel will replace the arrow function with a standard function. Another anternative might be to try Babili instead of Uglify: https://github.com/babel/babili – CodingWithSpike Sep 06 '16 at 15:10