turbo v2 preffered node watch approach #8434
Replies: 5 comments 3 replies
-
There is some commentary here and below there that I think might help you along. Let me know if there's more I can do to help. |
Beta Was this translation helpful? Give feedback.
-
I tried a lot of combinations, also from the linked ticket but I was unable to find anything that works for my use case up until now.. My full project structure is 2 apps (frontend/backend) + 8 packages (used in other packages or the apps) This is my turbo.json now:
I changes all my dev scripts in the packages to no longer include the --watch flags so now I have:
apps/frontend/package.json
apps/backend/package.json
With this setup I am able to run I also tried with the As I understood from the linked post it might not be possible to have these scripts that serve an application / server to reload when one of their dependant packages are changing or am I still missing something ? |
Beta Was this translation helpful? Give feedback.
-
I might have found a work around for now. Since the packages are now being watched and rebuild by turbo I was able to add these to the nodemon watch array:
By including all the packages that are defined in the dependency array, nodemon now triggers rebuilds when a package was updated. This is ofcourse not ideal since we have to keep nodemon in sync with the dependencies but it looks like the only solution I could find. Would love to know what would be the prefered way to have a node app watching for package changes and rebuild / serve on update. |
Beta Was this translation helpful? Give feedback.
-
I'm also interested in a solution for this. I have settled on a similar workaround but I'm using tsup as opposed to nodemon. The dev script in my app's package.json is defined as such: "dev": "tsup --onSuccess \"node dist/app.js\"", The watch: [".", "../../node_modules/@myrepo/**/**.js"] By configuring tsup to watch Also just to note. You can see in the create-turbo kitchen-sink example:
This is the behaviour I'm looking for, I would like the "api" app (and any other app importing the logger package) to rebuild when a change is made to the logger. At risk of speaking for them, I believe this is also what @pieterjandebruyne is after. Perhaps the solution is just to configure our bundler like we've done and it's not really something Turborepo should be solving. I don't know but I hope my example has clarified things a little. |
Beta Was this translation helpful? Give feedback.
-
I built a tool called |
Beta Was this translation helpful? Give feedback.
-
Summary
I used nodemon + tsc before to watch and serve my node backend code. Now with watch introduced in turbo v2 I tried to run it with the turbo watch dev command.
I do have some issues, first one is when I set turbo.json config for a task like this:
I have 2 apps: create react app frontend & node backend
I also have a package "shared-utils"
Because they both have shared-utils as a dependency, I would expect both watchers to re-run when I make changes to the shared package.
At the moment though only the frontend is reloading and the backend does not rerun when making changes to the shared package.
What is the preffered way in turbo v2 to watch for node code ?
Backend script:
"dev": "nodemon",
nodemon config:
The frontend uses:
"dev": "react-scripts start"
The shared-utils uses:
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
Both have shared-utils as dependency.
Is nodemon compatible with the watch of turbo v2?
What tools / scripts would be advised to work with node + turbo v2 watch ?
Additional information
when I run
turbo watch dev
Beta Was this translation helpful? Give feedback.
All reactions