Yarn 3: Hybrid node_modules & pnp - How do local dependencies work?

65 views Asked by At

I followed the instructions for Hybrid PnP + node_modules mono-repo: from the Recipes.

Does that support referencing other packages in the same repository from the workspace for which the node-modules linker is enabled?

Whenever I provide the yarn.lock file as instructed, local packages cannot be resolved any more:

➤ YN0001: │ Error: @local/lib@workspace:^: Workspace not found (@local/lib@workspace:^)
    at St.getWorkspaceByDescriptor (C:\Users\Max\repos\yarn-pnp-react-native\.yarn\releases\yarn-4.0.2.cjs:210:3520)

Sample repository here: yarn-pnp-react-native

Note when configuring the repository as suggested in https://github.com/yarnpkg/berry/issues/4232 local dependencies are resolved correctly. However, then when running yarn in the node-modules linked workspaces, node_module resolution is provided for all workspaces (which I understand as per #4323 to be the intended behaviour).

In any case, I can see only the following options:

  • Do not provide a yarn.lock: Local dependency resolution works, but one gets node_modules all over when running yarn install from the wrong place
  • Provide a yarn.lock: node-modules linker isolated to provided project, but local dependency resolution does not work

Both of these don't solve the requirement of local dependency resolution without 'leaking' the node-modules linker into the other workspaces. Is that possible?

0

There are 0 answers