1. load-module
Standard dynamic imports with a few extra features
load-module
Package: load-module
Created by: 75lb
Last modified: Sun, 08 May 2022 06:54:28 GMT
Version: 4.2.1
License: MIT
Downloads: 355,632
Repository: https://github.com/75lb/load-module

Install

npm install load-module
yarn add load-module

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> One or more additional directories from which to resolve the supplied specifier from.

loadModuleRelativeTo(specifier, paths)

Kind: exported function

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 <[email protected]>.

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

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code