Skip to content

Commit 6aec366

Browse files
committed
fix: remove auto-install feature from local CLI for better performance
The `vp run` command was automatically running `pnpm install` before executing tasks, causing serious performance degradation. Remove the entire auto-install feature: - Delete `create_install_synthetic_request()` and auto-install block from `execute_vite_task_command()` in the NAPI binding - Remove `VITE_DISABLE_AUTO_INSTALL` env var from 147 snap test files - Delete `auto-install-before-task` snap test and benchmark script - Update docs and RFCs to remove auto-install references
1 parent 5844065 commit 6aec366

157 files changed

Lines changed: 13 additions & 553 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bench/benches/auto_install.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

docs/vite/guide/cli.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,11 @@ vp cache clean
367367

368368
### Environment Variables
369369

370-
| Variable | Description |
371-
| --------------------------- | ------------------------------------------------------- |
372-
| `VITE_LOG` | Set logging level (e.g., `VITE_LOG=debug`) |
373-
| `VITE_DISABLE_AUTO_INSTALL` | Set to `1` to disable automatic dependency installation |
374-
| `VITE_TASK_EXECUTION_ENV` | Internal: indicates running inside vite task |
375-
| `VITE_TASK_EXECUTION_ID` | Internal: unique ID for task execution |
370+
| Variable | Description |
371+
| ------------------------- | -------------------------------------------- |
372+
| `VITE_LOG` | Set logging level (e.g., `VITE_LOG=debug`) |
373+
| `VITE_TASK_EXECUTION_ENV` | Internal: indicates running inside vite task |
374+
| `VITE_TASK_EXECUTION_ID` | Internal: unique ID for task execution |
376375

377376
### Execution Modes
378377

packages/cli/binding/src/cli.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -635,32 +635,6 @@ impl UserConfigLoader for VitePlusConfigLoader {
635635
}
636636
}
637637

638-
/// Create auto-install synthetic plan request
639-
async fn create_install_synthetic_request(
640-
cwd: &AbsolutePathBuf,
641-
) -> Result<SyntheticPlanRequest, Error> {
642-
let package_manager = vite_install::PackageManager::builder(cwd).build_with_default().await?;
643-
let resolve_command = package_manager.resolve_install_command(&vec![]);
644-
645-
let mut envs: FxHashMap<Arc<OsStr>, Arc<OsStr>> = std::env::vars_os()
646-
.map(|(k, v)| (Arc::from(k.as_os_str()), Arc::from(v.as_os_str())))
647-
.collect();
648-
649-
for (k, v) in resolve_command.envs {
650-
envs.insert(Arc::from(OsStr::new(&k)), Arc::from(OsStr::new(&v)));
651-
}
652-
653-
Ok(SyntheticPlanRequest {
654-
program: Arc::<OsStr>::from(OsStr::new(&resolve_command.bin_path).to_os_string()),
655-
args: resolve_command.args.into_iter().map(Str::from).collect(),
656-
cache_config: UserCacheConfig::with_config(EnabledCacheConfig {
657-
envs: None,
658-
pass_through_envs: None,
659-
}),
660-
envs: Arc::new(envs),
661-
})
662-
}
663-
664638
/// Execute a synthesizable subcommand directly (not through vite-task Session).
665639
/// No caching, no task graph, no dependency resolution.
666640
async fn execute_direct_subcommand(
@@ -771,21 +745,6 @@ async fn execute_vite_task_command(
771745
user_config_loader: &mut config_loader,
772746
})?;
773747

774-
// Auto-install (using Session::exec)
775-
if env::var_os("VITE_DISABLE_AUTO_INSTALL") != Some("1".into()) {
776-
if let Ok(install_request) = create_install_synthetic_request(&cwd).await {
777-
let cache_key: Arc<[Str]> = vec![Str::from("install")].into();
778-
let status = session
779-
.execute_synthetic(install_request, cache_key, true)
780-
.await
781-
.map_err(|e| Error::Anyhow(e))?;
782-
if status != ExitStatus::SUCCESS {
783-
command_handler.cleanup_temp_files().await;
784-
return Ok(status);
785-
}
786-
}
787-
}
788-
789748
// Main execution (consumes session)
790749
let result = session.main(command).await.map_err(|e| Error::Anyhow(e));
791750

packages/cli/snap-tests-global/command-add-npm10-with-workspace/steps.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"ignoredPlatforms": ["win32"],
3-
"env": {
4-
"VITE_DISABLE_AUTO_INSTALL": "1"
5-
},
63
"commands": [
74
"vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root",
85
"vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root",

packages/cli/snap-tests-global/command-add-npm10/steps.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"ignoredPlatforms": ["win32"],
3-
"env": {
4-
"VITE_DISABLE_AUTO_INSTALL": "1"
5-
},
63
"commands": [
74
"vp add --help # should show help",
85
"vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies",

packages/cli/snap-tests-global/command-add-npm11-with-workspace/steps.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"ignoredPlatforms": ["win32"],
3-
"env": {
4-
"VITE_DISABLE_AUTO_INSTALL": "1"
5-
},
63
"commands": [
74
"vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root",
85
"vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root",

packages/cli/snap-tests-global/command-add-npm11/steps.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"ignoredPlatforms": ["win32"],
3-
"env": {
4-
"VITE_DISABLE_AUTO_INSTALL": "1"
5-
},
63
"commands": [
74
"vp add --help # should show help",
85
"vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies",

packages/cli/snap-tests-global/command-add-pnpm10-with-workspace/steps.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"ignoredPlatforms": ["win32"],
3-
"env": {
4-
"VITE_DISABLE_AUTO_INSTALL": "1"
5-
},
63
"commands": [
74
"vp add testnpm2 -D -w && cat package.json # should add package to workspace root",
85
"vp add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root",

packages/cli/snap-tests-global/command-add-pnpm10/steps.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"ignoredPlatforms": ["win32"],
3-
"env": {
4-
"VITE_DISABLE_AUTO_INSTALL": "1"
5-
},
63
"commands": [
74
"vp add --help # should show help",
85
"vp add # should error because no packages specified",

packages/cli/snap-tests-global/command-add-pnpm9-with-workspace/steps.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"ignoredPlatforms": ["win32"],
33
"env": {
4-
"VITE_DISABLE_AUTO_INSTALL": "1",
54
"NODE_OPTIONS": "--no-deprecation"
65
},
76
"commands": [

0 commit comments

Comments
 (0)