Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Fix Tapable 1.0.0 deprecation. #142

Merged
merged 4 commits into from
Mar 28, 2018
Merged

Fix Tapable 1.0.0 deprecation. #142

merged 4 commits into from
Mar 28, 2018

Conversation

neolitec
Copy link
Contributor

@neolitec neolitec commented Mar 5, 2018

Avoid deprecation warning with Webpack 4:
(node:6257) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

@jdalton jdalton added the bug label Mar 5, 2018
@jdalton
Copy link
Member

jdalton commented Mar 5, 2018

This breaks Node 4 compat.

@jdalton
Copy link
Member

jdalton commented Mar 6, 2018

I can't remove Node 4 support for this. Is there a way to support both APIs?

@neolitec
Copy link
Contributor Author

neolitec commented Mar 6, 2018

Hum I understand... maybe by detecting if hooks property exists. I'll take a look at this ;)

@neolitec
Copy link
Contributor Author

neolitec commented Mar 6, 2018

Added compatibility with Webpack 3 (and 2, it seems to work...)
And Webpack 4 cannot work with Node 4 so this configuration is excluded from Travis builds.

src/index.js Outdated
/* Webpack >= 4 */
if (compiler.hooks) {
compiler.hooks.normalModuleFactory.tap('normal-module-factory', (nmf) => {
nmf.hooks.afterResolve.tapAsync('after-resolve', afterResolveFn)

Choose a reason for hiding this comment

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

Instead of normal-module-factory and after-resolve you should pass LodashModuleReplacementPlugin. By doing this, the ProfilingPlugin will accurately show where the time is spent.

Choose a reason for hiding this comment

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

In webpack 4, you can use synchronous callbacks for async hooks:

nmf.hooks.afterResolve.tap('LodashModuleReplacementPlugin', data => {
  if (data) {
    data.resource = resolve(data)
  }
  return data
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tips :)

@creage
Copy link

creage commented Mar 28, 2018

Could we have this PR accepted, please?

@creage
Copy link

creage commented Apr 10, 2018

Thank you, but how about releasing/publishing a new version now?

jdalton pushed a commit that referenced this pull request Apr 13, 2018
* Fix Tapable 1.0.0 deprecation.

* Restrict to node >= 6.11.5 and remove Node 4 build

* Fix Webpack < 4 compatibility and improve Travis config

* Use tap instead of tapAsync for afterResolve async hook
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

4 participants