Package Exports
- load-plugin
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 (load-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
load-plugin

Load a submodule, plugin, or file. Like Node’s require
and
require.resolve
, but from one or more places, and optionally
global too.
Installation
npm:
npm install load-plugin
When bundled for the browser, a small file is included to warn that, when any of the below functions are invoked, the action is unsupported.
Usage
Say we’re in this project (with dependencies installed):
var load = require('load-plugin');
load.resolve('lint', {prefix: 'remark'});
// '/Users/tilde/projects/oss/load-plugin/node_modules/remark-lint/index.js'
load.resolve('./index.js', {prefix: 'remark'});
// '/Users/tilde/projects/oss/load-plugin/index.js'
load.require('lint', {prefix: 'remark'});
// [Function: lint]
API
loadPlugin(name[, options])
Uses the standard node module loading strategy to require name
in each given cwd
(and optionally the global node_modules
directory).
If a prefix is given and name
is not a path, prefix-name
is also searched (preferring these over non-prefixed modules).
options
prefix
(string
, optional) — Prefix to search for;cwd
(string
,Array.<string>
, default:process.cwd()
) — Place or places to search from;global
(boolean
, optional, defaults to whether global is detected) — Whether to look forname
in global places. If this is nully,load-plugin
will detect if it’s currently running in global mode: either because it’s in Electron, or because a globally installed package is running it.
Returns
The results of require
ing the first path that exists.
Throws
If require
ing an existing path fails, or if no existing path exists.
loadPlugin.resolve(name[, options])
Search for name
. Accepts the same parameters as loadPlugin
but returns an absolute path for name
instead of requiring it,
and null
if it cannot be found.