ngmin
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -32,7 +32,12 @@ | ||
//TODO: honor scope | ||
// returns true iff there were things to annotate | ||
var markASTModules = module.exports = function (syntax) { | ||
var changed = false; | ||
var markASTModules = module.exports = function (syntax) { | ||
signatures.forEach(function (signature) { | ||
deepApply(syntax, signature, function (chunk) { | ||
chunk.ngModule = true; | ||
if (!chunk.ngModule) { | ||
changed = true; | ||
} | ||
}); | ||
@@ -95,2 +100,5 @@ }); | ||
deepApply(syntax, signature, function (chunk) { | ||
if (!chunk.callee.object.ngModule) { | ||
changed = true; | ||
} | ||
chunk.callee.object.ngModule = true; | ||
@@ -100,2 +108,3 @@ }); | ||
return changed; | ||
}; |
@@ -15,3 +15,3 @@ | ||
markASTModules(syntax); | ||
while (markASTModules(syntax)) {} | ||
annotateAST(syntax); | ||
@@ -18,0 +18,0 @@ |
{ | ||
"name": "ngmin", | ||
"description": "AngularJS Minifier", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"author": "Brian Ford", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -6,2 +6,17 @@ # ngmin | ||
## tl;dr | ||
Turns this | ||
``` | ||
angular.module('whatever').controller('MyCtrl', function ($scope, $http) { ... }); | ||
``` | ||
into | ||
``` | ||
angular.module('whatever').controller('MyCtrl', ['$scope', '$http', function ($scope, $http) { ... }]); | ||
``` | ||
so that minifiers can handle AngularJS's DI annotations and you can save a few keystrokes. | ||
## Installation | ||
@@ -13,2 +28,5 @@ Install via npm: | ||
## Grunt Task | ||
`ngmin` is available as a [Grunt](http://gruntjs.com/) task as [`grunt-ngmin`](https://github.com/btford/grunt-ngmin). | ||
## CLI Usage | ||
@@ -15,0 +33,0 @@ |
@@ -53,4 +53,30 @@ /* | ||
//TODO: test refs + chaining | ||
it('should annotate refs that have been chained', function () { | ||
var annotated = annotate(function () { | ||
var mod = angular.module('chain', []); | ||
mod.factory('a', function ($scope){}). | ||
factory('b', function ($scope){}); | ||
}); | ||
annotated.should.equal(stringifyFunctionBody(function () { | ||
var mod = angular.module('chain', []); | ||
mod.factory('a', ['$scope', function($scope){}]). | ||
factory('b', ['$scope', function($scope){}]); | ||
})); | ||
}); | ||
it('should annotate refs to chains', function () { | ||
var annotated = annotate(function () { | ||
var mod = angular.module('chain', []). | ||
factory('a', function ($scope){}); | ||
mod.factory('b', function ($scope){}); | ||
}); | ||
annotated.should.equal(stringifyFunctionBody(function () { | ||
var mod = angular.module('chain', []). | ||
factory('a', ['$scope', function($scope){}]); | ||
mod.factory('b', ['$scope', function($scope){}]); | ||
})); | ||
}); | ||
}); |
25241
689
144