# PluginDependency

> _Since v0.4.1_

Declares a dependency on another plugin.

#### Example

```typescript
export class UndoRedoPlugin extends BaseGridPlugin {
  static readonly dependencies: PluginDependency[] = [
    { name: 'editing', required: true },
  ];
}
```

## Properties

| Property | Type | Description |
| -------- | ---- | ----------- |
| <span id="name"></span>`name` | <code>string</code> | The name of the required plugin (matches the plugin's `name` property). Use string names for loose coupling - avoids static imports. |
| `required?` | <code>boolean</code> | Whether this dependency is required (hard) or optional (soft). - `true`: Plugin cannot function without it. Throws error if missing. - `false`: Plugin works with reduced functionality. Silent if missing   (set severity to `'warn'` or `'info'` to opt into a message). |
| `severity?` | <code>error &#124; warn &#124; info</code> | Explicit severity when this dependency is missing. Overrides the default derived from required. - `'error'`: throw (halts grid setup). Default when `required` is not `false`. - `'warn'`: log a console warning and continue (development only). - `'info'`: log a verbose console.debug message and continue (development only). <span class="since-badge" title="Introduced in v2.16.0">v2.16.0+</span> |
| `when?` | <code>(pluginConfig: unknown) =&gt; boolean</code> | Optional predicate that gates whether this dependency applies, evaluated against the depending plugin's own resolved configuration (defaults merged with user config). Return `false` to skip the dependency entirely. <span class="since-badge" title="Introduced in v2.16.0">v2.16.0+</span> |
| `provide?` | <code>() =&gt; <a href="/grid/api/plugin-development/classes/basegridplugin/">BaseGridPlugin</a></code> | Factory for a default instance of the dependency. When the dependency is missing, the grid attaches the instance this returns (once per grid, before the depending plugin) instead of reporting an error, so consumers never have to add it themselves. An explicitly configured instance always wins. <span class="since-badge" title="Introduced in v3.9.0">v3.9.0+</span> |
| `reason?` | <code>string</code> | Human-readable reason for this dependency. Shown in error/info messages to help users understand why. |

### Property Details

#### `required`

**Default:** `true`

---

#### `severity`

Explicit severity when this dependency is missing. Overrides the default
derived from required.
- `'error'`: throw (halts grid setup). Default when `required` is not `false`.
- `'warn'`: log a console warning and continue (development only).
- `'info'`: log a verbose console.debug message and continue (development only).

When omitted, a missing hard dependency throws and a missing soft
dependency is silent — preserving backward-compatible behavior.

---

#### `when`

Optional predicate that gates whether this dependency applies, evaluated
against the depending plugin's own resolved configuration (defaults merged
with user config). Return `false` to skip the dependency entirely.

Lets a plugin require/recommend another plugin only under certain config
— e.g. a plugin that needs a tool-panel host only when its tool panel is
enabled. When omitted, the dependency always applies.

```ts
when: (cfg: PivotConfig) => cfg.showToolPanel === true
```

---

#### `provide`

Factory for a default instance of the dependency. When the dependency is
missing, the grid attaches the instance this returns (once per grid,
before the depending plugin) instead of reporting an error, so consumers
never have to add it themselves. An explicitly configured instance always
wins.

Import the dependency's plugin module statically so it ships with the
depending plugin's module graph — never with `import()`.

```ts
provide: () => new HierarchyPlugin()
```

---

#### `reason`

```ts
"UndoRedoPlugin needs EditingPlugin to track cell edits"
```

---
