Framework
HmrContext
Interface: HmrContext
Context provided to HMR hooks. Runs in PARALLEL with a 5-second timeout. Hook errors are caught and logged but never crash the server.
Example
// src/robo/hmr.ts
import type { HmrContext } from 'robo.js'
export const config = {
namespaces: ['server'],
routes: ['api']
}
export default async function (context: HmrContext) {
context.logger.info(`HMR: ${context.changeType} - ${context.files.join(', ')}`)
// Custom logic: clear caches, notify services, etc.
}Properties
| Property | Type | Description |
|---|---|---|
changeType | "change" | "add" | "remove" | Type of file system change that triggered HMR. - 'change': File was modified - 'add': New file was added - 'remove': File was deleted |
env | typeof Env | Environment variable access. |
files | string[] | Source files that changed (relative paths from project root). Example ['src/api/users.ts', 'src/api/posts.ts'] |
logger | Logger | Logger instance (forked for plugins). |
mode | string | Current runtime mode (e.g., 'development', 'production'). |
routes | HmrRouteInfo[] | Routes affected by the HMR event. Already filtered by hook's config.namespaces and config.routes if specified. |
