You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #739 Resolve loaders directly from Encore instead of using their names (Lyrkan)
This PR was merged into the master branch.
Discussion
----------
Resolve loaders directly from Encore instead of using their names
This issue fixes#727 by replacing the use of loader names in rules (for instance `'file-loader'`) by their resolved path (`require.resolve('file-loader')`).
The problem with using their name is that we are assuming that the loader's package will be present at the top-level of `node_modules`.
If for some reason that's not the case and npm/Yarn decides to put it in, let's say `node_modules/@symfony/webpack-encore/node_modules`, the compilation will fail when Webpack tries to require it.
Another reason to do that is to ensure that Webpack uses the right version of a loader. We had some issues before 0.29 because we expected an old version of `file-loader` when some other packages included a newer one that was then used by Webpack because it got hoisted to the top-level `node_modules`.
This change should in my opinion be considered a BC break for people that were:
* adding a different version of a loader we embed into their `package.json`: that one won't be used anymore
* requiring a package that also included one of our embedded loaders: depending on which one was hoisted it could result in a different behavior
* manipulating the generated config and filtering loaders based on their names: the comparison won't be the same anymore (see the tests I had to change)
I also modified dev dependencies loaders for more consistency but it doesn't really matter for those.
Commits
-------
a3e1e94 Resolve loaders directly from Encore instead of using their names
0 commit comments