Skip to content

Commit 2c023b0

Browse files
committed
add README for vite_task_plan
1 parent e47e574 commit 2c023b0

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

crates/vite_task_plan/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 **tree** of task executions with all runtime details resolved.
20+
21+
```rust
22+
let plan = ExecutionPlan::plan(plan_request, cwd, envs, callbacks).await?;
23+
plan.root_node() // Root execution node
24+
```
25+
26+
### Plan Requests
27+
28+
There are two types of execution requests:
29+
30+
1. **Query Request** - Execute tasks from the task graph (e.g., `vite run -r build`)
31+
- Queries the task graph based on task patterns
32+
- Builds execution graph with dependency ordering
33+
34+
2. **Synthetic Request** - Execute on-the-fly tasks not in the graph (e.g., `vite lint`)
35+
- Generated dynamically with provided configuration
36+
- Used for built-in commands
37+
38+
### Execution Items
39+
40+
Each task's command is parsed and split into execution items:
41+
42+
- **Spawn Execution** - Spawns a child process
43+
- Contains: resolved env vars, cwd, program/args or shell script
44+
- Environment resolution for cache fingerprinting
45+
46+
- **In-Process Execution** - Runs built-in commands in-process
47+
- Optimizes simple commands like `echo`
48+
- No process spawn overhead
49+
50+
- **Expanded Execution** - Nested execution graph
51+
- Commands like `vite run ...` expand into sub-graphs
52+
- Enables composition of vite commands
53+
54+
### Command Parsing
55+
56+
Commands are intelligently parsed:
57+
58+
```bash
59+
# Single command -> Single spawn execution
60+
"tsc --noEmit"
61+
62+
# Multiple commands -> Multiple execution items
63+
"tsc --noEmit && vite run test && echo Done"
64+
# ↓ ↓ ↓
65+
# SpawnExecution Expanded InProcess
66+
```
67+
68+
### Error Handling
69+
70+
- **Recursion Detection** - Prevents infinite task dependency loops
71+
- **Call Stack Tracking** - Maintains task call stack for error reporting

0 commit comments

Comments
 (0)