-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Self-service
- I'd be willing to implement a fix
Describe the bug
Thank you for officially introducing the catalogs feature to Yarn :)
I've encountered an issue while using catalogs in Yarn version 4.10.3. One of the Yarn plugins I'm using supports a custom protocol using the reduceDependency
hook. When I use this custom protocol in the catalogs defined in .yarnrc.yml
and run yarn install
, I get the error "xxx isn't supported by any available resolver".
The underlying issue is that the plugin doesn't implement its own resolver. That said, since the plugin works correctly without catalogs, perhaps catalogs could be updated to support this type of plugin implementation?
To reproduce
Assuming the files below are in the same directory, this issue can be reproduced by running yarn plugin import ./plugin-custom-protocol.js
followed by yarn install
.
package.json
{
"name": "name",
"packageManager": "[email protected]",
"dependencies": {
"lodash": "catalog:",
"react": "catalog:"
}
}
.yarnrc.yml
catalog:
lodash: "npm:4.0.0"
react: "custom-protocol:19.0.0"
plugin-custom-protocol.js
module.exports = {
name: 'plugin-custom-protocol',
factory: function(require) {
const {structUtils} = require('@yarnpkg/core');
return {
default: {
hooks: {
reduceDependency(dependency, project) {
if (!dependency.range.startsWith('custom-protocol:')) {
return dependency;
}
const version = dependency.range.slice('custom-protocol:'.length);
return structUtils.makeDescriptor(
structUtils.makeIdent(dependency.scope, dependency.name),
`npm:${version}` // Just custom-protocol maps to npm
);
}
}
}
};
}
};
This issue can be reproduced by cloning this repository and running yarn install
.
Environment
System:
OS: macOS 15.3.1
CPU: (8) arm64 Apple M2
Binaries:
Node: 22.18.0 - /private/var/folders/c9/kkczqw7d28bf31_wkkzmrhpr0000gn/T/xfs-2103861d/node
Yarn: 4.10.3 - /private/var/folders/c9/kkczqw7d28bf31_wkkzmrhpr0000gn/T/xfs-2103861d/yarn
npm: 10.9.3 - ~/.local/share/nvm/v22.18.0/bin/npm
Deno: 2.5.2 - ~/.deno/bin/deno
Additional context
No response