I get this warning when using Grunt and grunt-ng-annotate.
There is no reference in the warning to where the error is in the file, which makes debugging it hard.
Any ideas?
I get this warning when using Grunt and grunt-ng-annotate.
There is no reference in the warning to where the error is in the file, which makes debugging it hard.
Any ideas?
The issue turned out to be use of ES6 notation, in this case arrow functions (=>), default parameters and let.
I haven't looked in detail as to why ngAnnotate doesn't support this.
To find where the issues were I overrode the ngAnnotate warning with grunt switch --force and later in the build uglify complained about the ES6 syntax with more detail.
--force
to push past ng-annotate. uglify
will complain later, with an actual line number in the .tmp source code. –
Jill Possible reasons:
() => {}
{ value }
let
function (...args)
function (defaultVar = false)
Solutions:
function () {}
{ value: value }
var
function (args)
function (defaultVar) { defaultVar = (defaultVar === undefined) ? false : defaultVar }
...
the other solution would be to use .concat()
–
Bellarmine I also faced the same problem but in my case, there was a different issue.
One of our team members has initialized function parameter to some default value. Something like the following.
$scope.functionName = function(defaultVar = false){
//some code
}
and in my gulp script, there was a line
.pipe(plugins.if(release, plugins.ngAnnotate()))
So when I have removed this line the build script automatically printed the error in console pointing to the exact file and line number where the error was.
Finally, I was able to solve it by removing that variable initialization code.
Hope this will help someone...
I also faced a similar issue caused by a destructuring assignment:
// the following line broke the build
const { name, gender, yearOfBirth, occupation } = profile;
© 2022 - 2024 — McMap. All rights reserved.
babel-plugin-angularjs-annotate
– Rolling