Dev Server

requests in dev mode

In production, all requests hit the server. Requests asking for client assets are simply served statically built files.

In development, most of the work is done by Vite for a better Hot Module Replacement (HMR) experience. So requests asking for client assets are served by Vite, and requests aiming at the server are proxied

Vite dev server on port 3001

Vite proxies /api requests to port 3000

The server esbuild has a proxy server listening on port 3000, and proxies all requests to the server on port 8877

The server esbuild watches the server files and restarts the server on changes. When the server is ready it listens on port 8877

This long chain of requests is necessary to have a good HMR experience for both the client and the server.

  • most requests are served by Vite, which has a very good HMR
  • if the server is currently restarting (there is no HMR for the server, only restarts), the server proxy will stall the request until the server is ready again

dev processes

Before starting

/script

  • 1-time esbuild process for bundling dev plugins

During development

/client

  • vite dev server + vite proxy server (1)
  • tcm CSS module types generation (1)

/assets

  • tsx launches a chokidarwatcher (3)

/worker

  • tsx launches an esbuild watcher (3)

/server

  • tsx launches an esbuild (2)
  • on build, esbuild spawns the app server (1)
  • fastify proxy server (1)

/

  • turbo launches some processes (4)