
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
use-plugin
Advanced tools
There is annotated source code for this module.
For use in framework modules to provide a plugin mechanism for extensions. While a simple require in calling code is a good start, this plugin provides some convenience abstractions over vanilla requires so that you can offer a more user-friendly interface.
See the seneca module for an example of practical usage.
// myframework.js
module.exports = function() {
var use = require('use-plugin')({prefix:'foo',module:module})
return {
use: function( plugin_name ) {
var plugin_properties == use(plugin_name)
// call the init function to init the plugin
plugin_properties.init()
}
}
}
// callingcode.js
var fm = require('myframework')
// this will try to load:
// 'bar', 'foo-bar', './foo', './foo-bar'
// against the framework module, and then the callingcode module
// nice error messages are thrown if there are problems
fm.use('bar')
The module provides a builder function that you call with your desired options. In particular, you should always set your module, as above.
The builder function returns a plugin loader function that you can use inside your framework. Calling the loader function returns an object with properties that describe the plugin.
In particular, the point of this module is to resolve (via require), the init function of the plugin, so that you can call it in your framework.
See the annotated source code for full details.
If you're using this module, feel free to contact me on twitter if you have any questions! :) @rjrodger
Current Version: 0.1.4
Tested on: node 0.10.26
FAQs
Generic plugin loader functionality for Node.js frameworks.
The npm package use-plugin receives a total of 5,872 weekly downloads. As such, use-plugin popularity was classified as popular.
We found that use-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.