Skip to content

Commit ade0bf0

Browse files
branchseerclaude
andcommitted
feat(plan): thread output_config through cache metadata and planning
Add `output_config: ResolvedGlobConfig` to `CacheMetadata` and propagate it through `plan_spawn_execution` and `resolve_synthetic_cache_config`. Synthetic tasks merge output globs into the parent's output config, mirroring the existing input config merging logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 496210c commit ade0bf0

2 files changed

Lines changed: 38 additions & 7 deletions

File tree

crates/vite_task_plan/src/cache_metadata.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bincode::{Decode, Encode};
44
use serde::{Deserialize, Serialize};
55
use vite_path::RelativePathBuf;
66
use vite_str::{self, Str};
7-
use vite_task_graph::config::ResolvedInputConfig;
7+
use vite_task_graph::config::ResolvedGlobConfig;
88

99
use crate::envs::EnvFingerprints;
1010

@@ -45,7 +45,11 @@ pub struct CacheMetadata {
4545

4646
/// Resolved input configuration for cache fingerprinting.
4747
/// Used at execution time to determine what files to track.
48-
pub input_config: ResolvedInputConfig,
48+
pub input_config: ResolvedGlobConfig,
49+
50+
/// Resolved output configuration for cache restoration.
51+
/// Used at execution time to determine what output files to archive.
52+
pub output_config: ResolvedGlobConfig,
4953
}
5054

5155
/// Fingerprint for spawn execution that affects caching.

crates/vite_task_plan/src/plan.rs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use vite_str::Str;
2020
use vite_task_graph::{
2121
TaskNodeIndex, TaskSource,
2222
config::{
23-
CacheConfig, EnabledCacheConfig, ResolvedGlobalCacheConfig, ResolvedInputConfig,
23+
CacheConfig, EnabledCacheConfig, ResolvedGlobConfig, ResolvedGlobalCacheConfig,
2424
ResolvedTaskOptions,
2525
user::{UserCacheConfig, UserTaskOptions},
2626
},
@@ -460,15 +460,16 @@ fn resolve_synthetic_cache_config(
460460
Ok(match synthetic_cache_config {
461461
UserCacheConfig::Disabled { .. } => Option::None,
462462
UserCacheConfig::Enabled { enabled_cache_config, .. } => {
463-
let EnabledCacheConfig { env, untracked_env, input } = enabled_cache_config;
463+
let EnabledCacheConfig { env, untracked_env, input, output } =
464+
enabled_cache_config;
464465
parent_config.env_config.fingerprinted_envs.extend(env.unwrap_or_default());
465466
parent_config
466467
.env_config
467468
.untracked_env
468469
.extend(untracked_env.unwrap_or_default());
469470

470471
if let Some(input) = input {
471-
let synthetic_input = ResolvedInputConfig::from_user_config(
472+
let synthetic_input = ResolvedGlobConfig::from_user_config(
472473
Some(&input),
473474
package_dir,
474475
workspace_path,
@@ -487,6 +488,23 @@ fn resolve_synthetic_cache_config(
487488
.extend(synthetic_input.negative_globs);
488489
}
489490

491+
if let Some(output) = output {
492+
let synthetic_output = ResolvedGlobConfig::from_user_config(
493+
Some(&output),
494+
package_dir,
495+
workspace_path,
496+
)
497+
.map_err(Error::ResolveTaskConfig)?;
498+
parent_config
499+
.output_config
500+
.positive_globs
501+
.extend(synthetic_output.positive_globs);
502+
parent_config
503+
.output_config
504+
.negative_globs
505+
.extend(synthetic_output.negative_globs);
506+
}
507+
490508
Some(parent_config)
491509
}
492510
})
@@ -620,6 +638,7 @@ fn plan_spawn_execution(
620638
spawn_fingerprint,
621639
execution_cache_key,
622640
input_config: cache_config.input_config.clone(),
641+
output_config: cache_config.output_config.clone(),
623642
});
624643
}
625644
}
@@ -828,7 +847,7 @@ mod tests {
828847
use vite_path::AbsolutePathBuf;
829848
use vite_str::Str;
830849
use vite_task_graph::config::{
831-
CacheConfig, EnabledCacheConfig, EnvConfig, ResolvedInputConfig,
850+
CacheConfig, EnabledCacheConfig, EnvConfig, ResolvedGlobConfig,
832851
user::{UserCacheConfig, UserInputEntry},
833852
};
834853

@@ -854,11 +873,12 @@ mod tests {
854873
fingerprinted_envs: FxHashSet::default(),
855874
untracked_env: FxHashSet::default(),
856875
},
857-
input_config: ResolvedInputConfig {
876+
input_config: ResolvedGlobConfig {
858877
includes_auto,
859878
positive_globs: positive_globs.iter().map(|s| Str::from(*s)).collect(),
860879
negative_globs: BTreeSet::new(),
861880
},
881+
output_config: ResolvedGlobConfig::default_auto(),
862882
}
863883
}
864884

@@ -876,6 +896,7 @@ mod tests {
876896
env: None,
877897
untracked_env: None,
878898
input: None,
899+
output: None,
879900
}),
880901
&pkg,
881902
&ws,
@@ -897,6 +918,7 @@ mod tests {
897918
env: None,
898919
untracked_env: None,
899920
input: Some(vec![UserInputEntry::Glob("config/**".into())]),
921+
output: None,
900922
}),
901923
&pkg,
902924
&ws,
@@ -918,6 +940,7 @@ mod tests {
918940
env: None,
919941
untracked_env: None,
920942
input: Some(vec![UserInputEntry::Glob("config/**".into())]),
943+
output: None,
921944
}),
922945
&pkg,
923946
&ws,
@@ -945,6 +968,7 @@ mod tests {
945968
UserInputEntry::Glob("config/**".into()),
946969
UserInputEntry::Auto(vite_task_graph::config::user::AutoInput { auto: true }),
947970
]),
971+
output: None,
948972
}),
949973
&pkg,
950974
&ws,
@@ -970,6 +994,7 @@ mod tests {
970994
env: None,
971995
untracked_env: None,
972996
input: Some(vec![UserInputEntry::Glob("config/**".into())]),
997+
output: None,
973998
}),
974999
&pkg,
9751000
&ws,
@@ -993,6 +1018,7 @@ mod tests {
9931018
env: None,
9941019
untracked_env: None,
9951020
input: Some(vec![UserInputEntry::Glob("config/**".into())]),
1021+
output: None,
9961022
}),
9971023
&pkg,
9981024
&ws,
@@ -1025,6 +1051,7 @@ mod tests {
10251051
env: None,
10261052
untracked_env: None,
10271053
input: Some(vec![UserInputEntry::Glob("!dist/**".into())]),
1054+
output: None,
10281055
}),
10291056
&pkg,
10301057
&ws,

0 commit comments

Comments
 (0)