interface WatchState

Build bookkeeping owned by the file watcher, used to decide whether a filesystem event should dispatch a rebuild. Watch mode runs exactly one group, so nothing here is contended.

import * as RunState from './setup/run-state.ts';

const { watch } = RunState.create();
watch.lastBuildEndMs; // 0 — no successful build yet, nothing to debounce against

Properties

building: boolean

true while esbuild is actively compiling.

pendingBuildTrigger: (() => void) | null

Queued build-trigger callback; fires once the in-progress build completes.

justAddedFiles: Set<string>

File paths added since the last build, used to decide whether a rebuild is needed.

Timestamp (ms) of the most recent successful build, used for debounce logic. 0 before the first build.

builtContentHash: Record<string, string>

Per-file content hash of what was last dispatched to a build. Both the fs.watch change handler and the macOS/Deno rescan compare against this instead of mtime — mtime has 1-second resolution on some filesystems (macOS/HFS+), so rapid same-second writes with different content are indistinguishable by mtime; the hash catches them and drops echoes.

justAddedAt: Map<string, number>

filePath → ms of when each file was last processed as an 'add', so a 'change' echo arriving inside ADD_SUPPRESS_WINDOW_MS can be suppressed.

Usage

import { type WatchState } from "lib/types.ts";