Task runnerIntroduction
Introduction
High-performance monorepo task runner with intelligent caching
Task Runner
High-performance monorepo task runner with intelligent caching, dependency-aware scheduling, and auto-fingerprinting.
@visulima/task-runner provides the core building blocks for running tasks in monorepos with maximum cache hit rates. It supports both explicit input declarations (like Nx) and automatic file access tracking (like Vite Task).
Why Task Runner?
- Two caching modes - Choose Nx-style explicit inputs or Vite Task-style auto-fingerprinting
- Smart lockfile hashing - Lockfile changes only bust cache for affected packages
- Framework env inference - Auto-detects Next.js, Vite, CRA, Gatsby, Nuxt, Expo, and more
- Remote caching - Turborepo-compatible HTTP cache protocol
- Native Rust addon - Optional xxHash-based parallel file hashing
- Dependency-aware scheduling - Topological ordering with priority-based batching
- Incremental hashing - mtime-based change detection for near-instant cache checks
- Affected detection - Git diff-based filtering
- Run summaries - Detailed JSON reports for debugging cache behavior
- Cache diagnostics - Explains exactly why a cache miss occurred
Quick Start
import { defaultTaskRunner } from "@visulima/task-runner";
const results = await defaultTaskRunner(tasks, {
smartLockfileHashing: true,
frameworkInference: true,
globalInputs: ["pnpm-lock.yaml", "tsconfig.base.json"],
globalEnv: ["NODE_ENV"],
}, context);How It Works
- Build the task graph - Define tasks and their dependencies
- Compute cache keys - Hash file contents, env vars, and command arguments
- Check cache - Skip execution if inputs haven't changed
- Execute tasks - Run in parallel, respecting dependency order
- Store results - Cache terminal output and build artifacts for next time
Comparison
| Feature | Task Runner | Nx | Turborepo | Vite Task |
|---|---|---|---|---|
| Input detection | Both modes | Explicit | Explicit | Automatic |
| Output caching | Yes | Yes | Yes | Terminal only |
| Remote cache | Yes | Yes | Yes | No |
| Smart lockfile hash | Yes | No | Yes | No |
| Framework inference | Yes | No | Yes | No |
| Auto-fingerprinting | Yes | No | No | Yes |
| Cache diagnostics | Yes | Partial | No | Yes |
| LRU cache eviction | Yes | No | No | No |
| Graph visualization | Yes | Yes | No | No |
| Run summaries | Yes | No | Yes | No |