I have a common (or not so coomon) scenario for yarn workspaces and didn't find the right guide for me online.
yarn workspaces look like that:
- monorepo
- packages
- client
- admin
- theme
- lib
- Client is used as our endusers, it is a react project
- Admin is used as backoffice for admin users and it is build in react too
- Theme is used for all the UI kit (components) and storybook. We use the UI kit in
clientandadminproject and this is classic "monorepo style" (lerna) to share components between 2 projects. This folder should be shared only for this project. - Lib is used for all API and shared "Business logic" between multiple projects. I have 4 project which use the same lib functionality for API requests, Authentication, Redux and more.
Additional information:
monorepois root repository with.gitmodules- Each sub folder is a different git repository
- We use workspaces in order to have easy development on
themeand on theclientandadminproject on the same time.
Questions:
We run yarn start only in client project and admin project. Both projects are using the same theme and same lib functionality. Because the lib is shared with other projects, it is updated on a weekly base:
- How I can prevent from it to be updated from project to project? should I work with
tagsin git repository or should I removelibfrom the monorepo worksapce and to work with it asnpm package(the whole point is to have easy development process when we change thelibfile we do not need tonpm updateit again and again. - If
libwill be npm package, How can I tell monorepo to use workspaces when I runyarn startand to use the npm version when I runyarn build?
Please advice on the best practices for this scenario.
Thanks in advance, Leo.