Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Can't I Minify Angular.js?

I'm trying to use Microsoft's Web Optimization bundling toolkit, which works well for everything else.

When I try to ask it to minify AngularJS, though, I get this error message in the resultant Javascript output:

"Ambiguous reference to named function expression"

I'm not even sure where to start with this one . . .

like image 762
blaster Avatar asked Apr 26 '26 04:04

blaster


2 Answers

The answer to this question (which should not have been downvoted, in my opinion, because it represents a real issue) is to upgrade from the older Microsoft.Web.Optimization package that uses the "Microsoft.Web.Optimization" namespace and making sure you're using their latest, signified by the "System.Web.Optimization" namespace instead.

In the older Microsoft package, Angular would bomb out when handed to JsMinify. Not so anymore in the latest version.

I hadn't realized at first that I was on an older version of that package because the package name changed - hence my spinning my wheels on it for a while.

like image 105
blaster Avatar answered Apr 28 '26 16:04

blaster


The best workaround in my opinion is to preminify the Angular applications using ngmin before minifying with another tool in order to keep dependency injection working.

https://github.com/btford/ngmin

HTH

like image 35
a.s.t.r.o Avatar answered Apr 28 '26 17:04

a.s.t.r.o



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!