Sharing a copy of a dependency in workspaces with hoisting limits #5647
Unanswered
tomasreimers
asked this question in
Q&A
Replies: 2 comments
-
You can make |
Beta Was this translation helpful? Give feedback.
0 replies
-
If anyone is facing the same issue when using react-native, the solution for was to add the path of the workspace from where the library/component is imported to
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I have created a workspace with the following structure:
The workspace uses node-modules as the linker and has
nmHoistingLimits: workspaces
.The two libraries (
web-app
andcomponents
) both depend on react. In addition, web-app depends on components. However, when I try to build the monorepo, I run into an issue, because both web-app and components depend on react, there are two copies of react included at run time (root/web-app/node_modules/react
androot/component/node_modules/react
). This breaks react.This is resolved if I either use PNP (as both reacts resolve to the same thing) or if I remove hoisting limits (as react is hoisted to the root and now they both depend on
root/node_modules/react
). Without removing hoisting limits (as there are other packages that need them), what else can I do?What comes to mind is I would like react to exist in some common folder (
.yarn/node_modules/react
) and forroot/web-app/node_modules/react
androot/component/node_modules/react
to both symlink there, is that possible?I saw this StackOverflow post: https://stackoverflow.com/questions/66940982/how-do-i-import-a-react-library-from-one-yarn-workspace-into-another-when-hoisti but it seems unresolved, which is why I'm escalating the issue here.
Thanks!
(React was chosen because it's easy to explain, but the same is true for
graphql
and a handful of other libraries.)Beta Was this translation helpful? Give feedback.
All reactions