Plug and Play is a tool targetting library and application authors to introduce a plugin architecture in their Node.js source code.
It simplifies complex code execution with well-defined interception points, we call them hooks, and it provides the library users the ability to extends, fix, and alter the execution flow of a code without changing it.
The library is released on the NPM registry under the MIT License.
The library supports both ESM and CommonJS. Whichever the module system, it exports a plugandplay
function to create a new instance.
With ESM:
import { plugandplay } from 'plug-and-play'
With CommonJS:
const { plugandplay } = require('plug-and-play')
Note, internally, the code is written in ESM.
It was originally developped inside Shell, a CLI toolkit, and was later enhanced inside Nikita, an automation and deployment toolkit.