Skip to content
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

Use JsonpMainTemplatePlugin.hooks instead of MainTemplate#hooks #7673

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

ooflorent
Copy link
Member

Refactor JsonpMainTemplatePlugin plugin to change how hooks are installed into MainTemplate.
cc @jantimon

What kind of change does this PR introduce?

refactoring

Did you add tests for your changes?

no

Does this PR introduce a breaking change?

yes

What needs to be documented once your changes are merged?

Maybe JsonpMainTemplatePlugin.hooks.

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

@jantimon
Copy link
Contributor

jantimon commented Jul 6, 2018

@sokra @ooflorent I really like that approach and will also use it for the html-webpack-plugin.
Just one thing - some Plugins might provide a hooks object but others will require a context argument.

Imho we should prefix get functions e.g.: getHooks to be more consistent.

JsonpMainTemplatePlugin.getHooks(
vs
compilation.hooks

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jantimon renaming sounds good to me

class JsonpMainTemplatePlugin {
static hooks(mainTemplate) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hooks -> getHooks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. I’ll do it in the other PR also

@sokra
Copy link
Member

sokra commented Jul 8, 2018

Should we add a instanceof MainTemplate check? It's very easy to do it wrong, i. e. JsonpMainTemplatePlugin.getHooks(compilation). This doesn't throw, but also don't work as expected. A instanceof MainTemplate could help by throwing an error.

@webpack-bot
Copy link
Contributor

@ooflorent Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra sokra deleted the refactor/jsonp_hooks branch July 9, 2018 11:19
@sokra
Copy link
Member

sokra commented Jul 9, 2018

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants