plugin-webpack: reference webpack loaders with require.resolve for yarn pnp compat #1611
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replaces implicit Webpack loader resolution (e.g.
loader: 'babel-loader'
) with an explicitrequire.resolve
call (e.g.loader: require.resolve('babel-loader')
). This should be a noop for regular npm/yarn installs, but is required when using Yarn 2 PnP andpnp-webpack-plugin
(because Yarn 2 overrides Node's module resolution, but not Webpack's enhanced-resolve).Context: https://github.com/arcanis/pnp-webpack-plugin#usage
In my project, I'm using Yarn 2 and
pnp-webpack-plugin
like so:Before this patch, the build fails with
Entry module not found: Error: Can't resolve 'babel-loader'
. After applying my changes, it succeeds.Changes
Loader paths are resolved with
require.resolve
instead of Webpack'senhanced-resolve
.Testing
Existing tests pass. A real regression test (that installs the required packages under pnp) would be complex, and doesn't seem like it would provide a ton of value.
Docs
No documentation, since this is a bug fix.