@triggery/vite
v0.10.0
Published
Vite plugin for Triggery — auto-imports every *.trigger.ts via a virtual module + HMR. Framework-agnostic (works alongside React, Solid, Vue).
Maintainers
Readme
@triggery/vite
Vite plugin for Triggery — auto-import every *.trigger.ts file via a virtual module.
Install
pnpm add -D @triggery/viteUse
// vite.config.ts
import { defineConfig } from 'vite';
import triggery from '@triggery/vite';
export default defineConfig({
plugins: [triggery({ glob: 'src/**/*.trigger.ts' })],
});Then once at the entry point of your app:
// src/main.tsx
import 'virtual:triggery-registry';That's it — every file matching the glob is auto-imported, so its top-level createTrigger(...) call registers with the default runtime.
Options
| Option | Default | Description |
|---|---|---|
| glob | 'src/**/*.trigger.{ts,tsx,js,jsx}' | One pattern or an array. Anything tinyglobby accepts. |
HMR
- Editing an existing trigger file just re-runs its
createTrigger(...)— the runtime's last-mount-wins replaces the old registration. No special handling needed. - Adding / removing / renaming a trigger file invalidates the virtual module so its import list is rebuilt on the next request.
Documentation
Full documentation, recipes and API reference at https://triggeryjs.github.io/packages/vite/.
Related packages
@triggery/core— Required peer — runtime where discovered triggers register.@triggery/react— Most common combination with this plugin.
See the full package list in the repo README.
License
MIT © Aleksey Skhomenko
