Name Last Update
..
dist Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
index.mjs Loading commit data...
package.json Loading commit data...

view on npm npm module downloads Gihub repo dependents Gihub package dependents Node.js CI Coverage Status js-standard-style

load-module

Standard dynamic imports intended for runtime loading of user-defined modules (e.g. plugins).

  • Search for modules in one or more specific folders.
  • Specify a base folder from which to resolve from (e.g. the current working directory).

Synopsis

import { loadModule } from 'load-module'

const ViewClass = await loadModule('default-view', { paths: '~/my-view-folder'})
const view = new ViewClass()

load-module

loadModule(specifier, options)

Kind: exported function

Param Type Description
specifier string A valid Node.js module specifier.
options.paths string[] One or more directories to pass to both loadModuleResolvedFrom and loadModuleRelativeTo.
options.resolvedFromPaths string[] Specific directories to pass to loadModuleResolvedFrom.
options.relativeToPaths string[] Specific directories to pass to loadModuleRelativeTo.

loadModuleSpecifier(specifier)

Kind: exported function

Param Type Description
specifier string A valid Node.js module specifier.

loadModuleResolvedFrom(specifier, paths)

Kind: exported function

Param Type Description
specifier string A valid Node.js module specifier.
paths string \ Array.<string>

loadModuleRelativeTo(specifier, paths)

Kind: exported function

Param Type Description
specifier string A valid module path.
paths string \ Array.<string>

© 2017-21 Lloyd Brookes <75pound@gmail.com>.

Tested by test-runner. Documented by jsdoc-to-markdown.