@moult/vite
v0.1.2
Published
Vite HMR bridge that maps module updates to Moult lifecycle operations.
Maintainers
Readme
@moult/vite
Vite HMR bindings that map module updates to Moult lifecycle operations.
Installation
npm install @moult/vite @moult/runtime viteRequires Node.js 22 or newer. The host supplies the Vite HMR event source.
Example
The bridge delegates installation, replacement, and removal to the runtime. Import and setup failures therefore preserve the previous active generation.
import { createRuntime } from '@moult/runtime';
import { createViteBridge, type ViteHotSource } from '@moult/vite';
const runtime = createRuntime();
const hot = import.meta.hot as unknown as ViteHotSource | undefined;
if (hot !== undefined) {
createViteBridge({
runtime,
hot,
});
}Features
- Handles
added,changed, andremovedmodule events. - Maps events to
Runtime.install,Runtime.replace, andRuntime.uninstall. - Loads replacement definitions before invoking the replacement transaction.
- Keeps the old generation active when import or setup fails.
- Serializes updates through the runtime lifecycle engine.
- Reports structured failures through the optional diagnostic callback.
- Keeps Vite module-graph objects outside the core runtime.
The host owns the HMR event source and decides how diagnostics are displayed. The bridge does not implement a second lifecycle or replacement protocol.
Public API
The package exports createViteBridge, ViteHotSource, VitePluginUpdate,
VitePluginEvent, ViteBridge, ViteBridgeOptions, and ViteDiagnostic.
Status and documentation
Implemented and published. See the Moult repository, the adapter design, and the lifecycle guarantees.
