# grunt-named-modules

> Allows you to specify aliases for your module paths

Latest version **1.0.3** (published 2015-02-11) · 0 weekly downloads

## Install

```sh
npm install grunt-named-modules
pnpm add grunt-named-modules
yarn add grunt-named-modules
bun add grunt-named-modules
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2015-02-11 |
| First published | 2013-10-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | John Fawcett |
| Maintainers | johndotawesome |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-named-modules
- Repository: https://github.com/jrf0110/grunt-named-modules
- Issues: https://github.com/jrf0110/grunt-named-modules/issues
- npm.io page: https://npm.io/package/grunt-named-modules

## Recent versions

- 1.0.3 (latest) — 2015-02-11
- 1.0.2 — 2014-12-16
- 1.0.1 — 2013-10-27

## README

# Grunt Named Modules

> Allows you to specify aliases for your module paths

## Getting Started

This plugin requires Grunt `~0.4.1`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-named-modules --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-named-modules');
```

## The "namedModules" task

### Overview

For now, this task has no options and assumes you're using a ```package.json``` file. In your ```package.json``` file, add a new directive called ```namedModules```:

```javascript
{
  "scripts": {
    "postinstall": "grunt namedModules"
  },
  ...
  "namedModules": {
    "utils": "lib/utils.js",
    "errors": "lib/errors.js",
    "middleware": "lib/middleware/index.js",
    "configs": "configs/" // <-- alias a directory
  }
}
```

The name of the module will be the key, and the full module path is the value. Now, anywhere in your code, you can just require the alias:

```javascript
var utils   = require('utils');
var errors  = require('errors');
var m       = require('middleware');
var aConf   = require('configs/a');
```

I would just put a watch on my ```package.json```:

```javascript
watch: {
  namedModules: {
    files: ['package.json'],
    tasks: ['namedModules'],
    options: {
      spawn: false,
    }
  }
}
```

## Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History

1.0.2 - Added directory support
1.0.1 - The initial release!

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