Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pnp): handle require.resolve('pnpapi') with exports correctly #3495

Merged
merged 5 commits into from
Sep 29, 2021

Conversation

paul-soporan
Copy link
Member

What's the problem this PR addresses?

When using PnP, calling require.resolve('pnpapi') tries to apply the exports resolution on the pnpapi path, either remapping it if there's a ".pnp.cjs": "./whatever.js" export (which is wrong) or throwing if there isn't such an export.

We originally considered this in #2431 (comment) but thought it wasn't a problem, even though it actually is - the unqualifiedPath is the one that gets resolved to a path in resolveUnqualifiedExport, not the request.

Fixes #3493.

How did you fix it?

Special-cased pnpapi in resolveRequest with an early return.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis arcanis merged commit 2e04683 into master Sep 29, 2021
@arcanis arcanis deleted the paul/fix/exports-pnpapi branch September 29, 2021 13:57
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.

[Bug]: Yarn SDKs requires ".pnp.cjs" property in package.json's exports.
3 participants