AddonLoader

AddonLoader

Addon loader

Constructor

new AddonLoader(rootPath, pkg, modulesDiropt, callbacksopt)

Parameters:
Name Type Attributes Default Description
rootPath string location to start looking for addons
pkg object package.json object
modulesDir string <optional>
node_modules modules directory
callbacks function <optional>
function to later register callbacks on the loader
Source:

Methods

discover(rootPath, pkg, modulesDiropt) → {Array.<{pkg, path, hooks}>}

Lookup package devDependencies and dependencies and resolve all of them which contain the addon keyword
Parameters:
Name Type Attributes Default Description
rootPath string
pkg object
modulesDir string <optional>
node_modules
Source:
Returns:
package metadata
Type
Array.<{pkg, path, hooks}>

hook(hookName, hookConfigopt) → {function}

Creates a function that can be called with additional params that calls all addons for a given hook. The second param is passed to each addon hook. The returned function represents a call to the callback for the hookName.
Parameters:
Name Type Attributes Description
hookName string name of the hook
hookConfig object <optional>
config object that is provided to each hook
Source:
Returns:
generated hook function
Type
function
Example
results = hook('IMG_PIPE')(pipe);

reduceAddonsToHooks(addons, loaderHooks) → {*}

Take an array of resolvePkg results and already loaded hooks. It creates a key -> Array.<{hook: string, addon}> map where each key is the hooks identifier.
Parameters:
Name Type Description
addons
loaderHooks
Source:
Returns:
Type
*

resolvePkg(addon) → {Object}

Generates metadata for package
Parameters:
Name Type Description
addon Object addon path and package.json object
Source:
Returns:
loaded addon. If no entrypoint was found, the package is skipped and a warning logged.
Type
Object