nodemon not watching workspace dependencies
Asked Answered
C

0

7

I use nodemon to watch file changes in a TypeScript Node.JS codebase. When a change is detected, esbuild and esbuild-register are used to transpile the code to CommonJS files and the application restarts.

The application is part of a monorepo with yarn workspaces. I use some code from a shared package in my application.

How can i get nodemon to automatically watch dependencies from the same workspace for changes and trigger a restart?

My workaround is adding the relative path to all used linked dependencies in watch in nodemon.json, but that requires me to manually edit the configuration when I add a local linked dependency.

nodemon.json

{
  "exec": "node -r esbuild-register",
  "ext": "ts,json",
  "watch": [
    "src",
    "../../packages/logger/src",
    "../../packages/helpers/src"
  ],
  "ignore": [
    "node_modules"
  ]
}

package.json

{
  "dependencies": {
    "@app/logger": "*",
    "@app/helpers": "*"
  }
}
Celik answered 8/10, 2022 at 7:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.