-
-
Notifications
You must be signed in to change notification settings - Fork 247
docs: 📖 add hooks documentation #274
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
Conversation
Add documentation on how to use hooks on a compiler instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, who never has used one of these hooks before, the way you use yourPluginName
is not 100% clear. Do I need to write an own plugin to use this? From the code it seems as if it can be used just from the file that instantiates webpack.
Could you add some more information on that part please?
Thanks for the review. Could you please give me some suggestions?
|
In case it helps, here's an example of hooking in: |
From looking at the code, they call it 'name' internally. I guess something like
No, I believe your example is 100% correct. I just wanted to display the confusion that the naming |
Got your point 😅. I will make the changes tomorrow and update this PR |
Explain the purpose of arguments passed to plugin hooks.
Ready for another round of review @phryneas, @johnnyreilly, @piotr-oles 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
Cool! Feel free to merge! |
Awesome! Do we need to do a beta -> master PR now so these changes show up, when people are reading the docs? |
@johnnyreilly yup, see #275. |
🎉 This PR is included in version 1.3.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Do you happen to know off hand why something like this might not work: let config = {...}
let compiler = webpack(config);
new ForkTsCheckerWebpackPlugin().apply(compiler);
const pluginHooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
pluginHooks.receive.tap('some-receive', (d, l) => {
console.log(d);
console.log(l);
});
pluginHooks.emit.tap('some-emit', (d, l) => {
console.log(d);
console.log(l);
});
module.exports = config; Or know off hand how I can bubble up any tslint errors from the forked process? Right now I'm looking at using this in the plugins sections of the webpack config: {
apply: (compiler) => {
compiler.hooks.done.tap('pm-on-emit', (stats) => {
if (stats.compilation.errors.length) {
stats.compilation.errors.forEach(err => console.error(err.message));
process.exit(1)
}
});
}
} |
@allen-munsch yes. You need to get plugin hooks from individual compiler instances, not the whole compiler. Do check the readme and multicompiler section |
Add documentation on how to use hooks on a compiler instance.
See #273