-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop - Plugin API - Tapable: The Building Blocks #36
Comments
Tapable is small module that allows you to add and apply plugins to a javascript module. It can be inherited or mixed in to other modules. Provides two kind of functions
The different apply functions cover the following use cases -
For eg - Webpack has something called a Compiler, which compiles all the webpack config and converts it into a compilation instance. When the compilation instance runs, it creates the required bundles. Now Compiler needs to register and execute plugins on itself. It may do this in the following manner using var Tapable = require("tapable");
function Compiler() {
Tapable.call(this);
}
Compiler.prototype = Object.create(Tapable.prototype); Now to write a plugin on the 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. |
Awesome start @pksjce !!!! Id love To see What other |
Thanks for the feedback! How about something like. Tapable is fundamental to the working of webpack. This is because all the moving components of webpack like The whole of webpack runs as a set of state machines along with all logic pushed to internal Plugins. This framework allows webpack to be very flexible. One can achieve almost any transformation on the build files at any of the numerous lifecycle points by registering a plugin at the right lifecycle event. |
One thing is missing -- the And the explanation is a little misleading:
@pksjce , i borrow some concepts from yours. Here is another version of my understanding:
It doesn't have full implementation as the Basically, it has four groups of member functions:
The different
|
Could someone aggregate the ideas of this thread into a PR? Good to review there. |
Wow it had been awhile since I had reviewed this content I'll start adding this to my pr this week. |
Alright created a new set of documents #361 This should allow us once merged to tackle individual tapable instances etc. |
安装 webpack
It seems this is complete with the |
WIP
The text was updated successfully, but these errors were encountered: