devreload

package
v2.33.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(engine httpx.Router, watchDir string, exclude []string, devServer func() string) (stop func())

Mount registers the SSE + script.js routes on the engine and starts an fsnotify watcher rooted at watchDir. Called from mountFrontend ONLY when NEXUS_DEV=1.

File changes within watchDir trigger a debounced broadcast: 80ms after the last event, all subscribers fire. The debounce coalesces the bursts esbuild typically emits (one .js + one .css + their .map siblings all land within milliseconds) into a single reload signal. devServer (the origin of a live Vite dev server named by the hot file; "" when there is none) is consulted when the debounce fires, and polled for changes of owner; see devReloadGate.

Errors from the watcher are logged and swallowed; the dev loop should not crash the app if fsnotify hits a per-platform limit (e.g. macOS open-file cap).

The returned stop ends the poller and the watcher (the app's OnStop), so an app that stops leaves no goroutine or watch behind.

func WatchDir

func WatchDir() string

WatchDir returns the absolute path of the directory the dev-reload fsnotify watcher should track. Honors the same NEXUS_DEV_ROOT env var nexus.Frontend reads in dev mode so the watcher and the disk-FS swap point at the same tree.

Returns "" when neither the env var nor the working directory resolves — the caller treats "" as "skip the watcher, mount SSE-only". That gracefully degrades to a manual-reload experience instead of crashing the boot.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL