DEV Community

Create a monorepo using PNPM workspace

Vinodh Kumar on August 15, 2023

Objective To create a mono repo using the PNPM package manager and its workspace feature. The main advantage of the PNPM workspace when...
Collapse
 
patamimbre profile image
Germán Castro Montes

This article is gold. Thanks man

Collapse
 
wolz profile image
Wolz

Amazinnngggg, I learned a lot

Collapse
 
wangxiaoyugg profile image
Garen

awesome article ! I learn how to config a monorepo project

Collapse
 
_dc28803af93dd911b63a2 profile image
worm

太棒了 非常规范的提交 学到了很多

Collapse
 
wulfp profile image
WulfP

Great article!!!

Only one question remains open:

Is it possible to have main.ts in watch-mode with hmr-updates while developing? That would be really helpful!

And maybe -e should be added after echo where .prettierrc.json is created.

Collapse
 
wulfp profile image
WulfP

I found out, that this does the job:
"watch": "concurrently \"tsc --watch\" \"vite build --watch\"",
in ./packages/common/package.json and then (after pnpm add -D concurrently):
pnpm --filter common watch.

But is there a better solution, especially when common grows?

Collapse
 
jesusvallez profile image
jesusvallez

Thank you so much for your article, it is amazing.

I followed your instructions to set up and configure my pnpm monorepo, but I'm encountering an issue using the "common" package in the webapp. When I try to use it, TypeScript can't resolve the path. However, I downloaded your repository, installed it, and it works perfectly, so I believe there might be a specific issue with my setup

Collapse
 
jesusvallez profile image
jesusvallez

My mistake! I copied this:

  "main": "./dist/common.js",
  "types": "./dist/main.d.ts",
Enter fullscreen mode Exit fullscreen mode

into the main package.json file, but I should have added it to packages/common/package.json.

Collapse
 
vinomanick profile image
Vinodh Kumar

Cool :)

Collapse
 
casamia918 profile image
Dev.Casamia

I really thank you. Very clean and well detailed article.

Collapse
 
nyruchi profile image
Pasquale De Lucia • Edited

Very good article!!

The sample is for front-end libraries, but for node back end libraries you have another sample?

Collapse
 
vinomanick profile image
Vinodh Kumar

Thank you. I'm not a backend developer so haven't got the opportunity to try it out. Probably you can try and share it with us. 🙂

Collapse
 
rayenmansouri profile image
Rayen

this seems to be article about eslint instead of monorepo