codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 222 forks source link

Webpack 4: DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead #320

Closed sonicoder86 closed 6 years ago

sonicoder86 commented 6 years ago

I'm submitting a bug report

Webpack version: 4.2.0

Webpack Karma version: 3.0.0

Karma version: 2.0.0

Please tell us about your environment: Linux

Browser: Chrome XX

Current behavior: When using the loader with Webpack 4 I get this error message: DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead. It works, but always show deprecation message.

The corresponding stack trace:

(node:56939) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
    at Plugin.<anonymous> (/Users/home/node_modules/karma-webpack/lib/karma-webpack.js:99:14)
    at Array.forEach (<anonymous>)
    at Plugin (/Users/home/node_modules/karma-webpack/lib/karma-webpack.js:98:16)
    at invoke (/Users/home/node_modules/di/lib/injector.js:75:15)
    at Array.instantiate (/Users/home/node_modules/di/lib/injector.js:59:20)
    at get (/Users/home/node_modules/di/lib/injector.js:48:43)
    at /Users/home/node_modules/di/lib/injector.js:71:14
    at Array.map (<anonymous>)
    at Array.invoke (/Users/home/node_modules/di/lib/injector.js:70:31)
    at Injector.get (/Users/home/node_modules/di/lib/injector.js:48:43)
    at instantiatePreprocessor (/Users/home/node_modules/karma/lib/preprocessor.js:55:20)
    at Array.forEach (<anonymous>)
    at createPreprocessor (/Users/home/node_modules/karma/lib/preprocessor.js:74:20)
    at Array.invoke (/Users/home/node_modules/di/lib/injector.js:75:15)
    at get (/Users/home/node_modules/di/lib/injector.js:48:43)
    at /Users/home/node_modules/di/lib/injector.js:71:14

Expected/desired behavior: No deprecation warning is shown.

The stack trace can be printed out with node --trace-deprecation ./node_modules/.bin/karma start --single-run.

Now this feature is deprecated and it will be removed from Webpack.

michael-ciniawsky commented 6 years ago

https://github.com/webpack-contrib/karma-webpack/releases/tag/v4.0.0-beta.0

sonicoder86 commented 6 years ago

@michael-ciniawsky Can I consider the beta release stable? It may be still an issue until a final release, as the version installed with npm install karma-webpack still shows it.

michael-ciniawsky commented 6 years ago

I released it under the @next tag as beta due to eventual issues with webpack >= v4.0.0 'as a whole' e.g splitChunks (new Dependency Graph). The karma-webpack side of affairs didn't recieve any logical changes besides refactoring to the new plugin system and another upgrade of webpack-dev-middleware to fully support webpack >= v4.0.0 without deprecation warnings.

So if karma-webpack =< v3.0.0 && webpack >= v4.0.0 works with your setup, there shouldn't be any known issues with upgrading tov4.0.0-beta.0