Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ Tasks are defined in `vite-task.json`:
"cwd": "relative/path",
"dependsOn": ["build", "package#task"],
"cache": true,
"envs": ["NODE_ENV"],
"env": ["NODE_ENV"],
"passThroughEnvs": ["CI"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about this?

"inputs": ["src/**", "!dist/**", { "auto": true }]
"input": ["src/**", "!dist/**", { "auto": true }]
}
}
}
Expand All @@ -145,9 +145,9 @@ Tasks are defined in `vite-task.json`:
- `cwd`: working directory relative to the package root
- `dependsOn`: explicit task dependencies (`taskName` or `package#task`)
- `cache` (task): enable/disable caching for this task (default: `true`)
- `envs`: env var names to fingerprint and pass to the task
- `env`: env var names to fingerprint and pass to the task
- `passThroughEnvs`: env var names to pass without fingerprinting
- `inputs`: files for cache fingerprinting (globs, `{ "auto": true }`, negation patterns)
- `input`: files for cache fingerprinting (globs, `{ "auto": true }`, negation patterns)

## Task Dependencies

Expand Down
24 changes: 12 additions & 12 deletions crates/vite_task/docs/task-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The task cache system enables:
- **Content-based hashing**: Cache keys based on actual content, not timestamps
- **Output replay**: Cached stdout/stderr are replayed exactly as originally produced
- **Two-tier caching**: Cache entries shared across tasks, with task-run associations
- **Configurable inputs**: Control which files are tracked for cache invalidation
- **Configurable input**: Control which files are tracked for cache invalidation

### Shared caching

Expand Down Expand Up @@ -56,7 +56,7 @@ the task cache system is able to hit the same cache for the `test` task and for
│ ▼ │
│ 2. Cache Key Generation │
│ ────────────────────── │
│ • Spawn fingerprint (cwd, program, args, envs) │
│ • Spawn fingerprint (cwd, program, args, env) │
│ • Input configuration │
│ │ │
│ ▼ │
Expand Down Expand Up @@ -131,15 +131,15 @@ This ensures cache invalidation when:

The `fingerprinted_envs` field is crucial for cache correctness:

- Only includes envs explicitly declared in the task's `envs` array
- Only includes env vars explicitly declared in the task's `env` array
- Does NOT include pass-through envs (PATH, CI, etc.)
- These envs become part of the cache key
- These env vars become part of the cache key

When a task runs:

1. All envs (including pass-through) are available to the process
2. Only declared envs affect the cache key
3. If a declared env changes value, cache will miss
1. All env vars (including pass-through) are available to the process
2. Only declared env vars affect the cache key
3. If a declared env var changes value, cache will miss
4. If a pass-through env changes, cache will still hit

The `pass_through_envs` field stores env names (not values) — if the set of pass-through env names changes, the cache invalidates, but value changes don't.
Expand Down Expand Up @@ -220,13 +220,13 @@ Vite Task uses `fspy` to monitor file system access during task execution:

### 7. Inputs Configuration

The `inputs` field in `vite-task.json` controls which files are tracked for cache fingerprinting:
The `input` field in `vite-task.json` controls which files are tracked for cache fingerprinting:

```json
{
"tasks": {
"build": {
"inputs": ["src/**", "!dist/**", { "auto": true }]
"input": ["src/**", "!dist/**", { "auto": true }]
}
}
}
Expand Down Expand Up @@ -382,7 +382,7 @@ Cache entries are automatically invalidated when:
4. **Pass-through config changes**: Pass-through environment names added/removed from configuration
5. **Input files change**: Content hash differs (detected via xxHash3)
6. **File structure changes**: Files added, removed, or type changed
7. **Input config changes**: The `inputs` configuration itself changes
7. **Input config changes**: The `input` configuration itself changes

## Configuration

Expand Down Expand Up @@ -535,13 +535,13 @@ Ensure commands produce identical outputs for identical inputs:
}
```

### 3. Use `inputs` for Precise Cache Control
### 3. Use `input` for Precise Cache Control

```json
{
"tasks": {
"build": {
"inputs": ["src/**", "tsconfig.json", "!src/**/*.test.ts"]
"input": ["src/**", "tsconfig.json", "!src/**/*.test.ts"]
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/vite_task/docs/wildcard-env-patterns.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Common Wildcard Pattern for Task Envs
# Common Wildcard Pattern for Task Env

## Executive Summary

Expand All @@ -13,7 +13,7 @@ Currently, vite-plus requires explicit listing of environment variables in task
"tasks": {
"build": {
"command": "vite build",
"envs": ["NODE_ENV", "NODE_OPTIONS", "VITE_API_URL", "VITE_APP_TITLE", "MY_APP_PORT"]
"env": ["NODE_ENV", "NODE_OPTIONS", "VITE_API_URL", "VITE_APP_TITLE", "MY_APP_PORT"]
}
}
}
Expand All @@ -23,7 +23,7 @@ This approach becomes cumbersome when dealing with multiple environment variable

## Goals

1. **Simplify Configuration**: Allow wildcard patterns in the `envs` array to match multiple environment variables
1. **Simplify Configuration**: Allow wildcard patterns in the `env` array to match multiple environment variables
2. **Maintain Cache Correctness**: Ensure wildcard-matched variables are properly included in cache fingerprints
3. **Backward Compatibility**: Support both explicit variable names and wildcard patterns
4. **Performance**: Minimal overhead when resolving environment variables
Expand All @@ -32,7 +32,7 @@ This approach becomes cumbersome when dealing with multiple environment variable
## Non-Goals

1. Full regex support (only glob-style wildcards)
2. Wildcard patterns in `pass_through_envs` (same as `envs`)
2. Wildcard patterns in `passThroughEnvs` (same as `env`)
3. Complex glob patterns like `{VITE,NODE}_*` (supported by wax crate)

## Proposed Solution
Expand Down Expand Up @@ -63,7 +63,7 @@ We don't support `!` for negated patterns. If match the negated pattern, will ig
```
┌─────────────────┐
│ Task Config │
envs: [ │
env: [ │
│ "NODE_*", │
│ "VITE_*", │
│ "CI" │
Expand Down Expand Up @@ -164,7 +164,7 @@ pub struct CommandFingerprint {
"tasks": {
"build": {
"command": "vite build",
"envs": [
"env": [
"NODE_ENV",
"NODE_OPTIONS",
"VITE_API_URL",
Expand All @@ -184,7 +184,7 @@ pub struct CommandFingerprint {
"tasks": {
"build": {
"command": "vite build",
"envs": ["NODE_*", "VITE_*"]
"env": ["NODE_*", "VITE_*"]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_task/src/session/cache/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub fn format_cache_status_inline(cache_status: &CacheStatus) -> Option<Str> {
None => "configuration changed",
}
}
FingerprintMismatch::InputConfig => "inputs configuration changed",
FingerprintMismatch::InputConfig => "input configuration changed",
FingerprintMismatch::InputChanged { kind, path } => {
let desc = format_input_change_str(*kind, path.as_str());
return Some(vite_str::format!("✗ cache miss: {desc}, executing"));
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_task/src/session/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Display for FingerprintMismatch {
write!(f, "Spawn fingerprint changed: old={old:?}, new={new:?}")
}
Self::InputConfig => {
write!(f, "inputs configuration changed")
write!(f, "input configuration changed")
}
Self::InputChanged { kind, path } => {
write!(f, "{}", display::format_input_change_str(*kind, path.as_str()))
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_task/src/session/reporter/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl TaskResult {
}
}
SavedCacheMissReason::ConfigChanged => {
Str::from("→ Cache miss: inputs configuration changed")
Str::from("→ Cache miss: input configuration changed")
}
SavedCacheMissReason::InputChanged { kind, path } => {
let desc = format_input_change_str(*kind, path.as_str());
Expand Down
8 changes: 4 additions & 4 deletions crates/vite_task_bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ fn synthesize_node_modules_bin_task(
program: find_executable(get_path_env(envs), cwd, executable_name)?,
args: args.into(),
cache_config: UserCacheConfig::with_config(EnabledCacheConfig {
envs: None,
env: None,
pass_through_envs: None,
inputs: None,
input: None,
}),
envs: Arc::clone(envs),
})
Expand Down Expand Up @@ -127,9 +127,9 @@ impl vite_task::CommandHandler for CommandHandler {
args: [name.clone()].into(),
cache_config: UserCacheConfig::with_config({
EnabledCacheConfig {
envs: None,
env: None,
pass_through_envs: Some(vec![name]),
inputs: None,
input: None,
}
}),
envs: Arc::new(envs),
Expand Down
4 changes: 2 additions & 2 deletions crates/vite_task_bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ async fn run() -> anyhow::Result<ExitStatus> {
args: [Str::from("FOO")].into(),
cache_config: UserCacheConfig::with_config({
EnabledCacheConfig {
envs: Some(Box::from([Str::from("FOO")])),
env: Some(Box::from([Str::from("FOO")])),
pass_through_envs: None,
inputs: None,
input: None,
}
}),
envs: Arc::clone(envs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ steps = [
]

[[e2e]]
name = "inputs config changed"
name = "input config changed"
steps = [
"vp run test # cache miss",
"json-edit vite-task.json \"_.tasks.test.inputs = ['test.txt']\" # change inputs config",
"json-edit vite-task.json \"_.tasks.test.input = ['test.txt']\" # change input config",
"vp run test # cache miss: configuration changed",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ expression: e2e_outputs
> vp run test # cache miss
$ print-file test.txt
initial content
> json-edit vite-task.json "_.tasks.test.inputs = ['test.txt']" # change inputs config
> json-edit vite-task.json "_.tasks.test.input = ['test.txt']" # change input config

> vp run test # cache miss: configuration changed
$ print-file test.txt ✗ cache miss: inputs configuration changed, executing
$ print-file test.txt ✗ cache miss: input configuration changed, executing
initial content
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"tasks": {
"test": {
"command": "print-file test.txt",
"envs": ["MY_ENV"],
"env": ["MY_ENV"],
"cache": true
},
"glob-test": {
"command": "print glob-test",
"inputs": ["*.txt"],
"input": ["*.txt"],
"cache": true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"tasks": {
"sub-glob-test": {
"command": "print-file src/sub.ts",
"inputs": ["src/**/*.ts"],
"input": ["src/**/*.ts"],
"cache": true
},
"sub-glob-with-cwd": {
"command": "print-file sub.ts",
"cwd": "src",
"inputs": ["src/**/*.ts"],
"input": ["src/**/*.ts"],
"cache": true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"tasks": {
"root-glob-test": {
"command": "print-file src/root.ts",
"inputs": ["src/**/*.ts"],
"input": ["src/**/*.ts"],
"cache": true
},
"root-glob-with-cwd": {
"command": "print-file root.ts",
"cwd": "src",
"inputs": ["src/**/*.ts"],
"input": ["src/**/*.ts"],
"cache": true
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tests that different env values get separate cache entries

[[e2e]]
name = "individual cache for envs"
name = "individual cache for env"
steps = [
"FOO=1 vp run hello # cache miss",
"FOO=2 vp run hello # cache miss, different env",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"tasks": {
"hello": {
"command": "print-env FOO",
"envs": ["FOO"],
"env": ["FOO"],
"cache": true
}
}
Expand Down
Loading
Loading