Extend AngularJS applications by injecting module dependencies at build time

Module License: MIT

Added by: Sam Deering





Stars: 5

Watchers: 5

Forks: 1

Module Description


Extend AngularJS applications by injecting module dependencies at build time (using static code transformations).

For example transforms this:

angular.module('moduleName', ['dependency']);

into that

angular.module('moduleName', ['dependency', 'additionalDependency']);


Build Status Coverage Status


Nowadays having a project using Grunt (or any other similar tool) for workflow automation and asset management is not uncommon. So the idea with this small library is to provide a way to implement a simple plugin system for AngularJS applications using only static code transformations. This has two main advantages (compared to extending the module with dynamic tricks):

  • Keeps the code clean from boilerplate
  • The modules can be still declared in any order.

The main use case for such a system is when you have an AngularJS based application and you want to allow third party modules (plugins) to exend you core app without hardcoding those new dependencies.


var angularExtend = require('angular-extend');

var src = "angular.module('moduleName', ['aModule']);";
var res = angularExtend(src, {moduleName: ['aPlugin']});
res.out will be:

angular.module('moduleName', ['aModule', "aPlugin"]);

res.changed is a boolean and will tell if any extension was applied at all.

Grunt plugin

A grunt plugin using this library will be soon available at


The transformation will work only if you follow the convention of delaring modules like

angular.module(<string>, [<strings>]);

Using variables or functions to define the module name, will fail.


Thanks to olov and his project ng-annotate for the inspiration he gave me to build this little tool.

Bitdeli Badge

Module stats last updated: 2015-06-04 11:08:54

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!