Search code examples
node.jsgitarchitecturegit-submodulesyarn-workspaces

Submodules as yarn workspaces


I've read that workspace packages should not be git submodules (source1, source2).

e.g. this setup restricts the content of packages

root
├── packages
│   ├── package1 # a yarn workspace - should not be a git submodule
│   ├── package2 # a yarn workspace - should not be a git submodule
│   └── package3 # a yarn workspace - should not be a git submodule

Can anyone explain why workspaces should not be git submodules? It seems like a reasonable solution to me when I have one central integration repo that needs to pull in various other repositories that will share node_modules if they are setup as workspaces.

An integration dev repo would then simply be a top level framework that contains lint settings, a dev docker, etc. It would always have the latest working submodules pinned to it via commits.


Solution

  • Using submodules as workspaces is an ok thing to do, both with yarn and npm workspaces.