npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@flowscripter/esm-dynamic-plugins

v1.5.15

Published

Plugin framework using ES Modules and Dynamic Import.

Downloads

135

Readme

esm-dynamic-plugins

license dependencies travis coverage npm

Plugin framework using ES Modules and Dynamic Import.

Overview

This project provides a Javascript framework for defining plugins which may be dynamically discovered and imported into a running Javascript process.

Key Features

  • Universal support for both NodeJS and browser Javascript runtimes
  • Dynamic plugin import using Javascript dynamic import
  • ES2015 module based
  • Written in Typescript

Key Concepts

The framework's key concepts are borrowed from the Eclipse Project's extension framework. The key concepts are:

  • A HostApplication instantiates a PluginManager
  • The PluginManager provides an ExtensionPointRegister
  • The HostApplication can declare ExtensionPoints in the ExtensionPointRegister
  • A Plugin provides one or more Extensions for one or more ExtensionPoints
  • A Plugin provides an ExtensionDescriptor for each Extension it provides
  • A PluginManager scans for and registers Plugins which provide Extensions for the known ExtensionPoints
  • A HostApplication uses the PluginManager to query for and select an Extension for a desired ExtensionPoint
  • The PluginManager uses an ExtensionFactory declared in an ExtensionDescriptor to instantiate a selected Extension

The following high level class diagram illustrates these relationships:

High Level Class Diagram

The following sequence diagram illustrates the key steps for a HostApplication to use a PluginManager for discovery and registration of Plugins:

Registration Sequence Diagram

Once registration has been performed, the HostApplication may query for and instantiate Extensions for known ExtensionPoints:

Query and Instantiation Sequence Diagram

As ExtensionPoints are simply Javascript classes, for the purposes of testing or validation, it is possible to bypass the framework altogether and import an Extension and use it directly:

Direct Instantiation Sequence Diagram

Examples

The following example projects are available which all support execution in NodeJS and a browser:

Code Documentation

Typescript documentation

Development

Firstly:

npm install

Note: The warnings regarding peer dependencies are caused by dependencies or sub-dependencies which have yet to update their peer-dependencies. They can safely be ignored.

Build: npm run build

Watch: npm run watch

Test: npm test

Lint: npm run lint

Docs: npm run docs

The following diagram provides an overview of the main classes:

Implementation Class Diagram

Further Details

Further details on project configuration files and Javascript version support can be found in the template for this project.

Alternatives

  • js-plugins - also provides a plugin framework following Eclipse Project's framework. Relies on plugin declarations in package.json instead of Typescript interfaces. Does not support browser or ES2015 modules.
  • oclif plugins - very much tied to the Oclif CLI. Relies on available plugins being declared in package.json. Does not support browser or ES2015 modules.

License

MIT © Flowscripter