saikat mukherjee
saikat mukherjee

Reputation: 355

Angular-js code minifying Error: Unexpected token: operator (>)

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

Answers (2)

Rohit Rane
Rohit Rane

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

henrikmerlander
henrikmerlander

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

Related Questions