Hello there ! ![]()
So basically, I’m trying to run a monorepo with applications running with tsx, and packages / dependencies build using tsup, but I’m facing an issue…
Currently, I have a simple dev tasks which is persistent and with disabled cache, and depends on build task to ensure all packages are being built before dev script runs
But, because of the way tsup works, when we start dev script at the same time for both applications and packages, packages are rebuilt on script start before watching for changes, resulting in the applications crashing because those are unable to find build files as the build is still running…
Here are the few files that should be relevant while talking about this issue :
package.json
{
"name": "boilerplate",
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo watch run dev",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"check-types": "turbo run check-types"
}
}
apps/server/package.json
{
"name": "server",
"type": "module",
"private": true,
"scripts": {
"dev": "tsx watch src/index.ts"
},
"dependencies": {
"@workspace/core": "workspace:*"
}
}
packages/core/package.json
{
"name": "@workspace/core",
"type": "module",
"private": true,
"exports": {
"./errors/*": {
"types": "./dist/errors/*.d.ts",
"default": "./dist/errors/*.js"
}
},
"scripts": {
"dev": "tsup --watch"
},
"tsup": {
"entry": [
"src/index.ts",
"src/errors/*.ts"
],
"splitting": false,
"minify": true,
"format": [
"esm"
],
"dts": true,
"sourcemap": true,
"clean": true,
"tsconfig": "./tsconfig.build.json"
}
}
turbo.json
{
"$schema": "https://turborepo.com/schema.json",
"ui": "tui",
"tasks": {
"build": {
"dependsOn": [
"^build"
],
"inputs": [
"$TURBO_DEFAULT$",
".env*"
],
"outputs": [
"dist/**",
".vitepress/dist/**",
".react-router/**"
]
},
"dev": {
"cache": false,
"persistent": true,
"dependsOn": [
"^build"
]
}
}
}
My question is the following, what are your best practices / tips to setup a power full dev script able to run your apps and watch on both your apps and packages without having such an issue ? Is there anything I’m missing ? ![]()
The only solution i found for now is to run dev apps and dev packages in different terminais so I can just wait for the initial build to be finished to start my apps, but I guess there are better options out there ?
Thanks a lot for your help, feel free to ask if you want me to add code, but basically, I kept the default template dev script, and added tsup –watch to my packages, and tsx watch to my apps dev scripts