symfony / webpack-encore

A simple but powerful API for processing & compiling assets built around Webpack
https://symfony.com/doc/current/frontend.html
MIT License
2.23k stars 198 forks source link

Warn when the Webpack version in package.json differs from Encore's supported version, not when it's present #1038

Open tropicalraisel opened 3 years ago

tropicalraisel commented 3 years ago

This would help to fix all the build warnings related to packages that have Webpack as a direct dependency. In Yarn 2, Webpack actually needs to be defined, otherwise it will crash.

Kocal commented 3 years ago

What's the issue reported by Yarn 2?

tropicalraisel commented 3 years ago

@Kocal The error is logged as an "ambiguous error," since a dependent has a dependency that is not listed in the package.json, such as webpack.

Kocal commented 3 years ago

But webpack is a dependency of Encore. Are you saying that we will have to install all Encore dependencies manually because of Yarn 2? Or am I missing something?

tropicalraisel commented 3 years ago

It's a little strange, and I don't understand it fully myself. My first ambiguous error encounter occurred after trying to add workbox-webpack-plugin, and had to list webpack in my package.json to fix it. Another example is stylelint wanting postcss-html.

stof commented 3 years ago

@Kocal the issue is that the project itself will be responsible for installing some of the webpack plugins, and they need to share the same webpack instance. I'm convinced that webpack should be handled as a peer dependency instead (and also that all webpack plugins should have a peer dependency on webpack instead of a dependency, for the same reason than Postcss did it in their version 8).

Kocal commented 3 years ago

@stof thank for the explanation. This is what I believe too, plugins and librairies for X should not directly depends of X but have a peer dependency to X instead.