<commit_before># gulp-define-module [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url]

The gulp define module plugin produces modules from a simple function input. It allows
[other plugins](https://github.com/wbyoung/gulp-ember-emblem) to offload module definition
to a separate plugin. For consistency, the input function should not include a trailing semicolon.

An example input file:

```javascript
function() {
  // this is a module definition file that includes this single module.
  this.property = "some property";
}
```

Transformed to **Node** (`defineModule('node')`):

```javascript
module.exports = function() {
  // this is a module definition file that includes this single module.
  this.property = "some property";
};
```

Transformed to **AMD** (`defineModule('amd')`):

```javascript
define([], function() {
  return function() {
    // this is a module definition file that includes this single module.
    this.property = "some property";
  };
});
```

Transformed to **CommonJS** (`defineModule('commonjs')`):

```javascript
module.exports = function() {
  // this is a module definition file that includes this single module.
  this.property = "some property";
};
```

Transformed to **Plain** (`defineModule('plain')`):

```javascript
function() {
  // this is a module definition file that includes this single module.
  this.property = "some property";
};
```

To use the module simply include it in your gulp pipeline:

```javascript
var emberEmblem = require('gulp-ember-emblem');
var defineModule = require('gulp-define-module');

gulp.task('templates', function(){
  gulp.src(['client/templates/*.hbs'])
    .pipe(emberEmblem())
    .pipe(defineModule('node'))
    .pipe(gulp.dest('build/templates/'));
});
```


## API

### defineModule(type, [options])

#### type
Type: `String`  
Default: `bare`

The desired output type. One of the following:

* `node` - Produce Node modules
* `amd` - Produce AMD modules
* `commonjs` - Produce CommonJS modules
* `plain` - Return an unmolested function definition


#### options.require

Type: `Object`  
Default: `{}`

An object containing dependencies that should be imported for this module.
This option is only supported for `amd` and `node` modules. For other systems,
you will have to manage the dependency loading in another way.

The property name in the object should be the value of the variable that the
dependency will be accessed from, and the property value should be the name
of the dependency.

For instance, `{ Library: 'library' }` will produce:

**Node**

```javascript
var Library = global.Library || require('library');

module.exports = function() {
};

```

**AMD**

```javascript
define(['library'], function(Library) {
  return function() {
  };
});
```

<commit_msg>Corrected documentation.<commit_after># gulp-define-module [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url]

The gulp define module plugin produces modules from an input source. It allows
[other plugins](https://github.com/wbyoung/gulp-ember-emblem) to offload module definition
to a separate plugin. For consistency, the input source should contain a single JavaScript
expression and should not contain a trailing semicolon.

An example input file to create a callable module:

```javascript
{
  start: function() {},
  end: function() {},
  version: "1.0"
}
```

Transformed to **Node** (`defineModule('node')`):

```javascript
module.exports = {
  start: function() {},
  end: function() {},
  version: "1.0"
};
```

Transformed to **AMD** (`defineModule('amd')`):

```javascript
define([], function() {
  return {
    start: function() {},
    end: function() {},
    version: "1.0"
  };
});
```

Transformed to **CommonJS** (`defineModule('commonjs')`):

```javascript
module.exports = {
  start: function() {},
  end: function() {},
  version: "1.0"
};
```

Transformed to **Plain** (`defineModule('plain')`):

```javascript
{
  start: function() {},
  end: function() {},
  version: "1.0"
};
```

To use the module simply include it in your gulp pipeline:

```javascript
var emberEmblem = require('gulp-ember-emblem');
var defineModule = require('gulp-define-module');

gulp.task('templates', function(){
  gulp.src(['client/templates/*.hbs'])
    .pipe(emberEmblem())
    .pipe(defineModule('node'))
    .pipe(gulp.dest('build/templates/'));
});
```


## API

### defineModule(type, [options])

#### type
Type: `String`  
Default: `bare`

The desired output type. One of the following:

* `node` - Produce Node modules
* `amd` - Produce AMD modules
* `commonjs` - Produce CommonJS modules
* `plain` - Return an unmolested function definition


#### options.require

Type: `Object`  
Default: `{}`

An object containing dependencies that should be imported for this module.
This option is only supported for `amd` and `node` modules. For other systems,
you will have to manage the dependency loading in another way.

The property name in the object should be the value of the variable that the
dependency will be accessed from, and the property value should be the name
of the dependency.

For instance, `{ Library: 'library' }` will produce:

**Node**

```javascript
var Library = global.Library || require('library');

module.exports = {};

```

**AMD**

```javascript
define(['library'], function(Library) {
  return {};
});
```


{'fraction_non_alphanumeric': 0.15268456375838926, 'fraction_numerical': 0.0018642803877703207, 'mean_word_length': 4.576923076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6105217', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1561, 'n_words': 553}