JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17021
  • Score
    100M100P100Q122706F
  • License MIT

This module extends the default Node.js require with capabilities to require nested modules, independent on where they are nested.

Package Exports

  • require-it
  • require-it/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (require-it) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

require-it

Downloads Version@npm Version@git

This module extends the default Node.js require with capabilities to require nested modules, independent of where they are nested.

Install

npm install require-it --save

Example

myPackage
 + node_modules
 |  + direct-dependecy
 |  |  + node_modules
 |  |  |  \ nested-module
 |  |  |     + index.js
 |  |  |     \ package.json
 |  |  + index.js
 |  |  \ package.json
 |  + index.js
 |  \ package.json
 + index.js
 \ package.json

myPackage/index.js:

const { requireIt } = require('require-it');
// it will work and won't throw error
const nestedModule = requireIt('nested-module');

API

requireIt(moduleName)

Requires the given local module, independent of which level it is.

requireIt.resolve(moduleName)

Returns the local path, which could be required by require.

requireIt.directory(moduleName)

Returns the local path, which could be required by require without the main JS file, i.e., the path to the module's directory.

requireGlobal(globalModuleName)

Requires the given global module.

requireGlobal.resolve(globalModuleName)

Returns the global path, which could be required by require.

requireGlobal.directory(globalModuleName)

Returns the global path, which could be required by require without the main JS file, i.e., the path to the module's directory.

requireFrom(moduleName, root)

Requires the given module found in the given root directory.

requireFrom.resolve(moduleName, root)

Returns the module's path, which could be required by require, found in the given root directory.

requireFrom.directory(moduleName, root)

Returns the module's path, which could be required by require without the main JS file, i.e., the path to the module's directory, found in the given root directory.