morning, you fine folks! quick/easy question about...
# help
s
morning, you fine folks! quick/easy question about monorepos + yarn workspaces. say I have 4 services in
src/services
, and 2 of them need the same npm dependency. should I run
yarn add somepkg
at the root level, or just do
yarn workspace service1 add somepkg && yarn workspace service2 add somepkg
? in other words, are root level dependencies intended to be shared among workspaces/services.. or should it be reserved only for things pertaining to the SST stack code?
a
depends if you need multiple versions of the same package or want a shared version for all services.
t
The only things I add at root level are dependencies to "run the whole repo" - which really just just sst/cdk stuff
I tend to add them package by package, seems more correct so when working inside a service you can check its package.json to be aware of its dependencies vs magic dependencies coming from a global context
a
yeah, makes sense..
t
That said I can see adding certain dependencies at the root because you want to imply every package should be using the same version, eg
typescript
s
I guess there’s no best practice here. though part of me feels like you should be able to, at any time, extract any service in a monorepo into its own standalone project.. in which case, having shared packages at the root would make that difficult. I guess. I’m just speculating 😄
a
devDependencies especially.
s
ha.
yarn upgrade-interactive
is a bit confused when I have 2 services using the same package at different versions 😄
I should probably open an issue. it should indicate workspace name