Skip to content

Resolve Yarn Plug'n'Play dependencies in the ESM loader - #2178

Open
Boulea7 wants to merge 1 commit into
TypeStrong:mainfrom
Boulea7:fix/esm-pnp-package-resolution
Open

Boulea7 wants to merge 1 commit into
TypeStrong:mainfrom
Boulea7:fix/esm-pnp-package-resolution

Conversation

@Boulea7

@Boulea7 Boulea7 commented Nov 30, 2026

Copy link
Copy Markdown

Yarn Plug'n'Play exposes dependencies through its resolver. The copy of Node's ESM resolver used by ts-node/esm looks for bare packages under node_modules, so a package can import correctly through Yarn and fail as soon as the ts-node loader is enabled.

Use the issuer's PnP API to locate the declared package. Then use the existing ts-node resolver for its exports, legacy entry points, and extension substitution. The test uses Yarn's ESM loader, a conditional package export, and a .js specifier backed by a local .ts file.

Fixes #1933. Related to #1941 and yarnpkg/berry#7350.

  • The new AVA test fails on unchanged main and passes with this change.
  • Build, pack, dprint, and the relevant ESM loader tests pass on Node 18.20.8.
  • A standalone Yarn 4.14.1 project runs both imports on Node 22.14.0, 22.23.5, 24.14.0, and 26.13.1. It also checks the pnpapi entry, rejection of an undeclared dependency, and package export boundaries.

Prepared and tested with OpenAI Codex assistance.

This branch has not been deployed

No deployments
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.

Support for yarn pnp ESM resolver

1 participant