Reputation: 355
I am trying to minify my angular-js code using js-minify tool but its throwing an exception as Error: Unexpected token: operator (>)
Upvotes: 4
Views: 1193
Reputation: 2940
Why don't you use a transpiler like https://babeljs.io/ to compile your es6 code down to es5 and than minify/uglify your source code.
In this way you can continue to enjoy writing code in es6.
Upvotes: 1
Reputation: 1574
The arrow function expression is a new feature introduced in ECMAScript 2015. Your minifier probably does not support it yet. You mentioned that you were trying to do this:
scope.chartData[0].reduce((a, b) => a + b, 0)
You can rewrite it without the arrow function like this:
scope.chartData[0].reduce(function(a, b) {
return a + b
}, 0)
Upvotes: 4