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
50 changes: 19 additions & 31 deletions packages/cli/binding/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,37 +620,25 @@ impl UserConfigLoader for VitePlusConfigLoader {
) -> anyhow::Result<Option<UserRunConfig>> {
// Try static config extraction first (no JS runtime needed)
let static_fields = vite_static_config::resolve_static_config(package_path);

// If plugins are present, a plugin's config hook may add/modify the `run`
// field at runtime, so we must fall back to NAPI-based resolution which
// calls Vite's resolveConfig() and executes plugin hooks.
if static_fields.get("plugins").is_some() {
tracing::debug!(
"plugins detected for {}, falling back to NAPI to run config hooks",
package_path.as_path().display()
);
} else {
// No plugins — static analysis results are trustworthy
match static_fields.get("run") {
Some(vite_static_config::FieldValue::Json(run_value)) => {
tracing::debug!(
"Using statically extracted run config for {}",
package_path.as_path().display()
);
let run_config: UserRunConfig = serde_json::from_value(run_value)?;
return Ok(Some(run_config));
}
Some(vite_static_config::FieldValue::NonStatic) => {
// `run` field exists (or may exist via a spread) — fall back to NAPI
tracing::debug!(
"run config is not statically analyzable for {}, falling back to NAPI",
package_path.as_path().display()
);
}
None => {
// Config was analyzed successfully and `run` field is definitively absent
return Ok(None);
}
match static_fields.get("run") {
Some(vite_static_config::FieldValue::Json(run_value)) => {
tracing::debug!(
"Using statically extracted run config for {}",
package_path.as_path().display()
);
let run_config: UserRunConfig = serde_json::from_value(run_value)?;
return Ok(Some(run_config));
}
Some(vite_static_config::FieldValue::NonStatic) => {
// `run` field exists (or may exist via a spread) — fall back to NAPI
tracing::debug!(
"run config is not statically analyzable for {}, falling back to NAPI",
package_path.as_path().display()
);
}
None => {
// Config was analyzed successfully and `run` field is definitively absent
return Ok(None);
}
}

Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions packages/cli/snap-tests/vite-config-task-from-plugin/snap.txt

This file was deleted.

This file was deleted.

This file was deleted.

Loading