Skip to content

Support for resolving Yarn Plug 'n Play modules #308

Closed as not planned
Closed as not planned

Description

@empyrical

Do you want to request a feature or report a bug?
Request a feature

What is the current behavior?
Metro does not (yet) have PnP support

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?
I think it would be very handy if Metro had support for resolving Yarn PnP modules.

Not only would there be the benefits you'd get for using it in other project, I believe that if this Yarn feature request is able to be resolved, this could be a reasonable alternative to using symlinks (since they are not able to be supported for technical reasons)

Activity

  1. arcanis commented on Nov 6, 2018

    @arcanis

    It actually already does! We just need to open-source the resolver in a separate package (or make it native, possible) 😃 ping @rafeca

  2. empyrical commented on Nov 15, 2018

    @empyrical
    ContributorAuthor

    Curious how this is going. If the internal resolver is inappropriate for open source, perhaps I could make an attempt at implementing one.

    I think this could probably be a first-class metro feature. Only thing I can't really figure out is a good way to unit test it. Non-PnP mode has really nice virtual filesystem for testing, and this wouldn't be able to make use of that without heavy modification (probably)

  3. vjpr commented on Dec 4, 2018

    @vjpr

    I found it implemented here: 60bad94

  4. dalinarkholin commented on May 5, 2020

    @dalinarkholin

    @arcanis @empyrical was Pnp support removed? Im guessing that is why this is still open?

  5. arcanis commented on May 5, 2020

    @arcanis

    Yep, I think FB removed it about a year ago since they don't use it internally. You should be able to add it back by overriding resolveRequest in your configuration, though.

  6. arlyon commented on May 8, 2020

    @arlyon

    Now that yarn uses pnp by default, can we consider adding it again?

  7. dalinarkholin commented on May 8, 2020

    @dalinarkholin

    @arlyon I just added an example repo with pnp and react native working. Checkout the metro.config.js here: https://github.com/dalinarkholin/react-native-pnp-enabled

    Also my comment here: react-native-community/cli#27 (comment)

    But yes, it would be good to get it back as a option as well :)

  8. Dirklectisch commented on Sep 10, 2020

    @Dirklectisch

    Would it help if I provide a pull request to get this back in? If there is no interest in adding this back in we could create a separate package for it so that at least React Native has a way forward for adopting Yarn 2.

  9. dvicory commented on Sep 10, 2020

    @dvicory

    Would it help if I provide a pull request to get this back in? If there is no interest in adding this back in we could create a separate package for it so that at least React Native has a way forward for adopting Yarn 2.

    I'd love to see this either way, but would use a separate package if metro isn't interested in adding it.

  10. evelant commented on Jan 24, 2022

    @evelant

    Since it's 3 years and counting with no movement on this I'm guessing it's never going to happen. The expo crew seems to worked around it. See here: https://github.com/expo/expo/tree/master/packages/expo-yarn-workspaces

    I was able to use expo-yarn-workspaces to get my vanilla RN app to work in a yarn workspace

  11. self-assigned this
    on Jan 24, 2022
  12. alamothe commented on Jan 25, 2022

    @alamothe

    @evelant Yarn PNP or no?

  13. evelant commented on Jan 25, 2022

    @evelant

    edit: actually, no. I guess yarn had implicitly decided to use node_modules event though it wasn't configured to do so. PnP does not work, but you can use a yarn mono repo with hoisting to a root node_modules via a few autogenerated symlinks with that expo-yarn-workspaces package

  14. Nantris commented on Mar 23, 2023

    @Nantris

    Any update? Yarn 2 has been stable and widely used for years. It would be nice if the React Native ecosystem could get on-board.

  15. robhogan commented on Sep 11, 2026

    @robhogan
    Collaborator

    Metro now (since 0.79.0's default-on symlink support) fully supports modern package managers, including Yarn 2+ with nodeLinker: pnpm and nodeLinker: node-modules. I believe that's most of the ask from folks in this thread. In particular, Metro fully supports workspaces now.

    The specific PnP feature (nodeLinker: pnp) is not supported (it was briefly, between 60bad94, v0.50.0, and 1ff21a8, v0.55.0). It doesn't produce Node.js-compatible node_modules layouts and has its own algorithm that always needs bespoke support. Some other bundlers support it, some (eg TurboPack) don't.

    Supporting it correctly according to Metro's architecture isn't trivial, and isn't a priority.

    Closing as not planned. If folks still want PnP specifically even now that we support symlinks, workspaces etc, please open a new issue. If there's still sufficient interest we might reconsider.

  16. Nantris commented on Sep 12, 2026

    @Nantris

    Thank you for the update @robhogan.

    I created #1928 for people still interested in PnP support (as I certainly am).

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

Metadata

Metadata

Assignees

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