Skip to content

Commit 3af1f2a

Browse files
committed
add README for vite_task_plan
1 parent e47e574 commit 3af1f2a

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

crates/vite_task_plan/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# vite_task_plan
2+
3+
Execution planning layer for the vite-task monorepo task runner. This crate converts abstract task definitions from the task graph into concrete execution plans ready for execution.
4+
5+
## Overview
6+
7+
`vite_task_plan` sits between [`vite_task_graph`](../vite_task_graph) (which defines what tasks exist and their dependencies) and the actual task executor. It resolves all the runtime details needed to execute tasks:
8+
9+
- Environment variables (fingerprinted and pass-through)
10+
- Working directories
11+
- Command parsing and expansion
12+
- Process spawn configuration
13+
- Caching metadata
14+
15+
## Key Concepts
16+
17+
### Execution Plan
18+
19+
The main output of this crate is an [`ExecutionPlan`](src/lib.rs), which contains a graph of task executions with all runtime details resolved.
20+
21+
```rust
22+
let plan = ExecutionPlan::plan(plan_request, cwd, envs, callbacks).await?;
23+
```
24+
25+
### Plan Requests
26+
27+
There are two types of execution requests:
28+
29+
1. **Query Request** - Execute tasks from the task graph (e.g., `vite run -r build`)
30+
- Queries the task graph based on task patterns
31+
- Builds execution graph with dependency ordering
32+
33+
2. **Synthetic Request** - Execute on-the-fly tasks not in the graph (e.g., `vite lint`)
34+
- Generated dynamically with provided configuration
35+
- Used for built-in commands
36+
37+
### Execution Items
38+
39+
Each task's command is parsed and split into execution items:
40+
41+
- **Spawn Execution** - Spawns a child process
42+
- Contains: resolved env vars, cwd, program/args or shell script
43+
- Environment resolution for cache fingerprinting
44+
45+
- **In-Process Execution** - Runs built-in commands in-process
46+
- Optimizes simple commands like `echo`
47+
- No process spawn overhead
48+
49+
- **Expanded Execution** - Nested execution graph
50+
- Commands like `vite run ...` expand into sub-graphs
51+
- Enables composition of vite commands
52+
53+
### Command Parsing
54+
55+
Commands are intelligently parsed:
56+
57+
```bash
58+
# Single command -> Single spawn execution
59+
"tsc --noEmit"
60+
61+
# Multiple commands -> Multiple execution items
62+
"tsc --noEmit && vite run test && echo Done"
63+
# ↓ ↓ ↓
64+
# SpawnExecution Expanded InProcess
65+
```
66+
67+
### Error Handling
68+
69+
- **Recursion Detection** - Prevents infinite task dependency loops
70+
- **Call Stack Tracking** - Maintains task call stack for error reporting

0 commit comments

Comments
 (0)