Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

fix(index): tapable deprecation warnings (webpack >= v4.0.0) #238

Merged
merged 1 commit into from
Feb 23, 2018
Merged

Conversation

ai
Copy link
Contributor

@ai ai commented Feb 23, 2018

Right now the plugin shows this warning when I try to run it with webpack 4.0.0-beta2:

DepreciationWarning: Tappable.plugin is deprecated. Use new API on `.hooks` instead

This fix will support both webpack 3 and webpack 4 APIs without any warning. This way to deal with the API is recommended by @sokra webpack-contrib/webpack-bundle-analyzer#154 (comment)

I need this PR to add .mjs support to Size Limit ai/size-limit#42

@michael-ciniawsky nice to see you here, you do a lot of work =^_^=

@ai
Copy link
Contributor Author

ai commented Feb 23, 2018

I tested this changes in Size Limit branch and everything works.

@ai
Copy link
Contributor Author

ai commented Feb 23, 2018

The diff is a little bit tricky. I just move logic to functions and make if with different API to bind functions: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/pull/238/files#diff-1fdf421c05c1140f6d71444ea2b27638R243

@michael-ciniawsky michael-ciniawsky changed the title Fix webpack 4 warning fix(index): deprecation warnings (webpack >= v4.0.0) Feb 23, 2018
Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

@ai Thx

src/index.js Outdated
};

if (compiler.hooks) {
const name = 'uglifyjs-webpack-plugin';
Copy link
Member

Choose a reason for hiding this comment

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

- const name = 'uglifyjs-webpack-plugin';
+ const plugin = { name: 'UglifyJSPlugin' };

// ...hook.tap(plugin, cb)

Copy link
Member

Choose a reason for hiding this comment

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

'\n'

src/index.js Outdated
compiler.hooks.compilation.tap(name, (compilation) => {
if (this.options.sourceMap) {
compilation.hooks.buildMobule.tap(name, buildMobuleFn);
}
Copy link
Member

Choose a reason for hiding this comment

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

'\n'

compiler.plugin('compilation', (compilation) => {
if (this.options.sourceMap) {
compilation.plugin('build-module', buildMobuleFn);
}
Copy link
Member

Choose a reason for hiding this comment

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

'\n'

@ai
Copy link
Contributor Author

ai commented Feb 23, 2018

@michael-ciniawsky \n was added, plugin was used, commit message was changed to common scheme

@michael-ciniawsky michael-ciniawsky changed the title fix(index): deprecation warnings (webpack >= v4.0.0) fix(index): tapable deprecation warnings (webpack >= v4.0.0) Feb 23, 2018
@michael-ciniawsky michael-ciniawsky merged commit 23b1b38 into webpack-contrib:master Feb 23, 2018
@michael-ciniawsky
Copy link
Member

Released in v1.2.1 🎉 Thx

@ai
Copy link
Contributor Author

ai commented Feb 23, 2018

Thanks to be sooooo fast 😺

@michael-ciniawsky
Copy link
Member

For sure, these annoying warnings... 😛

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

Successfully merging this pull request may close these issues.

2 participants