Closed stevebeauge closed 5 months ago
It's not a peer dependency for users using webpack 5, so you should install it by yourself.
@kdy1 : installing in my project loader-utils
won't work.
The pnpm symlink structure requires to have every dependency known.
If the dependency is optional, you may set peerdependenciesmeta
:
{
"peerDependencies": {
"loader-utils": ">=1.2.3"
},
"peerDependenciesMeta": {
"loader-utils": {
"optional": true
}
}
}
This way, wp5 users won't be required to install the dependency, but it will be available to wp4 users (at least theorically, I never played with such edge case).
If you need a repro I can take a few minutes to create it.
I'm trying to create a minimal repro but in this repro, I don't get the error.
Let me close the issue while I investigate if there's interference with other tools. I'll reopen the issue only if I get a proper repro.
Hello,
When using webpack 4
swc-loader
relies onloader-utils
to work https://github.com/swc-project/pkgs/blob/f035da2969b45ab9b1810fc2b93be9798ccf8069/packages/swc-loader/src/index.js#L12However, this package is not listed in the dependencies explicitly. It may work when using
npm
, because it's a phantom dependency (installed by webpack in the flat node_modules), but when usingpnpm
, it fails because the dependency is not found with:I believe you should declare
loader-utils
as a peer dependency to ensure the package is available.As a workaround,
pnpm
allows tweaking the dependencies of dependencies usingpnpm.packageExtension
field. I was able to get rid of this error using in my package.json file :