cssinjs / react-jss-hmr

Hot module replacement for react-jss
MIT License
7 stars 3 forks source link

Deprecation warnings with Webpack 4 - use new plugin api #4

Closed Raghav-Maheshwari closed 5 years ago

Raghav-Maheshwari commented 5 years ago

Hello, I'm encountering a few deprecation warnings when using this plugin with webpack v4: (node:24318) DeprecationWarning: Tapable.plugin is deprecated. Use new API on.hooksinstead at ReactJssHmrPlugin.apply (node_modules/react-jss-hmr/lib/ReactJssHmrPlugin.js:39:16) ...

(node:24318) DeprecationWarning: Resolver: The callback argument was splitted into resolveContext and callback. at Resolver.doResolve (node_modules/enhanced-resolve/lib/Resolver.js:193:15) at Resolver.<anonymous> (node_modules/react-jss-hmr/lib/ReactJssHmrPlugin.js:44:27) ...

(node:24318) DeprecationWarning: Resolver#doResolve: The type arguments (string) is now a hook argument (Hook). Pass a reference to the hook instead. at Resolver.doResolve (node_modules/enhanced-resolve/lib/Resolver.js:199:11) at Resolver.<anonymous> (node_modules/react-jss-hmr/lib/ReactJssHmrPlugin.js:44:27)

It works fine, since the deprecations won't take full effect until the next major webpack release. However I decided to address these deprecation warnings in this PR.

I just replaced the old plugin calls with hooks and new tap calls. It seems to pass the required tests:

screen shot 2018-09-24 at 6 24 15 pm
felthy commented 5 years ago

Thanks for this @Raghav-Maheshwari 👍

I originally wrote this targeting the webpack v4 interface but then I downgraded for compatibility with the current release of create-react-app (which is still on webpack v3).

This is good timing though: according to facebook/create-react-app#5103, create-react-app 2.0 is about to be released. I’ve tested this successfully in a new project bootstrapped from create-react-app 2.0.