Volt.HMR.Boundary (Volt v0.14.0)

Copy Markdown View Source

Detects HMR boundaries from the dev module graph and source ASTs.

When a file changes, Volt first checks Volt.HMR.ModuleGraph for served importers and self-accepting modules. If the file has not entered the dev module graph yet, boundary lookup falls back to Volt.HMR.ImportGraph raw specifiers. If no self-accepting boundary is found, the client performs a full reload.

Summary

Functions

Find the HMR boundary for a changed file.

Check if a module's source code contains import.meta.hot.accept().

Functions

find_boundary(changed_path, read_source)

@spec find_boundary(String.t(), (String.t() -> String.t() | nil)) ::
  {:ok, String.t()} | :full_reload

Find the HMR boundary for a changed file.

Walks upward through the module graph from changed_path. Returns {:ok, boundary_path} if a self-accepting module is found, or :full_reload if the change bubbles up to the root without finding a boundary.

The read_source function is called with an absolute path and should return the module's source code for boundary detection.

self_accepting?(source)

@spec self_accepting?(String.t()) :: boolean()

Check if a module's source code contains import.meta.hot.accept().