Skip to content

[bug]: tsdown --watch cleans dist/ on startup causing race condition in dev mode #8791

@Alex-stack-cell

Description

@Alex-stack-cell

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When running pnpm dev, the dev tasks for all packages use tsdown --watch, which cleans the dist/ directory on startup. Since turbo's dev task depends on ^build to pre-populate dist/, the clean step wipes those outputs before the apps (admin, space, live) can resolve them.

This causes errors like:

Failed to resolve entry for package "@plane/utils". The package may have incorrect main/module/exports specified in its package.json.

and:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../node_modules/@plane/logger/dist/index.mjs'

The turbo pipeline runs ^build before dev, populating dist/. But tsdown --watch (the dev script) cleans dist/ as its first action, creating a window where apps try to import from empty dist/ directories.

Suggested fix

Add --no-clean to all tsdown --watch dev scripts in packages/*/package.json and apps/live/package.json:

- "dev": "tsdown --watch",                                                                                                                                                      
+ "dev": "tsdown --watch --no-clean",                                                                                                                                             
 
The build script still cleans (tsdown default), so production builds remain unaffected. Only the watch mode skips cleaning, relying on ^build outputs already being in place.  

### Steps to reproduce

1. `pnpm clean` (or `git pull` that invalidates turbo cache)                                                                                                                      
2. `pnpm dev`
3. admin, space, and live apps fail to start


Affected packages                                                                                                                                                                 
                                                                                                                                                                                
All 12 packages + apps/live (13 files total).                                                                                                                                     
                                                                                                                                                                              
Environment                                                                                                                                                                       
                                                                                                                                                                              
- Node: v22.22.1                                                                                                                                                                
- tsdown: v0.16.0                                                                                                                                                               
- turbo: v2.8.12                                                                                                                                                                  
- macOS

### Environment

Production

### Browser

Mozilla Firefox

### Variant

Local

### Version

v1.2.0

Metadata

Metadata

Labels

planesync issues to Plane🐛bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions