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
 
wolz profile image
Wolz

Amazinnngggg, I learned a lot

Collapse
 
patamimbre profile image
Germán Castro Montes

This article is gold. Thanks man

Collapse
 
wangxiaoyugg profile image
Garen

awesome article ! I learn how to config a monorepo project

Collapse
 
_dc28803af93dd911b63a2 profile image
worm

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

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
 
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
 
rui_peng_4688fe545ae28098 profile image
rui peng

致敬!

Collapse
 
casamia918 profile image
Hichoi-Dev

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

Collapse
 
danielo515 profile image
Daniel Rodríguez Rivero

Thank you. There are not many references about how to configure eslint 9 in a mono-repo. I don't know where you got the information from, because in the eslint docs there is not a single reference.

Collapse
 
mohammed_usmanmohammed_f profile image
mohammed usman Mohammed

Thank you so much 👍

Collapse
 
rayenmansouri profile image
Rayen

this seems to be article about eslint instead of monorepo

Collapse
 
uwais_jawed_7042920deac5c profile image
Uwais Jawed

I feel the other parts were exaggerated too much upon. The focus could have been more on workspaces.

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. 🙂