load-module
Standard dynamic imports but with a few additional features:
- You can supply specific folders in which to search for modules (e.g. any local directory).
- You can specify a base folder from which to resolve from (e.g. the current working directory).
Synopsis
> const loadModule = require('load-module')
> loadModule('react-dom')
> loadModule('something.mjs', { paths: process.cwd() })
> loadModule('something.mjs', { paths: [process.cwd(), '~/my-modules'] })
load-module
loadModule.loadModuleSpecifier(specifier)
Kind: static method of load-module
Param | Type | Description |
---|
specifier | string | A valid Node.js module specifier. |
loadModule.loadModuleResolvedFrom(specifier, paths)
Kind: static method of load-module
Param | Type | Description |
---|
specifier | string | A valid Node.js module specifier. |
paths | string | Array.<string> | One or more additional directories from which to resolve the supplied specifier from. |
loadModule.loadModulePathRelativeTo(specifier, paths)
Kind: static method of load-module
Param | Type | Description |
---|
specifier | string | A valid module path. |
paths | string | Array.<string> | One or more additional directories in which to search for the supplied module path. |
© 2017-21 Lloyd Brookes <75pound@gmail.com>.
Tested by test-runner. Documented by jsdoc-to-markdown.