Override core resolvers with plugin #6658
Unanswered
TrevorBurnham
asked this question in
Q&A
Replies: 1 comment
-
When I asked Claude how to override the core resolvers with my plugin resolver, it suggested this: class CustomResolver extends NpmSemverResolver {
// Add this method to set priority
static get priority(): number {
// Default npm resolver is 50
// Default file resolver is 100
// Use a higher number to override them
return 150;
// Other methods...
} Of course, that Really, though, I'd have expected plugin resolvers to simply come before core resolvers. If they don't know how to resolve something, they can return |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a use case where I want to control the way that a particular package is resolved. I'd imagined that I could do something like this:
To my surprise, though, the custom resolver never gets called for normal-looking dependencies. I was only able to get Yarn to call it by adding a dependency in my
package.json
thatNpmSemverResolver
(and all the other built-in resolvers) don't know how to handle, like:Based on this code, it looks like resolvers and linkers from plugins will always be called after the core resolvers. That seems like a major limitation for plugins. Is that right, or is there something I'm missing?
Related discussion: #2702 The suggestion there was "You can also write a resolver plugin that handles this one particular package," but I don't understand how that would work for the use case proposed there: If the package looks like something that
NpmSemverResolver
can handle, the resolver plugin would be a no-op.Beta Was this translation helpful? Give feedback.
All reactions