Skip to content

Extend dev command with turbo watch mode #189

@nnoce14

Description

@nnoce14

Context

CellixJS is a Turborepo monorepo with several apps in the apps/ directory, each with distinct dev server requirements, and multiple TypeScript libraries compiled to dist/. The current root dev script starts all app servers but does not watch or rebuild libraries on code changes, requiring manual restarts for affected apps.

Goal

Extend the root dev script to leverage turbo watch so that app servers stay running and rebuild/restart correctly when libraries or codegen outputs change:

  • All dev servers start and stay running
  • Library source changes trigger affected rebuilds and restart dependent servers
  • gen re-runs only when .graphql or codegen plugin source changes
  • Vite/Docusaurus rely on native HMR and are not restarted by turbo
  • portless proxy start runs before any turbo-managed dev processes, but outside of turbo

Tasks

  • Update root package.json dev script:
    • "dev": "portless proxy start && turbo watch dev gen build"
  • Update root turbo.json:
    • Add futureFlags.watchUsingTaskInputs: true
    • Add a dev task with cache: false, persistent: true, dependsOn: ["^build"]
    • Make task input filters explicit:
      • gen inputs MUST include the negated pattern to exclude generated outputs from triggering itself: include "!src/generated/**" in gen.inputs (i.e., exclude src/generated/ so generated files don't re-trigger gen).
      • build inputs SHOULD be scoped to package source files only, for example: "src/**/*.ts", "tsconfig*.json", and "rolldown.config.ts". This prevents rebuilds on unrelated files and limits watch churn.
  • Update/adjust app turbo.json files:
    • apps/api: set interruptible: true and dependsOn: ["^build", "gen"]
      • Important: gen here is the same-package gen (no caret). That ensures static SDL arrays and resolver manifests exist before func start loads the bundle.
    • apps/server-oauth2-mock: CREATE package-level turbo.json with interruptible: true and dependsOn: ["^build", "build"] so turbo waits for both cross-package builds and the app's own build before starting node dist/index.js.
    • apps/server-mongodb-memory-mock: add dependsOn: ["^build", "build"] but DO NOT set interruptible: true (the in-memory replica must persist for the session to avoid dropping dev data).
    • apps/docs: dev task should be persistent: true, no interruptible, and no dependsOn: ["^build"] (Docusaurus handles content changes natively).
    • apps/ui-community: dev task should be persistent: true, dependsOn: ["^build"], no interruptible (Vite will HMR linked packages without a full restart).

Acceptance criteria

  • pnpm run dev launches the portless proxy and all five app dev servers in the intended order
  • Editing library source rebuilds the library and restarts apps/api; Vite hot-reloads without a full restart
  • Editing a .graphql file triggers gen (which does not self-trigger), then build, then apps/api restarts
  • Editing source in @cellix/server-oauth2-mock-seedwork rebuilds it and restarts apps/server-oauth2-mock
  • Editing source in @cellix/server-mongodb-memory-mock-seedwork rebuilds it but does NOT restart apps/server-mongodb-memory-mock
  • Editing .md files in apps/docs triggers Docusaurus's native reload with no turbo involvement
  • No tasks re-run spuriously during an idle watch session

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions