0.4.0 • Published 7 years ago

require-up v0.4.0

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

Require-up

npm

Require modules from anywhere up the parent directories. Like find-up but for require.

Optionally, a new syntax ('.../') which will work with regular require/import calls.

Install

$ npm install --save require-up

Usage

If you have a structure like this:

proj
├───index.js
├───utils.js
└───foo
    └───bar
        └───some-file.js
// proj/foo/bar/some-file.js
const requireUp = require('require-up')
const { utils } = requireUp('utils')

It will look for (in this order):

proj/foo/bar/node_modules/utils
proj/foo/bar/utils
proj/foo/node_modules/utils
proj/foo/utils
proj/node_modules/utils
proj/utils # << found

Register

A new syntax ('.../') which will work with regular require/import calls.

// proj/index.js
import 'require-up/register'
// proj/foo/bar/some-file.js
import utils from '.../utils'

CAUTION

BEWARE: Registering new syntax patches core module.js's Module._resolveFilename.

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago