I build a monorepo using pnpm workspaces and I have trouble getting it work. It uses typescript, vite on frontends, rollup at backend microservices.
Here is the setup:
package.json <== all dependencies reside here
tsconfig.json
pnpm-workspaces.yaml
- commonlib/
package.json, tsconfig.json, rollup.config.js
src/
...interfaces, types etc---
- serverlib/
package.json, tsconfig.json, rollup.config.js
src/
...modules for common server/microservice funtionality---
- weblib/
package.json, tsconfig.json, vite.config.js
src/
...react etc components & functions---
- servers/
srv-gateway/
package.json, tsconfig.json, rollup.config.js
src/
...server code...
ms-xxx/ <== Multiple REST microservices
package.json, tsconfig.json, rollup.config.js
src/
...microservice code...
- webapps/
app/
package.json, tsconfig.json, vite.config.js
src/
...main application code---
admin/
package.json, tsconfig.json, vite.config.js
src/
...application code---
app-2/ <== Other webapps / micro frontends
...
My requirement(s):
My problem(s):
I had a working system beforehand, where I defined @myapp/uilib, @myapp/graphlib etc and used "path" and "references". But as they did increase in number, I wanted to combine them into a single library. This is where I lost track. I made too many changes to revert from a previous git state. The blame goes to many conflicting tutorials I watched & ChatGPT, and of course mainly myself :/
Apperantly I do it all wrong, now I want to learn the correct way.
Thank you in advance for your help.
After a long list of trials, struggles, and performance tests, I decided on these:
This was a long lesson for me in my first monorepo. I'll try to update this post with my structure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With