require("base-resolver")(configPathOrArray, basePath) → {external:q}
This function configures the resolver. This function takes two parameters and creates a configuration object that is used to load the starting modules.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
configPathOrArray |
string | Array.<(module:base-resolver~Configuration|string)> | If this parameter is a string,
requiring the string path should return the config array. We try to require the |
|
basePath |
string |
<optional> |
basePath is an optional parameter which provides the absolute path from where the
components should be resolved. If
|
Returns:
a Promise that gets resolved with module:base-resolver~Resolver when the resolver is set up. This promise is rejected with the error if the resolver set-up fails.
- Type
- external:q
The base.resolver component provides inversion of control and dependency injection api for running of zest infrastructure components. Using resolver, you set up a simple configuration and tell resolver which components you want to load. Each component registers itself with resolver, so other components can use its functions. Components can be maintained as NPM packages so they can be dropped in to other zest integrations. Simple components can also just be a file that can be required from node. (A javascript file or even a JSON file)
Requires
- module:base-resolver/configurations
- module:base-resolver/resolution-provider
- module:base-resolver/unloader
- module:base-resolver/utils
- external:q
- external:base-logger
Namespaces
Type Definitions
-
Configuration
-
An array of Configuration object is passed to configure resolver
Type:
- object
- if path does not start with a
.
, or does not contain/
the component is assumed to be an npm module - if path does not start with a
.
, and has a single/
, the component is assumed to be a git repository - in all other cases, the component is assumed to be located at the path specified in the local disk.
- Native modules are nodejs modules that are not compliant to the zest component structure
- When a component is marked as native, no dependency will be injected in it
- A native component can be injected into another component by its module name (as specified in
package.json
file - If no
package.json
file is found, or if no name is there inpackage.json
, the native component will be named as the last part of the path in configuration excluding extension. - Source:
Properties:
Name Type Argument Description path
string specifies the path of the component
options
* <optional>
the options to be passed to instantiate the component. - The Parameter Modifier can be used here using the
{param-number}
format - The|
(OR modifier) can also be used to gracefully degrade to defaults (explained in the example below) - If#
,|
or/
are to be used as literals in option, they must be escaped by a/
. Eg./#
will translate to a single#
startup
boolean <optional>
startup is optional and is used to specify if a component is a starting component.
native
boolean <optional>
is optional and is used to mark a component as native nodejs module.