Installation
Usage
Import and use the hot update plugin in your Vite configuration:vite.config.ts
API
workflowHotUpdatePlugin(options)
Vite plugin that watches for workflow/step file changes and triggers rebuilds during development.
Plugin configuration options.
Builder instance or a getter function.Use a getter function when the builder is created lazily (e.g., in Nitro where it depends on the nitro object).Examples:
Optional build queue function to prevent concurrent builds.If not provided, builds will run directly without queuing.Example:
How It Works
The plugin monitors file changes during Vite’s HMR (Hot Module Replacement) process:- File Detection: Watches for changes to
.ts,.tsx,.js,.jsx,.mjs,.cjsfiles - Pattern Matching: Scans file content for:
"use workflow"directive"use step"directive@workflow/serdeimportsSymbol.for('workflow-serialize')orSymbol.for('workflow-deserialize')
- Rebuild Trigger: When patterns are detected, triggers the builder to regenerate workflow routes
- HMR Passthrough: Lets Vite handle normal HMR for the changed file
Exclusions
The plugin automatically skips:- Non-JavaScript/TypeScript files
- Generated workflow route files (prevents infinite rebuild loops)
- Files in
.well-known/workflow/paths
Integration Examples
With Custom Builder
vite.config.ts
With Lazy Builder
vite.config.ts
Usage in Other Integrations
This plugin is used internally by:@workflow/astro@workflow/sveltekit@workflow/nitro(via Vite mode)
@workflow/rollup for complete workflow support.