Skip to content

Commit 317191b

Browse files
fengmk2claude
andcommitted
refactor(cli): remove deprecated vite optimize command
The vite optimize command is deprecated as dependency pre-bundling now runs automatically. Only keep the vite preview command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6ea1ca5 commit 317191b

8 files changed

Lines changed: 13 additions & 86 deletions

File tree

packages/cli/binding/src/cli.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ pub enum Commands {
108108
/// Arguments to pass to vite dev
109109
args: Vec<String>,
110110
},
111-
/// Pre-bundle dependencies
112-
Optimize {
113-
#[arg(allow_hyphen_values = true, trailing_var_arg = true)]
114-
/// Arguments to pass to vite optimize
115-
args: Vec<String>,
116-
},
117111
/// Preview production build
118112
Preview {
119113
#[arg(allow_hyphen_values = true, trailing_var_arg = true)]
@@ -443,13 +437,6 @@ pub async fn main<
443437
workspace.unload().await?;
444438
summary
445439
}
446-
Commands::Optimize { args } => {
447-
let workspace = Workspace::partial_load(cwd)?;
448-
let vite_fn = options.map(|o| o.vite).expect("optimize command requires CliOptions");
449-
let summary = vite_cmd("optimize", vite_fn, &workspace, args).await?;
450-
workspace.unload().await?;
451-
summary
452-
}
453440
Commands::Preview { args } => {
454441
let workspace = Workspace::partial_load(cwd)?;
455442
let vite_fn = options.map(|o| o.vite).expect("preview command requires CliOptions");
@@ -967,27 +954,6 @@ mod tests {
967954
}
968955
}
969956

970-
#[test]
971-
fn test_args_optimize_command() {
972-
let args = Args::try_parse_from(["vite-plus", "optimize"]).unwrap();
973-
assert_eq!(args.task, None);
974-
assert!(args.task_args.is_empty());
975-
assert!(matches!(args.commands, Commands::Optimize { .. }));
976-
assert!(!args.debug);
977-
}
978-
979-
#[test]
980-
fn test_args_optimize_command_with_args() {
981-
let args = Args::try_parse_from(["vite-plus", "optimize", "--force"]).unwrap();
982-
assert_eq!(args.task, None);
983-
assert!(args.task_args.is_empty());
984-
if let Commands::Optimize { args } = &args.commands {
985-
assert_eq!(args, &vec!["--force".to_string()]);
986-
} else {
987-
panic!("Expected Optimize command");
988-
}
989-
}
990-
991957
#[test]
992958
fn test_args_preview_command() {
993959
let args = Args::try_parse_from(["vite-plus", "preview"]).unwrap();

packages/cli/binding/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ impl From<JsCommandResolvedResult> for ResolveCommandResult {
8080
}
8181
}
8282

83-
static BUILTIN_COMMANDS: &[&str] =
84-
&["lint", "fmt", "build", "test", "doc", "lib", "optimize", "preview"];
83+
static BUILTIN_COMMANDS: &[&str] = &["lint", "fmt", "build", "test", "doc", "lib", "preview"];
8584

8685
/// Main entry point for the CLI, called from JavaScript.
8786
///
@@ -285,7 +284,6 @@ fn parse_args() -> Args {
285284
"test" => Commands::Test { args: forwarded_args },
286285
"doc" => Commands::Doc { args: forwarded_args },
287286
"lib" => Commands::Lib { args: forwarded_args },
288-
"optimize" => Commands::Optimize { args: forwarded_args },
289287
"preview" => Commands::Preview { args: forwarded_args },
290288
_ => unreachable!(),
291289
},

packages/cli/snap-tests/command-helper/snap.txt

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
Usage: vite [OPTIONS] [TASK] [-- <TASK_ARGS>...] <COMMAND>
33

44
Commands:
5-
run Run tasks
6-
lint Lint code
7-
fmt Format code
8-
build Build application
9-
test Run test
10-
lib Build library
11-
dev Run development server
12-
optimize Pre-bundle dependencies
13-
preview Preview production build
14-
doc Build documentation
15-
cache Manage the task cache
16-
install Install command. It will be passed to the package manager's install command currently
17-
help Print this message or the help of the given subcommand(s)
5+
run Run tasks
6+
lint Lint code
7+
fmt Format code
8+
build Build application
9+
test Run test
10+
lib Build library
11+
dev Run development server
12+
preview Preview production build
13+
doc Build documentation
14+
cache Manage the task cache
15+
install Install command. It will be passed to the package manager's install command currently
16+
help Print this message or the help of the given subcommand(s)
1817

1918
Arguments:
2019
[TASK]
@@ -336,25 +335,6 @@ Options:
336335
-h, --help Display this message
337336

338337

339-
> vite optimize -h # optimize help message
340-
vite/<semver>
341-
342-
Usage:
343-
$ vite optimize [root]
344-
345-
Options:
346-
--force [boolean] force the optimizer to ignore the cache and re-bundle
347-
-c, --config <file> [string] use specified config file
348-
--base <path> [string] public base path (default: /)
349-
-l, --logLevel <level> [string] info | warn | error | silent
350-
--clearScreen [boolean] allow/disable clear screen when logging
351-
--configLoader <loader> [string] use 'bundle' to bundle the config with Rolldown, or 'runner' (experimental) to process it on the fly, or 'native' (experimental) to load using the native runtime (default: bundle)
352-
-d, --debug [feat] [string | boolean] show debug logs
353-
-f, --filter <filter> [string] filter debug logs
354-
-m, --mode <mode> [string] set env mode
355-
-h, --help Display this message
356-
357-
358338
> vite preview -h # preview help message
359339
vite/<semver>
360340

packages/cli/snap-tests/command-helper/steps.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"vite lint -h # lint help message",
1111
"vite build -h # build help message",
1212
"vite test -h # test help message",
13-
"vite optimize -h # optimize help message",
1413
"vite preview -h # preview help message"
1514
]
1615
}

packages/cli/snap-tests/command-optimize/package.json

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

packages/cli/snap-tests/command-optimize/snap.txt

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

packages/cli/snap-tests/command-optimize/steps.json

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

packages/global/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const LOCAL_CLI_COMMANDS = [
1111
'lib',
1212
'doc',
1313
'run',
14-
'optimize',
1514
'preview',
1615
];
1716

0 commit comments

Comments
 (0)