Skip to content
Classcore/hmrv0.12.0

HmrModuleHandler

Reloads THandler and optional TMiddleware modules on HMR updates.

Call handle() from your HmrAware.onHmr() for standard reload behavior, or write a fully custom onHmr() and skip this class.

This is only useful during development.

class HmrModuleHandler<
    THandler,
    TMiddleware = void,
    TArtifacts = unknown
>

Member visibility

Filter class members by access level.

constructor

Constructs a new instance of the HmrModuleHandler class

HmrModuleHandler(
    options: HmrModuleHandlerOptions<THandler, TMiddleware, TArtifacts>
)

Showing members with Protected visibility and higher.

THandler

THandler

TMiddleware

TMiddleware = void

handle()

Unloads or reloads the modules affected by an HmrUpdateEvent, scoped to the handler and middleware directories. When that unloads something, it also retries every file that failed earlier on a duplicate name.

public async handle(event: HmrUpdateEvent): Promise<void>

trackHandler()

Links the handler to its source file so a later update can unload it.

public trackHandler(
    file: string,
    handler: THandler
): void

trackMiddleware()

Links the middleware to its source file so a later update can unload it.

public trackMiddleware(
    file: string,
    middleware: TMiddleware
): void