lineman-angular updated to ng-annotate

We use LinemanJS to automate the build process of various AngularJS projects. Two newer projects use the most excellent UI-router package, and I had some issues. The resolve section required manual protection for minification; ngmin, the automatic minify protector included with lineman-angular, did not handle resolves correctly. So this code:

resolve: {
     liveConfig: function(ServerConfigService) {
       return ServerConfigService.fetchFutureConfig();
     },
     liveLocations: [ "PickSchoolService", function(PickSchoolService) {
        return PickSchoolService.fetchSchools();
     }]}

would not work, as the minifier would convert the ServerConfigService object to, say, a, and that would obviously not match the injected service. Blam.

 liveConfig: function(a) {  // what the heck is a??
      return a.fetchFutureConfig();

There has been a feature request outstanding on this for a while, So yesterday on a longer car ride, I finally got ng-annotate to work on my local project. I was all ready to grab the source for lineman-angular and submit a PR, and found davemo beat me to it:

davemo authored replaces ngmin with ng-annotate 2386ab76016b485a03dfbf684c4639e9235f8a4d

updated my local package.json to 0.3.0 and lineman build. Nice. Now I can rip out all that icky brackety stuff.

Now to make sure – I found that chaining

angular.module("app", ["ui.router", "mm.foundation", "ngStorage"])

.run(function ($rootScope) {
///
})
.run(function($log, $state, $localStorage, $timeout) {
///
})
.run(function ($rootScope, $state, $log, PickSchoolService) {
///
})
.config(['$logProvider', function ($logProvider) {
///
}])
.config(['$httpProvider', function ($httpProvider) {
///
}]);

also had issues in minification. I had to break some files up with the explicit module statement for it to work.

angular.module("app")  // require redeclaring for ng-min support
    .config(function($httpProvider) {
    ///
    });

angular.module("app")  // require redeclaring for ng-min support
    .run(function ($rootScope) {
    ////
    });

I mashed them back together. Seems to work great now. Nice work, all.

Leave a Reply