Yarn Workspaces: Is there no way to share dependencies / devDependencies across workspaces? #6043
Unanswered
BrandLibel
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my project with yarn 1, I had multiple workspaces:
/components
/apps/*
which contained 3 subdirectories, each "app" workspace depended on/components
My project is a React application and with yarn 1 I installed most dependencies in the root
/package.json
, and these would be shared across all workspaces.For instance I only added the dependency
"react": "~16.9.0",
inside the root/package.json
and didn't need to add it 4 more times in/components/package.json
,/apps/app1/package.json
,/apps/app2/package.json
,/apps/app3/package.json
I'm now in yarn 3.6.4 - is this approach not allowed anymore? I couldn't find explicit documentation about this, but it seems in modern yarn we're required to explicitly define the same dependency across all package.json files in our project. So if we had 10 workspaces I'd have to add
"react": "~16.9.0",
to 10package.json
files, and if I had 50 workspaces I'd have to add it to 50 files.Is this really the case? If so, this is extremely tedious; there are some dependencies that just logically should be shared across all our project workspaces -
react
,lerna
, oreslint
for example. What I've resorted to is copying all the dependencies and devDependencies from my rootpackage.json
into my 4 individual workspacepackage.json
files. At this point I don't want to manually sort them out and decide which workspace actually needs which dependency.Is there really no way around this? Do I have to start telling my team members to install the same dependency 4 times to all our workspaces?
I've looked at this discussion already, but its seems to only be about being able to share scripts: #2825
Beta Was this translation helpful? Give feedback.
All reactions