prequire

0.0.0 • Public • Published

pRequire

pRequire is a small abstraction to the require statement.

Usage

Add the following statement to your app's entry point.

require('prequire')(__dirname)

This will create a GLOBAL reference to pRequire, which allows you to require modules defined in your package.json relative to your project root not located in node_modules.

You then define keys in your package.json that reference modules relative to the root folder.

Example package.json

"localDependencies"{
  "base": "test/base",
  "libIndex": "test/lib",
  "libOther": "test/lib/other"
}

Note: libIndex is referencing a folder that contains index.js. It works just like require('./test/lib');.

Example of pRequire statement

require('./index')(__dirname);
 
var base = pRequire('base');
 
var libIndex = pRequire('libIndex');
 
var libOther = pRequire('libOther');
 
console.log(base, libIndex, libOther);

You can run node test.js to see pRequire in action.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.0
    1

Package Sidebar

Install

npm i prequire

Weekly Downloads

1

Version

0.0.0

License

MIT

Last publish

Collaborators

  • hellopat