morning, you fine folks! quick/easy question about...
# help
morning, you fine folks! quick/easy question about monorepos + yarn workspaces. say I have 4 services in
, 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?
depends if you need multiple versions of the same package or want a shared version for all services.
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
yeah, makes sense..
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
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 😄
devDependencies especially.
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