@jil/plugin
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@jil/plugin

Plugin based architecture that supports module loading, custom types, registries, scopes, and more.

import {Registry, Pluggable} from '@jil/plugin';

export interface Renderable<T> extends Pluggable<T> {
  render(): string | Promise<string>;
}

const registry = new Registry<Renderable>('jil', 'plugin', {
  validate(plugin) {
    if (typeof plugin.render !== 'function') {
      throw new TypeError('Plugins require a `render()` method.');
    }
  },
});

const plugin = await registry.load('jil-plugin-example');

Features

  • Custom plugin types and registries.
  • Node module, file path, and configuration file loading strategies.
  • Multiple module name formats: public, scoped public, scoped private.
  • Structural contracts with life cycle events.
  • Factory function pattern for plugin creation.
  • Asynchronous by default.

Installation

npm i  @jil/plugin

Documentation

/@jil/plugin/

    Package Sidebar

    Install

    npm i @jil/plugin

    Weekly Downloads

    2

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    57 kB

    Total Files

    35

    Last publish

    Collaborators

    • towyuan