# gulp-angular-module

> Allows for dynamic module extension

Latest version **0.0.2** (published 2014-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-angular-module
pnpm add gulp-angular-module
yarn add gulp-angular-module
bun add gulp-angular-module
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2014-07-26 |
| First published | 2014-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Andrew Ross |
| Maintainers | rossross |
| Keywords | gulp, angular, gulpplugin |

## Links

- npm: https://www.npmjs.com/package/gulp-angular-module
- Repository: https://github.com/rossross/gulp-angular-module
- Issues: https://github.com/rossross/gulp-angular-module/issues
- npm.io page: https://npm.io/package/gulp-angular-module

## Dependencies (7)

- [vinyl](https://npm.io/package/vinyl.md) ^0.3.0
- [lodash](https://npm.io/package/lodash.md) ^2.4.1
- [esprima](https://npm.io/package/esprima.md) ^1.2.2
- [through2](https://npm.io/package/through2.md) ^0.5.1
- [escodegen](https://npm.io/package/escodegen.md) ^1.3.3
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.0
- [estraverse](https://npm.io/package/estraverse.md) ^1.5.1

## Recent versions

- 0.0.2 (latest) — 2014-07-26
- 0.0.1 — 2014-07-26

## README

#gulp-angular-module
>Dymaic angular module extension

##Usage

Install `gulp-angular-module` as a development dependency:

```shell
npm install gulp-angular-module --save-dev
```

Then add it to your `gulpfile.js`:

```javascript
var angularModule = require('gulp-angular-module'),
    gulp = require('gulp');
    
    gulp.task('module', function(){
        gulp.sr('./src/app/*.js')
            .pipe(angularModule())
            .pipe(gulp.dest('./dist/'));
    });
```
## API

### Options
####moduleDefinitionFileName
Type: `String`

If defined then all module definitions will be placed here. 
The default behaviour will place a module definition in a file named the same as the module.

####masterModule
Type: `String`

If set will add all modules found as a dependency to this module.

####masterVendorModules
Type: `Array`

Possible 3rd party vendor modules to add to the master module. 

## Use cases

Let's say you have a very large angular app that you've separated into different modules  

```
|
+- src
|   +- modules
|       +- admin
|           +- userManagmentController.js
|           +- userService.js
|       +- ui
|           +- specialButtonDirective.js
|           +- awesomeSliderDirective.js
+- dist
```

In the `src/modules/admin/userManagmentController.js`

You have the following code 
```javascript
angular.module('admin',['fooVendorModule'])
.controller('userManagement', function(fooService){
    ...
});
```

And in `src/modules/admin/userService.js`

You have
```javascript
angular.module('admin',['barVendorModule'])
.service('userService', function(barService){
    ...
});
```

There would be an issue because angular only allows a module to be defined once.
To fix this you then have to create an app.js at root of the module and redefine all the dependencies there,
whilst also having to replace all of the module definitions up in all your controllers, constants, directives, ect.

```javascript
angular.module('admin',['barVendorModule','fooVendorModule']);
```

As you can guess this becomes a very large cognitive load as your app gets very large and this plugin automates this process.

---
_Source: https://npm.io/package/gulp-angular-module · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
