Struggling to set up a monorepo using pnpm workspaces with typescript, vite for frontends, and rollup for backend microservices. Here's the current project structure:
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 functionality---
- weblib/
package.json, tsconfig.json, vite.config.js
src/
...react 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
...
Looking for some guidance on how to best organize my setup:
- Managing all dependencies in root package.json
- Accessing modules like @myapp/commonlib, @myapp/weblib, etc.
- Avoiding publishing to npmjs as these libraries are not meant for public use
- Handling multiple versions of dependencies and various module formats (cjs, es, esm)
Facing challenges understanding package.json, tsconfig.json, rollup.config.json, and vite.config.json files - it feels overwhelming. Do I need to compile/transpile the libraries or include them differently?
- Should I version and bundle the libs, or simply reference them?
- If referencing, how should I do it? Using paths and references in servers/webapps?
- In weblib, excluding external packages during compilation caused issues - now the webapp is not displaying correctly.
Previously had a system working with individual libraries (@myapp/uilib, @myapp/graphlib) using paths and references but wanted to consolidate into a single library, leading to confusion. Looking for advice on correcting these missteps.
Tried following conflicting tutorials and suggestions from ChatGPT, ultimately creating more chaos. Ready to learn the right way forward. Appreciate any insight you can provide.