Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

require-for

eush773MIT0.1.0

Make a 'require' object for a given path, that bases all require() and require.resolve() calls on that path

require, resolve, cache, extensions, main, registerExtension, path, module, from, vm, global

readme

npm

require-for

Build Status Dependency Status

Make a require object for a given path, that bases all require() and require.resolve() calls on that path.

Much like resolve-from, and in fact requireFor(dir).resolve is exactly that.

Such object can be passed to VM running some script enabling that script to require other modules, as in nodei.

Example

var requiref = requireFor('./module');

requiref('./index.js')
//=> require('./module/index.js')

Object.keys(requiref)
//=> [ 'resolve', 'main', 'extensions', 'registerExtension', 'cache' ]

API

requireFor(fromDir, [requirefn])

Make a require object for fromDir directory. Use optional requirefn as a require function.

Install

npm install require-for

License

MIT