Yarn PNP: Possible alternative to `yarn link` for use cases where symlinks won’t work

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

What is the current behavior?
At least as of Yarn 1.12.1, if I try to use yarn link [package name] in a PnP project, it will still create a symlink

If the current behavior is a bug, please provide the steps to reproduce.
I don’t view it as being a “bug”

What is the expected behavior?
For cases like React Native projects (see: facebook/metro#1), symlinks are sadly not an option.

This can be awkward if you would like to yarn link a dependency that you are working on locally. For cases like this, Wix developed a tool called wml that uses Watchman to watch for changes and copy files from the dev folder to a destination folder (e.g. in node_modules). But that has its own set of issues as well. (see the section at the bottom of this article)

If there could be an option for yarn link to instead add a module in an arbitrary location to the pnp lookup file, I think this could be a good alternative to symlinks in cases like this. (I do see people perhaps wanting actual symlinks to be still supported though, so perhaps both behaviours could be supported?)

Metro does not yet have PnP resolver support (as far as I know, at least), and a lot of other parts of React Native don’t yet have support for it, but when they do they could hypothetically take advantage of this.

Please mention your node.js, yarn and operating system version.
Node: 10.11.0
Yarn: 1.12.1
OS: macOS 10.13.6

Author: Fantashit

1 thought on “Yarn PNP: Possible alternative to `yarn link` for use cases where symlinks won’t work

  1. It should also do this for link: dependencies, I think! Which are a much better alternative to yarn link without having to go full workspace.

    We generally don’t recommend yarn link, since 1/ they make the install non-reproducible and 2/ they are poor devx in general (you need to remember to run the command, and/or to remove the links after use).

Comments are closed.