require-mapper

Maps the project's local modules for an easy require access

npm install require-mapper
8 downloads in the last week
41 downloads in the last month

require-mapper

Maps the project's local modules for an easy require access.
With simple key value mapping, the project's modules can be addressed more easily

Usage

Just map your modules

var Mapper = require("require-mapper"),
        mapper = new Mapper();

mapper.map({
    "my.module": "src/My.js"
});

And then...

Load your module using the map's keys:

_require("my.module")
  

Customize on initial phase (optional)

  • methodname - The method name to be used for require the modules
  • basepath - The base path for resolving the modules (default: ".")
  • data - The modules map
var Mapper = require("require-mapper"),
        mapper = new Mapper();

mapper.init({
    methodname: "requirexxx"
    basepath: "../",
    data:{
        "foo.module": "src/foo/Foo.js"
    }
});

// use your custom require method name
requirexxx("foo.module");
  
npm loves you