Closed Ubernt closed 3 years ago
You are correct. Peer dependencies are an awful user experience. See https://github.com/shama/webpack-stream/issues/241#issuecomment-912825857
Peer dependencies may be a bit complexer, but also provide a lot of improvements when done correctly.
My negative opinion on peer dependencies comes from being on the Grunt and webpack teams as well as maintaining and interacting with many frameworks and plugins but that was awhile ago, so maybe things have changed. If you got some examples of them being done correctly, I would love to see them and copy their work because I have no idea how to do them correctly.
I much prefer just declaring dependencies
that for sure will work with the library and then provide a dependency injection mechanism to override a peer dependency. Maybe the injected version doesn't work but it is explicit to the end developer as they are injecting it. The problem is exacerbated as you add more plugins with overlapping compatible framework versions hence the added resolutions
feature of package installers... but even that fails if not all the plugins are compatible with the resolved framework version. You're stuck waiting on all the maintainers of each plugin to update to progress up in versions.
Hey shama,
with correct I meant more "at the right position, not for everything, just like needed", but that also changed a few times for me :D And while writing the rest of this comment, realized for me it is more a "is it a plugin for something or is it using that something standalone" question.
peer-deps aren't so important imho
package.json
To be honest, don't have that much examples in my mind atm., maybe remembering some in the next days.
immutable
in the future, so this won't be a peer-dependency anymoreWhen using webpack-stream
, then webpack
should be provided by the user imho, as it may integrate into an existing codebase where webpack
already exists or should be used even without webpack-stream
. Like with babel, as webpack-stream is more a plugin for webpack, you don't expect a plugin to include the programm it integrates into.
Side note: the newer npm versions (since v7) warn/fail when installing the wrong peer-dependency, thus some of the DX has been optimized, but that means the published packages need to correctly tell their valid peer-dep versions.
Thank you a lot! Your solution helped me. The solution is: npm install --save-dev webpack
Faced similar error and running npm install --save-dev webpack
did solve the problem. Thanks!
Installing latest webpack-stream package throws an error: Cannot find module webpack/lib/ProgressPlugin. I have removed previous node_modules folder before updating webpack-stream from 6.1.2 to 7.0.0. Has anyone else experienced this problem aswell with the latest version?
I managed to skip this issue by installing latest webpack with "npm install --save-dev webpack". I think webpack-stream package.json is not installing webpack also.