Skip to content

Override core resolvers with plugin #6658

Closed Answered by TrevorBurnham
TrevorBurnham asked this question in Q&A
Discussion options

You must be logged in to vote

It turns out that it's already possible to "override" the core resolvers. The trick is to alter the protocol of the dependencies you want to resolve yourself using the reduceDependency hook. Since none of the core resolvers recognize that protocol, your custom resolver will get to handle those dependencies:

class CustomResolver implements Resolver {
  supportsDescriptor(descriptor: Descriptor, opts: MinimalResolveOptions) {
    return descriptor.range.startsWith(CUSTOM_PROTOCOL);
  }

  // other methods...
}

module.exports = {
  name: `plugin-custom-resolve`,
  factory: (): Plugin => {
    return {
      resolvers: [CustomResolver],
      hooks: {
        reduceDependency: async (dependency

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TrevorBurnham
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant