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

Support for resolving Yarn Plug 'n Play modules #308

Open
empyrical opened this issue Nov 6, 2018 · 13 comments
Open

Support for resolving Yarn Plug 'n Play modules #308

empyrical opened this issue Nov 6, 2018 · 13 comments
Assignees

Comments

@empyrical
Copy link
Contributor

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)

@arcanis
Copy link

arcanis commented Nov 6, 2018

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

@empyrical
Copy link
Contributor Author

empyrical commented Nov 15, 2018

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)

@vjpr
Copy link

vjpr commented Dec 4, 2018

I found it implemented here: 60bad94

@dalinarkholin
Copy link

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

@arcanis
Copy link

arcanis commented May 5, 2020

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.

@arlyon
Copy link

arlyon commented May 8, 2020

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

@dalinarkholin
Copy link

dalinarkholin commented May 8, 2020

@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 :)

@Dirklectisch
Copy link

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.

@dvicory
Copy link

dvicory commented Sep 10, 2020

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.

@evelant
Copy link

evelant commented Jan 24, 2022

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

@robhogan robhogan self-assigned this Jan 24, 2022
@alamothe
Copy link

@evelant Yarn PNP or no?

@evelant
Copy link

evelant commented Jan 25, 2022

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

@Nantris
Copy link

Nantris commented Mar 23, 2023

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.

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

No branches or pull requests