Lifecycle hooks the CLI runs around import map generation, modeled on tsdown's hooks.
Each hook may be async; the CLI awaits it. The synchronous library functions ignore hooks.
Example 1
Example 1
// Build generated targets before the scan so they land in the map. import { execSync } from 'node:child_process'; import { defineConfig } from 'jsr:@kjanat/importmapify'; export default defineConfig({ hooks: { 'generate:before': () => execSync('deno task build', { stdio: 'inherit' }), }, });
readonly
generate:before: (context: HookContext) => void | Promise<void>
Runs before the filesystem is scanned. Build pattern targets here so they exist when patterns expand.
readonly
generate:done: (context: HookContext & { readonly
map: ImportMapDocument;
}) => void | Promise<void>
Runs after the map is generated and emitted.