From 502d89eaaaa33547da4740ff3e28e2606ed4ff48 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 7 Apr 2026 22:43:51 +0800 Subject: [PATCH 1/2] fix(cli): enable cache support for `vp check` in task runner When `vp check` was used as a script (e.g., `"check": "vp check"`) and run via `vp run check` with `run: { cache: true }`, cache was always disabled because the command handler forced `UserCacheConfig::disabled()`. Change the Check handler to use `UserCacheConfig::with_config(...)` with auto input tracking and task-cache directory exclusions, matching the pattern used by other synthesized commands (build, lint, fmt). --- packages/cli/binding/src/cli.rs | 27 ++++++++++++++++--- .../check-cache-disabled/package.json | 7 +++++ .../snap-tests/check-cache-disabled/snap.txt | 5 ++++ .../check-cache-disabled/src/index.js | 5 ++++ .../check-cache-disabled/steps.json | 3 +++ .../check-cache-enabled/package.json | 7 +++++ .../snap-tests/check-cache-enabled/snap.txt | 20 ++++++++++++++ .../check-cache-enabled/src/index.js | 5 ++++ .../snap-tests/check-cache-enabled/steps.json | 9 +++++++ .../check-cache-enabled/vite.config.ts | 5 ++++ 10 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 packages/cli/snap-tests/check-cache-disabled/package.json create mode 100644 packages/cli/snap-tests/check-cache-disabled/snap.txt create mode 100644 packages/cli/snap-tests/check-cache-disabled/src/index.js create mode 100644 packages/cli/snap-tests/check-cache-disabled/steps.json create mode 100644 packages/cli/snap-tests/check-cache-enabled/package.json create mode 100644 packages/cli/snap-tests/check-cache-enabled/snap.txt create mode 100644 packages/cli/snap-tests/check-cache-enabled/src/index.js create mode 100644 packages/cli/snap-tests/check-cache-enabled/steps.json create mode 100644 packages/cli/snap-tests/check-cache-enabled/vite.config.ts diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index 1ede4a2146..6d790118c6 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -504,6 +504,21 @@ fn exclude_glob(pattern: &str, base: InputBase) -> UserInputEntry { UserInputEntry::GlobWithBase(GlobWithBase { pattern: Str::from(pattern), base }) } +/// Cache input entries for the check command. +/// The vp check subprocess is a full vp CLI process (not resolved to a binary like +/// build/lint/fmt), so it accesses additional directories that must be excluded: +/// - `.vite-temp`: config compilation cache, read+written during vp CLI startup +/// - `.vite/task-cache`: task runner state files that change after each run +fn check_cache_inputs() -> Vec { + vec![ + UserInputEntry::Auto(AutoInput { auto: true }), + exclude_glob("!node_modules/.vite-temp/**", InputBase::Workspace), + exclude_glob("!node_modules/.vite-temp/**", InputBase::Package), + exclude_glob("!node_modules/.vite/task-cache/**", InputBase::Workspace), + exclude_glob("!node_modules/.vite/task-cache/**", InputBase::Package), + ] +} + /// Common cache input entries for build/pack commands. /// Excludes .vite-temp config files and dist output files that are both read and written. /// TODO: The hardcoded `!dist/**` exclusion is a temporary workaround. It will be replaced @@ -587,10 +602,14 @@ impl CommandHandler for VitePlusCommandHandler { }; match cli_args { CLIArgs::Synthesizable(SynthesizableSubcommand::Check { .. }) => { - // Check is a composite command — run as a subprocess in task scripts - Ok(HandledCommand::Synthesized( - command.to_synthetic_plan_request(UserCacheConfig::disabled()), - )) + // Check is a composite command (fmt + lint) — run as a subprocess in task scripts + Ok(HandledCommand::Synthesized(command.to_synthetic_plan_request( + UserCacheConfig::with_config(EnabledCacheConfig { + env: Some(Box::new([Str::from("OXLINT_TSGOLINT_PATH")])), + untracked_env: None, + input: Some(check_cache_inputs()), + }), + ))) } CLIArgs::Synthesizable(subcmd) => { let resolved = diff --git a/packages/cli/snap-tests/check-cache-disabled/package.json b/packages/cli/snap-tests/check-cache-disabled/package.json new file mode 100644 index 0000000000..ece867044b --- /dev/null +++ b/packages/cli/snap-tests/check-cache-disabled/package.json @@ -0,0 +1,7 @@ +{ + "name": "check-cache-disabled-test", + "type": "module", + "scripts": { + "check": "vp check" + } +} diff --git a/packages/cli/snap-tests/check-cache-disabled/snap.txt b/packages/cli/snap-tests/check-cache-disabled/snap.txt new file mode 100644 index 0000000000..0f813d28d4 --- /dev/null +++ b/packages/cli/snap-tests/check-cache-disabled/snap.txt @@ -0,0 +1,5 @@ +> vp run check # vp check should have cache disabled without run.cache +$ vp check ⊘ cache disabled +pass: All 3 files are correctly formatted (ms, threads) +pass: Found no warnings or lint errors in 1 file (ms, threads) + diff --git a/packages/cli/snap-tests/check-cache-disabled/src/index.js b/packages/cli/snap-tests/check-cache-disabled/src/index.js new file mode 100644 index 0000000000..13305bd3e9 --- /dev/null +++ b/packages/cli/snap-tests/check-cache-disabled/src/index.js @@ -0,0 +1,5 @@ +function hello() { + return "hello"; +} + +export { hello }; diff --git a/packages/cli/snap-tests/check-cache-disabled/steps.json b/packages/cli/snap-tests/check-cache-disabled/steps.json new file mode 100644 index 0000000000..f58ee79361 --- /dev/null +++ b/packages/cli/snap-tests/check-cache-disabled/steps.json @@ -0,0 +1,3 @@ +{ + "commands": ["vp run check # vp check should have cache disabled without run.cache"] +} diff --git a/packages/cli/snap-tests/check-cache-enabled/package.json b/packages/cli/snap-tests/check-cache-enabled/package.json new file mode 100644 index 0000000000..997527d326 --- /dev/null +++ b/packages/cli/snap-tests/check-cache-enabled/package.json @@ -0,0 +1,7 @@ +{ + "name": "check-cache-enabled-test", + "type": "module", + "scripts": { + "check": "vp check" + } +} diff --git a/packages/cli/snap-tests/check-cache-enabled/snap.txt b/packages/cli/snap-tests/check-cache-enabled/snap.txt new file mode 100644 index 0000000000..53f5b97163 --- /dev/null +++ b/packages/cli/snap-tests/check-cache-enabled/snap.txt @@ -0,0 +1,20 @@ +> vp run check # first run should be cache miss +$ vp check +pass: All 4 files are correctly formatted (ms, threads) +pass: Found no warnings or lint errors in 2 files (ms, threads) + + +> vp run check # second run should be cache hit +$ vp check ◉ cache hit, replaying +pass: All 4 files are correctly formatted (ms, threads) +pass: Found no warnings or lint errors in 2 files (ms, threads) + +--- +vp run: cache hit, ms saved. + +> echo 'export const foo = 1;' > src/foo.js +> vp run check # third run should be cache miss after new file added +$ vp check ○ cache miss: 'foo.js' added in 'src', executing +pass: All 5 files are correctly formatted (ms, threads) +pass: Found no warnings or lint errors in 3 files (ms, threads) + diff --git a/packages/cli/snap-tests/check-cache-enabled/src/index.js b/packages/cli/snap-tests/check-cache-enabled/src/index.js new file mode 100644 index 0000000000..13305bd3e9 --- /dev/null +++ b/packages/cli/snap-tests/check-cache-enabled/src/index.js @@ -0,0 +1,5 @@ +function hello() { + return "hello"; +} + +export { hello }; diff --git a/packages/cli/snap-tests/check-cache-enabled/steps.json b/packages/cli/snap-tests/check-cache-enabled/steps.json new file mode 100644 index 0000000000..abcc3eae2e --- /dev/null +++ b/packages/cli/snap-tests/check-cache-enabled/steps.json @@ -0,0 +1,9 @@ +{ + "ignoredPlatforms": ["win32"], + "commands": [ + "vp run check # first run should be cache miss", + "vp run check # second run should be cache hit", + "echo 'export const foo = 1;' > src/foo.js", + "vp run check # third run should be cache miss after new file added" + ] +} diff --git a/packages/cli/snap-tests/check-cache-enabled/vite.config.ts b/packages/cli/snap-tests/check-cache-enabled/vite.config.ts new file mode 100644 index 0000000000..5f95ceeb78 --- /dev/null +++ b/packages/cli/snap-tests/check-cache-enabled/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: true, + }, +}; From ccf61c76dd2b9c6db4826acbf4309e53630cba82 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 7 Apr 2026 22:43:57 +0800 Subject: [PATCH 2/2] fix(core): widen esbuild peer dependency to include ^0.27.0 --- packages/core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/package.json b/packages/core/package.json index f36b0e9bbd..e19883b0e1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -140,7 +140,7 @@ "@tsdown/exe": "0.21.7", "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.1.0", - "esbuild": "^0.28.0", + "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", "publint": "^0.3.0",