-
-
Notifications
You must be signed in to change notification settings - Fork 246
Difficulty with webpack multi-compiler and plugin hooks #273
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
Comments
I wasn't actually aware of the multi compiler thing at all, so a docs PR would definitely be appreciated! Changing the behaviour in the way you suggest seems potentially useful. It would be backwards compatible by the sounds of it. If you're game, maybe we could get a docs PR first. Merging that should be no problem at all. Then if you wanted to raise a prospective pr which implements the changes you suggest and the team can collaborate with you on this? We'll see where it leads! |
That sounds like an idea. I will work on the docs first from my understanding. I will also show you the code which is responsible to properly hook into this plugin for both single compiler and multi-compiler. Maybe we can proceed from there. |
So this is the piece which determines whether it is a multi-compiler or not. if ('compilers' in compiler) {
// It is a multi-compiler instance
// so tap the hook for every instance
((compiler as any).compilers as webpack.Compiler[]).forEach(
sCompiler => {
this.addTsHooks(sCompiler, ForkTsCheckerWebpackPlugin);
}
);
} else {
// single compiler instance, so just tap one
this.addTsHooks(compiler, ForkTsCheckerWebpackPlugin);
} I don't know of any other method to figure out the type of compiler it is. I will work on the docs for hooks. |
cc @sokra @TheLarkInn - do have any thoughts on this? Feels like there might be something worth considering in here around the general webpack compiler hooks API? |
@swashata |
Hi @piotr-oles I will take a look once I get a chance. |
Feature motivation
Right now, the way the plugin's hook system and webpack multi-compiler works, it makes it quite difficult to actually get the plugin hooks. For example, let's say we have
In such multi-compiler setup, we can not hook into fork-ts-checker hooks from the multi-compiler instance.
Feature description
However, we can loop over
compilers
property to get the actualcompiler
where the plugin is attached.Feature implementation
So I was thinking maybe the
ForkTsCheckerPlugin.getCompilerHooks
could be a bit intuitive to support multi-compiler out of the box. Internal implementation could be like thisMaybe this would be a bit out of scope, but I think and helper would be really nice here. Something like
In any case, a little documentation on usage of the hooks would be really nice. I was trying to implement async typechecking and custom error reporting for a multi-compiler friendly webpack setup on my tooling and I really needed to dig through the source code to findout how and why things work.
The text was updated successfully, but these errors were encountered: