Plugin config schemas and helpers: discovers local plugin files in a directory, reads a plugin spec's identifier and options, resolves path-like specs relative to the declaring config file, and deduplicates plugins by load identity.

Members

(static, constant) Options

Schema for arbitrary inline plugin options (a string-keyed record of unknown values).

(static, constant) Spec

Schema for a plugin spec: a plain identifier string, or a [identifier, options] tuple.

Methods

(static) deduplicatePluginOrigins(plugins) → {Array}

Deduplicate plugins by load identity, keeping the last-declared occurrence of each (package name for npm specs, exact file URL for local specs) while preserving the original ordering and each entry's full provenance.

Parameters:
NameTypeDescription
pluginsArray

Plugin origin entries, each with a spec field.

Returns:

The deduplicated plugin entries in their original order.

Type: 
Array

(static) load(dir) → {Promise.<Array.<string>>}

Discover local plugin files under plugin/ or plugins/ in a directory.

Parameters:
NameTypeDescription
dirstring

The directory to scan (its plugin/plugins subdirs).

Returns:

File URLs (file://) of the discovered .js/.mjs plugins.

Type: 
Promise.<Array.<string>>

(static) pluginOptions(plugin) → {Object|undefined}

Extract the inline options of a plugin spec, if any.

Parameters:
NameTypeDescription
pluginstring | Array

A plugin spec string or [identifier, options] tuple.

Returns:

The options object, or undefined when the spec is a bare identifier.

Type: 
Object | undefined

(static) pluginSpecifier(plugin) → {string}

Extract the identifier portion of a plugin spec.

Parameters:
NameTypeDescription
pluginstring | Array

A plugin spec string or [identifier, options] tuple.

Returns:

The plugin identifier.

Type: 
string

(static) resolvePluginSpec(plugin, configFilepath) → {Promise.<(string|Array)>}

Resolve a path-like plugin spec into an absolute file:// URL (or its package entry), anchored to the config file that declared it. Non-path specs (e.g. npm package names) are returned unchanged.

Parameters:
NameTypeDescription
pluginstring | Array

A plugin spec string or [identifier, options] tuple.

configFilepathstring

Path to the config file that declared the plugin.

Returns:

The resolved spec, preserving the tuple shape when options were present.

Type: 
Promise.<(string|Array)>