# define-modules

> Simple way to inject module dependencies

Latest version **0.1.1** (published 2014-12-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install define-modules
pnpm add define-modules
yarn add define-modules
bun add define-modules
```

## 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.1.1 |
| Published | 2014-12-31 |
| First published | 2014-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Raghavendra Ravikumar |
| Maintainers | raghavgujjar |
| Keywords | modules, inject, define |

## Links

- npm: https://www.npmjs.com/package/define-modules
- Repository: https://github.com/raghavgujjar/DefineModules
- Issues: https://github.com/raghavgujjar/DefineModules/issues
- npm.io page: https://npm.io/package/define-modules

## Recent versions

- 0.1.1 (latest) — 2014-12-31
- 0.1.0 — 2014-12-25

## README

DefineModules
=============

A module that simplifies injecting module dependencies into a file through a configuration json that contains the paths of the project files aliased to a unique name.

## Installation

  npm install define-modules --save
  
## Usage
* Creating a JSON configuration file.

  If the folder structure is as follows (example of an auto generated express application):
  ```
  Express/
  	     routes/
  	            index.js
  	            user.js
  	     public
  	     views
  	     app.js
  ```
  The server side javascript files should be configured in a json as follows:
  ```json
  {
  	"app":"app",
  	"routes":"routes",
  	"user":"routes/user"
  } 
  ```
  You can call it pathsconfig.json or whatever name you prefer and save it in your main project root.
  
* Invoking the code.

  If you want to invoke the code in app.js which is in the main project root, the syntax is as follows:
  ```javascript
  var define = require('define-modules');
  
  define.config('./pathsconfig.json');
  
  //if both routes and user needs to be required, use this instead
  define.load(['routes','user'], function(routes, user) {
  	//functions exported by user and routes can be used here 
  });
  ```
  
### Summary  
That is all. You just needed to specify the file paths in a json file once and instead of writing multiple require statements, use syntax similar to requirejs define to invoke the modules inside whatever files you want in your project.
   
## Tests
  
  npm test

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