DEV Community

Gaurav Saini
Gaurav Saini

Posted on

Help: How to watch for changes in local dependencies in monorepo?

Hey folks,

I am currently setting up a monorepo project using pnpm, turborepo, typescript, and nestjs.

The folder structure is like this

└── my-ts-monorepo/
    ├── apps/
    │   └── server
    └── libs/
        └── utils
Enter fullscreen mode Exit fullscreen mode

The utils library is added as a dependency in the server application.
utils is a simple typescript library with some math functions and server is a NestJS REST API.

Everything is working fine except for one thing. While running the dev server, if I make any code changes in the utils library, the changes are not picked up by the server application.

I tried running the tsc build for the utils library with the --watch flag, but no luck there also.

The dev scripts look like this

/* root package.json */
"dev": "turbo run dev"

/* apps/server/package.json */
"dev": "nest start --watch"

/* libs/utils/package.json */
"dev": "tsc --watch"
Enter fullscreen mode Exit fullscreen mode

Please help me so that the NestJS dev server can pick up code changes in the utils dependency also.

Thanks!

Top comments (2)

Collapse
 
kostyatretyak profile image
Костя Третяк

Try Project References. As an illustrative example, you can use the Ditsmod repository, where this feature has already been implemented.

Collapse
 
gal1419 profile image
Gal Malachi

@sainig what did you end up doing?