triggery (Vite plugin)
Stable · since 0.1.0
A Vite plugin that globs every *.trigger.{ts,tsx,js,jsx} file in the project at build time and generates a virtual module — virtual:triggery-registry — that imports all of them. Import the virtual module once at your app entry point and every trigger registers itself with the runtime automatically; no manual wiring, no per-file import './foo.trigger' lines.
HMR-aware: editing an existing trigger file re-runs its createTrigger(...) call and the runtime’s last-mount-wins replaces the old registration. Adding, removing, or renaming a trigger file invalidates the virtual module so the import list is rebuilt on the next request.
Import
Section titled “Import”Signature
Section titled “Signature”Options
Section titled “Options”| Field | Type | Default | Description |
|---|---|---|---|
glob | string | readonly string[] | 'src/**/*.trigger.{ts,tsx,js,jsx}' | Pattern(s) for trigger files. Resolved relative to the project root reported by Vite. |
Examples
Section titled “Examples”Default — drop into vite.config
Section titled “Default — drop into vite.config”Then in your app entry:
Custom glob
Section titled “Custom glob”Multiple globs
Section titled “Multiple globs”Typing the virtual module
Section titled “Typing the virtual module”Add to a global .d.ts so TypeScript stops complaining about the bare-string import:
Related
Section titled “Related” createTrigger The constructor each `*.trigger.ts` file calls.
createRuntime Triggers register against the default runtime by default.
Vite project layout guide Conventions for organizing trigger files.
CLI scaffold trigger Generate a new `*.trigger.ts` from the terminal.