webpack-contrib / install-webpack-plugin

Speed up development by automatically installing & saving dependencies with Webpack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Don't install peerDependencies which can be resolved by Webpack

insin opened this issue · comments

If peerDependencies were handled like any other normal module the plugin tries to install and Webpack was able to resolve the package name, they wouldn't be installed.

e.g. when you're using compatibility layers like preact-compat or inferno-compat, they're aliased to 'react', so you don't want the real React to be installed if you import a React component which has React as a peerDependency.

Relevant from the closed PR:

If, instead of being installed up-front, peerDependencies were handled like any other normal module the plugin tries to install and Webpack was able to resolve them package via aliases, fallback module directories etc. they wouldn't be installed.

We can't ignore peerDependencies because Plugin#resolveModule() skips sub-dependencies - could install() return something the plugin could use to check if it should attempt to resolve/install sub-dependencies which are known to be peerDependencies?

Anyone got a module which demonstrates a solid use case for needing to install peerDependencies?

I have a build which disables up-front installation and has lots of debug logging to show what's going on, and it works just fine in example/webpack2 and my nwb preact case.