KEMBAR78
feat: ensure further resolvers get a chance to run by andreialecu · Pull Request #17 · arcanis/pnp-webpack-plugin · GitHub
Skip to content

Conversation

andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Jan 24, 2020

Also adds new plugin to help debug pnp resolver errors. I've updated the README.

Fixes #16

I have tested it and the output looks like this:

image

adds new plugin to help debug pnp resolver errors
@arcanis
Copy link
Owner

arcanis commented Jan 24, 2020

Adding a new plugin is difficult, because it would require to also change CRA, Next, Gatsby, Vue-CLI, etc. Any idea if this can be done in the resolver somehow, thus keeping the public API?

Maybe by hooking at the very last step of the resolver, right before it would throws, and instead throwing the error we would have previously set in the context object?

@andreialecu
Copy link
Contributor Author

andreialecu commented Jan 24, 2020

I've looked through enhanced-resolve and can't find such a hook. There's a .details property on the error object which does include the log message I'm adding here:
https://github.com/arcanis/pnp-webpack-plugin/pull/17/files#diff-168726dbe96b3ce427e7fedce31bb0bcR100

But it doesn't print it to the console.

For context however, the error message PnP is throwing in this case is not really useful. The dependency that's broken and needs a peer to graphql is apollo-link-ws, but PnP shows apollo-utilities.

This is the packageExtension I removed to get the error:

  # apollo-link-ws@*:
  #   peerDependencies:
  #     graphql: "*"

The actual stack trace shown by webpack/enhanced-resolve properly hints to apollo-link-ws though:

image

@andreialecu
Copy link
Contributor Author

Found a workaround, I have tested it on the main project I'm working on and it seems to let resolve.modules|alias work, the unit tests pass, and now the errors are also detailed when there's a dependency problem:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing dependencies onwards to other resolvers

2 participants