Minification Issues


#1

In many instances in the tutorials and examples, the code will have trouble with magnification. Perhaps it would be best to use examples that explicitly solve this problem? Otherwise, developers are going to have trouble with magnification or be forced to use ngmin.

Example from the Intro App Tutorial :

UPDATED CODE : Had extra closing bracket.

.config(function($routeProvider, $locationProvider) { ... });

Should really be:

.config( ['$routeProvider', '$locationProvider' , function($routeProvider, $locationProvider) { ... }]);

#2

Yes good point, I created an issue so we get that fixed up: https://github.com/driftyco/ionic-site/issues/90


#3

LOL - Just realized I wrote :

the code will have trouble with magnification

I don’t think magnification will be a problem.


#4

Ha, yeah we’ll work to support magnification too


#5

@calendee is there a typo in your example:

.config( ['$routeProvider', '$locationProvider' ], function($routeProvider, $locationProvider) { ... }]);

OR

.config( ['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { ... }]);

I am using minification with my Ionic project and all my code uses minification-safe syntax. I get an error on trying to load my first page:

Error: [ng:areq] Argument 'fn' is not a function, got string

This is in my minified vendors.js file so it’s unlikely to come from my scripts folder containing my controllers and models and other JS files. This is a snippet from the vendors.js file where the error apparently comes from:

encodeURIComponent(h(arguments[c]));return new Error(b)}}

Can you see anything that might be causing this?


#6

You are correct, there is a misplaced closing bracket in my code. I’ve updated it now.

I can’t tell you quite what might be wrong. I ran into a lot of those on my first run with minification. I literally went through the app line be line finding each injection issue. It was kind of painful. Lesson learned - run minification every build and see what fails.


#7

You are absolutely right. It was an oversight on my part: I forgot to rewrite the http interceptor I was using inside the config block. After a few hours of confusion, I finally caught it :smile:


#8

Yes, the config and routing section was where I had most of my troubles as well. Keep on top of it by testing with minification so another injection problem doesn’t sneak in.