Skip to content
Pitlane

hot

Interfaces

BrowserEvent

An event for the browser HMR client. A reload is the only one content sends.

Properties

files?
ts
optional files?: string[];
type
ts
type: "reload";

BrowserHmrChannel

The part of remix/node-hmr's BrowserHmrChannel this module uses.

Declared structurally rather than imported, because importing the module that declares it would pull a Node-only dependency into every bundle this package reaches. hotContent holds the only import of it, loaded on demand behind its guard.

Properties

url
ts
readonly url: string;

Methods

close()
ts
close(): void;
Returns

void

onFileEvents()
ts
onFileEvents(handler): () => void;
Parameters
handler

(events) => Promise<readonly BrowserEvent[]>

Returns

() => void

updateWatchedFiles()
ts
updateWatchedFiles(delta): void;
Parameters
delta
add

readonly string[]

remove

readonly string[]

Returns

void


FileEvent

A file change the supervisor's watcher observed.

Properties

event
ts
event: "add" | "change" | "unlink";
filePath
ts
filePath: string;

Functions

hotContent()

ts
function hotContent(content): Promise<void>;

Reloads the browser when a file behind a collection changes.

Call it once, beside createContent, and leave it in for production: it does nothing unless remix/node-hmr is supervising the process, which is what a dev command does and a production server does not. That is also why the import below is loaded on demand. remix/node-hmr/runtime is Node-only and can only be imported by a supervised child, so a static import would follow this module into a Worker bundle.

Parameters

content

Record<string, unknown>

The object createContent returned.

Returns

Promise<void>