Skip to content

Enable PnP by default if within a PnP environment? #199

@arcanis

Description

@arcanis

This is a followup to #174. In this PR, we've implemented normalize-options.js as a way for third-party runtimes to hook into resolve by default and modify its default options.

It worked really well, and unlocked many packages - Babel being an important one. I just found out, however, that it doesn't work with one particular project: Next.js. For some reason, Next precompiles resolve and thus causes normalize-options.js to disappear, leaving no chance to the hook to override it.

There are a few options to solve that on their side, but I wonder: could/should resolve improve its support? Since 2018 a lot of new projects have adopted PnP, including enhanced-resolve from Webpack. Coupled to the fact that:

  • This behaviour is in essence already enabled by default for everyone using PnP
  • It doesn't affect at all people that don't use PnP
  • The PnP API has been very stable for a while now
  • PnP will be the default in Yarn 2+

How would you feel about adding the PnP logic into resolve itself if process.versions.pnp is detected (we would still have forceNodeResolution to prevent it, just like it is at the moment)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions