Skip to content

Commit 08a5993

Browse files
authored
fix: remove auto-install feature from local CLI for better performance (#631)
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 5dc3a8b commit 08a5993

157 files changed

Lines changed: 27 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
@@ -644,32 +644,6 @@ impl UserConfigLoader for VitePlusConfigLoader {
644644
}
645645
}
646646

647-
/// Create auto-install synthetic plan request
648-
async fn create_install_synthetic_request(
649-
cwd: &AbsolutePathBuf,
650-
) -> Result<SyntheticPlanRequest, Error> {
651-
let package_manager = vite_install::PackageManager::builder(cwd).build_with_default().await?;
652-
let resolve_command = package_manager.resolve_install_command(&vec![]);
653-
654-
let mut envs: FxHashMap<Arc<OsStr>, Arc<OsStr>> = std::env::vars_os()
655-
.map(|(k, v)| (Arc::from(k.as_os_str()), Arc::from(v.as_os_str())))
656-
.collect();
657-
658-
for (k, v) in resolve_command.envs {
659-
envs.insert(Arc::from(OsStr::new(&k)), Arc::from(OsStr::new(&v)));
660-
}
661-
662-
Ok(SyntheticPlanRequest {
663-
program: Arc::<OsStr>::from(OsStr::new(&resolve_command.bin_path).to_os_string()),
664-
args: resolve_command.args.into_iter().map(Str::from).collect(),
665-
cache_config: UserCacheConfig::with_config(EnabledCacheConfig {
666-
envs: None,
667-
pass_through_envs: None,
668-
}),
669-
envs: Arc::new(envs),
670-
})
671-
}
672-
673647
/// Execute a synthesizable subcommand directly (not through vite-task Session).
674648
/// No caching, no task graph, no dependency resolution.
675649
async fn execute_direct_subcommand(
@@ -766,21 +740,6 @@ async fn execute_vite_task_command(
766740
user_config_loader: &mut config_loader,
767741
})?;
768742

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

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)