Tapable is a small library that allows you to add and apply plugins to a javascript module. It can be inherited or mixed in to other modules. It is similar to NodeJS's EventEmitter class, focusing on custom event emission and manipulation. However, in addition to this, Tapable allows you to have access to the "emittee" or "producer" of the event through callbacks arguments.

Tapable has four groups of member functions:

The different applyPlugins* methods cover the following use cases:


One of webpack's Tapable instances, Compiler, is responsible for compiling the webpack configuration object and returning a Compilation instance. When the Compilation instance runs, it creates the required bundles.

See below for a simplified version of how this looks using Tapable:


var Tapable = require("tapable");

function Compiler() {

Compiler.prototype = Object.create(Tapable.prototype);

Now to write a plugin on the compiler,


function CustomPlugin() {}
CustomPlugin.prototype.apply = function(compiler) {
  compiler.plugin('emit', pluginFunction);

The compiler executes the plugin at the appropriate point in its lifecycle by


this.apply*("emit",options) // will fetch all plugins under 'emit' name and run them.