From e56313df99eac990a2c3aa8414712150256077c2 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 19:30:09 +0800 Subject: [PATCH 01/15] chore: bump vite-task to ffd0eed3 Closes #1095 --- Cargo.lock | 36 ++++++++-------- Cargo.toml | 12 +++--- .../snap-tests/command-pack-monorepo/snap.txt | 43 ++++--------------- .../command-pack-monorepo/steps.json | 6 +-- packages/cli/snap-tests/command-pack/snap.txt | 7 +-- 5 files changed, 38 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2669b4c44f..cc588dda2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1772,7 +1772,7 @@ dependencies = [ [[package]] name = "fspy" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "allocator-api2", "anyhow", @@ -1807,7 +1807,7 @@ dependencies = [ [[package]] name = "fspy_detours_sys" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "cc", "winapi", @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "fspy_preload_unix" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "anyhow", "bincode", @@ -1831,7 +1831,7 @@ dependencies = [ [[package]] name = "fspy_preload_windows" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "bincode", "constcat", @@ -1847,7 +1847,7 @@ dependencies = [ [[package]] name = "fspy_seccomp_unotify" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "bincode", "futures-util", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "fspy_shared" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "allocator-api2", "bincode", @@ -1882,7 +1882,7 @@ dependencies = [ [[package]] name = "fspy_shared_unix" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "anyhow", "base64 0.22.1", @@ -4600,7 +4600,7 @@ dependencies = [ [[package]] name = "pty_terminal_test_client" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" [[package]] name = "quote" @@ -7237,7 +7237,7 @@ dependencies = [ [[package]] name = "vite_glob" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "thiserror 2.0.18", "vite_path", @@ -7281,7 +7281,7 @@ dependencies = [ [[package]] name = "vite_graph_ser" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "petgraph 0.8.3", "serde", @@ -7363,7 +7363,7 @@ dependencies = [ [[package]] name = "vite_path" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "bincode", "diff-struct", @@ -7377,7 +7377,7 @@ dependencies = [ [[package]] name = "vite_select" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "anyhow", "crossterm", @@ -7404,7 +7404,7 @@ dependencies = [ [[package]] name = "vite_shell" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "bincode", "brush-parser 0.3.0 (git+https://github.com/reubeno/brush?rev=dcb760933b10ee0433d7b740a5709b06f5c67c6b)", @@ -7431,7 +7431,7 @@ dependencies = [ [[package]] name = "vite_str" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "bincode", "compact_str", @@ -7442,7 +7442,7 @@ dependencies = [ [[package]] name = "vite_task" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "anyhow", "async-trait", @@ -7477,7 +7477,7 @@ dependencies = [ [[package]] name = "vite_task_graph" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "anyhow", "async-trait", @@ -7499,7 +7499,7 @@ dependencies = [ [[package]] name = "vite_task_plan" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "anyhow", "async-trait", @@ -7529,7 +7529,7 @@ version = "0.0.0" [[package]] name = "vite_workspace" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" dependencies = [ "clap", "petgraph 0.8.3", diff --git a/Cargo.toml b/Cargo.toml index 310f87436c..bb85422f85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,7 @@ dunce = "1.0.5" fast-glob = "1.0.0" flate2 = { version = "=1.1.9", features = ["zlib-rs"] } form_urlencoded = "1.2.1" -fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } +fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } futures = "0.3.31" futures-util = "0.3.31" glob = "0.3.2" @@ -185,15 +185,15 @@ vfs = "0.13.0" vite_command = { path = "crates/vite_command" } vite_error = { path = "crates/vite_error" } vite_js_runtime = { path = "crates/vite_js_runtime" } -vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } +vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } vite_install = { path = "crates/vite_install" } vite_migration = { path = "crates/vite_migration" } vite_shared = { path = "crates/vite_shared" } vite_static_config = { path = "crates/vite_static_config" } -vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } -vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } -vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } -vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } +vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } +vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } +vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } +vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } walkdir = "2.5.0" wax = "0.6.0" which = "8.0.0" diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index 556000d05d..b0545294e5 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -2,48 +2,23 @@ > ls packages/hello/dist # should have the library index.cjs -> vp run hello#build 2>&1 # should hit cache but not working for now -~/packages/hello$ vp pack -ℹ entry: src/index.ts -ℹ Build start -ℹ Cleaning 1 files -ℹ dist/index.cjs kB │ gzip: kB -ℹ 1 files, total: kB -✔ Build complete in ms - ---- -vp run: hello#build not cached because it modified its input. (Run `vp run --last-details` for full details) +> vp run hello#build 2>&1 | grep 'cache hit' # should hit cache +~/packages/hello$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. > vp run array-config#build # should build the library supports array config > ls packages/array-config/dist # should have the library index.d.mts index.mjs -> vp run array-config#build 2>&1 # should hit cache but not working -~/packages/array-config$ vp pack -ℹ entry: src/sub/index.ts -ℹ Build start -ℹ Cleaning 2 files -ℹ dist/index.mjs kB │ gzip: kB -ℹ dist/index.d.mts kB │ gzip: kB -ℹ 2 files, total: kB -✔ Build complete in ms - ---- -vp run: array-config#build not cached because it modified its input. (Run `vp run --last-details` for full details) +> vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache +~/packages/array-config$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. > vp run default-config#build # should build the library supports default config > ls packages/default-config/dist # should have the library index.mjs -> vp run default-config#build 2>&1 # should hit cache but not working -~/packages/default-config$ vp pack -ℹ entry: src/index.ts -ℹ Build start -ℹ Cleaning 1 files -ℹ dist/index.mjs kB │ gzip: kB -ℹ 1 files, total: kB -✔ Build complete in ms - ---- -vp run: default-config#build not cached because it modified its input. (Run `vp run --last-details` for full details) +> vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache +~/packages/default-config$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index 3dff4364be..6399495acb 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -6,18 +6,18 @@ "ignoreOutput": true }, "ls packages/hello/dist # should have the library", - "vp run hello#build 2>&1 # should hit cache but not working for now", + "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache", { "command": "vp run array-config#build # should build the library supports array config", "ignoreOutput": true }, "ls packages/array-config/dist # should have the library", - "vp run array-config#build 2>&1 # should hit cache but not working", + "vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache", { "command": "vp run default-config#build # should build the library supports default config", "ignoreOutput": true }, "ls packages/default-config/dist # should have the library", - "vp run default-config#build 2>&1 # should hit cache but not working" + "vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache" ] } diff --git a/packages/cli/snap-tests/command-pack/snap.txt b/packages/cli/snap-tests/command-pack/snap.txt index 074a58b0f8..10bbc5270b 100644 --- a/packages/cli/snap-tests/command-pack/snap.txt +++ b/packages/cli/snap-tests/command-pack/snap.txt @@ -59,20 +59,17 @@ $ vp pack src/index.ts ℹ 1 files, total: kB ✔ Build complete in ms ---- -vp run: command-pack#pack not cached because it modified its input. (Run `vp run --last-details` for full details) > ls dist # should have the library index.mjs > vp run pack # should hit cache -$ vp pack src/index.ts +$ vp pack src/index.ts ◉ cache hit, replaying ℹ entry: src/index.ts ℹ Build start -ℹ Cleaning 1 files ℹ dist/index.mjs kB │ gzip: kB ℹ 1 files, total: kB ✔ Build complete in ms --- -vp run: command-pack#pack not cached because it modified its input. (Run `vp run --last-details` for full details) +vp run: cache hit, ms saved. From 098550d3bbd8c4e91b59eaf400a906339a8aa4af Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 19:43:49 +0800 Subject: [PATCH 02/15] test: add vp build cache snap tests Add snap tests to verify vp build caching works correctly: - vp-build-cache: single package build cache hit - vp-build-cache-monorepo: monorepo with two packages, both hit cache --- .../vp-build-cache-monorepo/package.json | 8 ++++++++ .../packages/app/index.html | 8 ++++++++ .../packages/app/package.json | 7 +++++++ .../packages/web/index.html | 8 ++++++++ .../packages/web/package.json | 7 +++++++ .../snap-tests/vp-build-cache-monorepo/snap.txt | 17 +++++++++++++++++ .../vp-build-cache-monorepo/steps.json | 17 +++++++++++++++++ .../vp-build-cache-monorepo/vite.config.ts | 5 +++++ .../cli/snap-tests/vp-build-cache/index.html | 8 ++++++++ .../cli/snap-tests/vp-build-cache/package.json | 7 +++++++ packages/cli/snap-tests/vp-build-cache/snap.txt | 4 ++++ .../cli/snap-tests/vp-build-cache/steps.json | 10 ++++++++++ .../snap-tests/vp-build-cache/vite.config.ts | 5 +++++ 13 files changed, 111 insertions(+) create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/package.json create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/index.html create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/package.json create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/index.html create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/package.json create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/steps.json create mode 100644 packages/cli/snap-tests/vp-build-cache-monorepo/vite.config.ts create mode 100644 packages/cli/snap-tests/vp-build-cache/index.html create mode 100644 packages/cli/snap-tests/vp-build-cache/package.json create mode 100644 packages/cli/snap-tests/vp-build-cache/snap.txt create mode 100644 packages/cli/snap-tests/vp-build-cache/steps.json create mode 100644 packages/cli/snap-tests/vp-build-cache/vite.config.ts diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/package.json b/packages/cli/snap-tests/vp-build-cache-monorepo/package.json new file mode 100644 index 0000000000..514d12a003 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/package.json @@ -0,0 +1,8 @@ +{ + "name": "build-cache-monorepo", + "private": true, + "workspaces": [ + "packages/*" + ], + "packageManager": "pnpm@10.32.1" +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/index.html b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/index.html new file mode 100644 index 0000000000..8d691b4891 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/package.json b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/package.json new file mode 100644 index 0000000000..5958e45892 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/package.json @@ -0,0 +1,7 @@ +{ + "name": "app", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/index.html b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/index.html new file mode 100644 index 0000000000..b5fbf6dcc5 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/package.json b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/package.json new file mode 100644 index 0000000000..8bfdd7166f --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/package.json @@ -0,0 +1,7 @@ +{ + "name": "web", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt new file mode 100644 index 0000000000..8e8332a6c9 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -0,0 +1,17 @@ +> vp run app#build # should build the app +> ls packages/app/dist # should have the build output +assets +index.html + +> vp run app#build 2>&1 | grep 'cache hit' # should hit cache +~/packages/app$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. + +> vp run web#build # should build the web +> ls packages/web/dist # should have the build output +assets +index.html + +> vp run web#build 2>&1 | grep 'cache hit' # should hit cache +~/packages/web$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json new file mode 100644 index 0000000000..f2a5c5a4a0 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -0,0 +1,17 @@ +{ + "ignoredPlatforms": ["win32"], + "commands": [ + { + "command": "vp run app#build # should build the app", + "ignoreOutput": true + }, + "ls packages/app/dist # should have the build output", + "vp run app#build 2>&1 | grep 'cache hit' # should hit cache", + { + "command": "vp run web#build # should build the web", + "ignoreOutput": true + }, + "ls packages/web/dist # should have the build output", + "vp run web#build 2>&1 | grep 'cache hit' # should hit cache" + ] +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/vite.config.ts b/packages/cli/snap-tests/vp-build-cache-monorepo/vite.config.ts new file mode 100644 index 0000000000..5f95ceeb78 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: true, + }, +}; diff --git a/packages/cli/snap-tests/vp-build-cache/index.html b/packages/cli/snap-tests/vp-build-cache/index.html new file mode 100644 index 0000000000..7febab8c7e --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache/package.json b/packages/cli/snap-tests/vp-build-cache/package.json new file mode 100644 index 0000000000..e46476bc41 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/package.json @@ -0,0 +1,7 @@ +{ + "name": "build-cache-test", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache/snap.txt b/packages/cli/snap-tests/vp-build-cache/snap.txt new file mode 100644 index 0000000000..594800c765 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/snap.txt @@ -0,0 +1,4 @@ +> vp run build # first build +> vp run build 2>&1 | grep 'cache hit' # should hit cache +$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/vp-build-cache/steps.json b/packages/cli/snap-tests/vp-build-cache/steps.json new file mode 100644 index 0000000000..68aeb4ad34 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/steps.json @@ -0,0 +1,10 @@ +{ + "ignoredPlatforms": ["win32"], + "commands": [ + { + "command": "vp run build # first build", + "ignoreOutput": true + }, + "vp run build 2>&1 | grep 'cache hit' # should hit cache" + ] +} diff --git a/packages/cli/snap-tests/vp-build-cache/vite.config.ts b/packages/cli/snap-tests/vp-build-cache/vite.config.ts new file mode 100644 index 0000000000..5f95ceeb78 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: true, + }, +}; From c9d27f4d3851abdf820e453489827ac404707577 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 21:18:30 +0800 Subject: [PATCH 03/15] test: verify cache miss after source file change in pack monorepo --- packages/cli/snap-tests/command-pack-monorepo/snap.txt | 4 ++++ packages/cli/snap-tests/command-pack-monorepo/steps.json | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index b0545294e5..09c00f91bb 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -6,6 +6,10 @@ index.cjs ~/packages/hello$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. +> echo 'export function hello() { console.log("changed"); }' > packages/hello/src/hello.ts +> vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change +~/packages/hello$ vp pack ○ cache miss: 'packages/hello/src/hello.ts' modified, executing + > vp run array-config#build # should build the library supports array config > ls packages/array-config/dist # should have the library index.d.mts diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index 6399495acb..21c165fc2a 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -7,6 +7,8 @@ }, "ls packages/hello/dist # should have the library", "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache", + "echo 'export function hello() { console.log(\"changed\"); }' > packages/hello/src/hello.ts", + "vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change", { "command": "vp run array-config#build # should build the library supports array config", "ignoreOutput": true From 9109f5ee5dca7a27bb4608c5ed7c1767de1b3ab7 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 21:19:27 +0800 Subject: [PATCH 04/15] test: verify cache miss after source file change in build monorepo --- packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt | 4 ++++ packages/cli/snap-tests/vp-build-cache-monorepo/steps.json | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt index 8e8332a6c9..a29644537e 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -7,6 +7,10 @@ index.html ~/packages/app$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. +> echo '' > packages/app/index.html +> vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change +~/packages/app$ vp build ○ cache miss: 'packages/app/index.html' modified, executing + > vp run web#build # should build the web > ls packages/web/dist # should have the build output assets diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json index f2a5c5a4a0..b41a31a8f9 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -7,6 +7,8 @@ }, "ls packages/app/dist # should have the build output", "vp run app#build 2>&1 | grep 'cache hit' # should hit cache", + "echo '' > packages/app/index.html", + "vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change", { "command": "vp run web#build # should build the web", "ignoreOutput": true From 1250fd0806cf36cbbf856970d8e97f7680412930 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 21:23:10 +0800 Subject: [PATCH 05/15] test: enable win32 for cache snap tests Remove ignoredPlatforms and ls commands so tests run on all platforms. --- packages/cli/snap-tests/command-pack-monorepo/snap.txt | 10 ---------- .../cli/snap-tests/command-pack-monorepo/steps.json | 4 ---- .../cli/snap-tests/vp-build-cache-monorepo/snap.txt | 8 -------- .../cli/snap-tests/vp-build-cache-monorepo/steps.json | 3 --- packages/cli/snap-tests/vp-build-cache/steps.json | 1 - 5 files changed, 26 deletions(-) diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index 09c00f91bb..e50a75cd3c 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -1,7 +1,4 @@ > vp run hello#build # should build the library -> ls packages/hello/dist # should have the library -index.cjs - > vp run hello#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/hello$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. @@ -11,18 +8,11 @@ vp run: cache hit, ms saved. ~/packages/hello$ vp pack ○ cache miss: 'packages/hello/src/hello.ts' modified, executing > vp run array-config#build # should build the library supports array config -> ls packages/array-config/dist # should have the library -index.d.mts -index.mjs - > vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/array-config$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. > vp run default-config#build # should build the library supports default config -> ls packages/default-config/dist # should have the library -index.mjs - > vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/default-config$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index 21c165fc2a..67a25243b5 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -1,11 +1,9 @@ { - "ignoredPlatforms": ["win32"], "commands": [ { "command": "vp run hello#build # should build the library", "ignoreOutput": true }, - "ls packages/hello/dist # should have the library", "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache", "echo 'export function hello() { console.log(\"changed\"); }' > packages/hello/src/hello.ts", "vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change", @@ -13,13 +11,11 @@ "command": "vp run array-config#build # should build the library supports array config", "ignoreOutput": true }, - "ls packages/array-config/dist # should have the library", "vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache", { "command": "vp run default-config#build # should build the library supports default config", "ignoreOutput": true }, - "ls packages/default-config/dist # should have the library", "vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache" ] } diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt index a29644537e..49b7e15b25 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -1,8 +1,4 @@ > vp run app#build # should build the app -> ls packages/app/dist # should have the build output -assets -index.html - > vp run app#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/app$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. @@ -12,10 +8,6 @@ vp run: cache hit, ms saved. ~/packages/app$ vp build ○ cache miss: 'packages/app/index.html' modified, executing > vp run web#build # should build the web -> ls packages/web/dist # should have the build output -assets -index.html - > vp run web#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/web$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json index b41a31a8f9..e14f13e151 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -1,11 +1,9 @@ { - "ignoredPlatforms": ["win32"], "commands": [ { "command": "vp run app#build # should build the app", "ignoreOutput": true }, - "ls packages/app/dist # should have the build output", "vp run app#build 2>&1 | grep 'cache hit' # should hit cache", "echo '' > packages/app/index.html", "vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change", @@ -13,7 +11,6 @@ "command": "vp run web#build # should build the web", "ignoreOutput": true }, - "ls packages/web/dist # should have the build output", "vp run web#build 2>&1 | grep 'cache hit' # should hit cache" ] } diff --git a/packages/cli/snap-tests/vp-build-cache/steps.json b/packages/cli/snap-tests/vp-build-cache/steps.json index 68aeb4ad34..312d648c75 100644 --- a/packages/cli/snap-tests/vp-build-cache/steps.json +++ b/packages/cli/snap-tests/vp-build-cache/steps.json @@ -1,5 +1,4 @@ { - "ignoredPlatforms": ["win32"], "commands": [ { "command": "vp run build # first build", From 4577f63c2262994d0b77a4bea84c7a6377aa1a78 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 21:24:13 +0800 Subject: [PATCH 06/15] test: restore ls steps in cache snap tests --- packages/cli/snap-tests/command-pack-monorepo/snap.txt | 10 ++++++++++ .../cli/snap-tests/command-pack-monorepo/steps.json | 3 +++ .../cli/snap-tests/vp-build-cache-monorepo/snap.txt | 8 ++++++++ .../cli/snap-tests/vp-build-cache-monorepo/steps.json | 2 ++ 4 files changed, 23 insertions(+) diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index e50a75cd3c..09c00f91bb 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -1,4 +1,7 @@ > vp run hello#build # should build the library +> ls packages/hello/dist # should have the library +index.cjs + > vp run hello#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/hello$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. @@ -8,11 +11,18 @@ vp run: cache hit, ms saved. ~/packages/hello$ vp pack ○ cache miss: 'packages/hello/src/hello.ts' modified, executing > vp run array-config#build # should build the library supports array config +> ls packages/array-config/dist # should have the library +index.d.mts +index.mjs + > vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/array-config$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. > vp run default-config#build # should build the library supports default config +> ls packages/default-config/dist # should have the library +index.mjs + > vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/default-config$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index 67a25243b5..77c2f37d24 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -4,6 +4,7 @@ "command": "vp run hello#build # should build the library", "ignoreOutput": true }, + "ls packages/hello/dist # should have the library", "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache", "echo 'export function hello() { console.log(\"changed\"); }' > packages/hello/src/hello.ts", "vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change", @@ -11,11 +12,13 @@ "command": "vp run array-config#build # should build the library supports array config", "ignoreOutput": true }, + "ls packages/array-config/dist # should have the library", "vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache", { "command": "vp run default-config#build # should build the library supports default config", "ignoreOutput": true }, + "ls packages/default-config/dist # should have the library", "vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache" ] } diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt index 49b7e15b25..a29644537e 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -1,4 +1,8 @@ > vp run app#build # should build the app +> ls packages/app/dist # should have the build output +assets +index.html + > vp run app#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/app$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. @@ -8,6 +12,10 @@ vp run: cache hit, ms saved. ~/packages/app$ vp build ○ cache miss: 'packages/app/index.html' modified, executing > vp run web#build # should build the web +> ls packages/web/dist # should have the build output +assets +index.html + > vp run web#build 2>&1 | grep 'cache hit' # should hit cache ~/packages/web$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json index e14f13e151..b51a4b114a 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -4,6 +4,7 @@ "command": "vp run app#build # should build the app", "ignoreOutput": true }, + "ls packages/app/dist # should have the build output", "vp run app#build 2>&1 | grep 'cache hit' # should hit cache", "echo '' > packages/app/index.html", "vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change", @@ -11,6 +12,7 @@ "command": "vp run web#build # should build the web", "ignoreOutput": true }, + "ls packages/web/dist # should have the build output", "vp run web#build 2>&1 | grep 'cache hit' # should hit cache" ] } From b92a15baa849907ce4da9b856ebbb4e4bb6922d5 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 21:27:16 +0800 Subject: [PATCH 07/15] test: verify vp run build hits cache in package sub dir --- packages/cli/snap-tests/command-pack-monorepo/snap.txt | 4 ++++ packages/cli/snap-tests/command-pack-monorepo/steps.json | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index 09c00f91bb..525d0fd6a6 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -6,6 +6,10 @@ index.cjs ~/packages/hello$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. +> cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir +~/packages/hello$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. + > echo 'export function hello() { console.log("changed"); }' > packages/hello/src/hello.ts > vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change ~/packages/hello$ vp pack ○ cache miss: 'packages/hello/src/hello.ts' modified, executing diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index 77c2f37d24..69c7cdea40 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -6,6 +6,7 @@ }, "ls packages/hello/dist # should have the library", "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache", + "cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir", "echo 'export function hello() { console.log(\"changed\"); }' > packages/hello/src/hello.ts", "vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change", { From 88eea4ab3176400e7d13526fa4757b46a00ac96c Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 22 Mar 2026 21:28:19 +0800 Subject: [PATCH 08/15] test: verify vp run build hits cache in package sub dir for vp build --- packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt | 4 ++++ packages/cli/snap-tests/vp-build-cache-monorepo/steps.json | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt index a29644537e..49e9f6bb9e 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -7,6 +7,10 @@ index.html ~/packages/app$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. +> cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir +~/packages/app$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. + > echo '' > packages/app/index.html > vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change ~/packages/app$ vp build ○ cache miss: 'packages/app/index.html' modified, executing diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json index b51a4b114a..46b88d99bc 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -6,6 +6,7 @@ }, "ls packages/app/dist # should have the build output", "vp run app#build 2>&1 | grep 'cache hit' # should hit cache", + "cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir", "echo '' > packages/app/index.html", "vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change", { From 5036f44d3be6a1fbcdd72d68f552123a11dae696 Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Mar 2026 11:13:22 +0800 Subject: [PATCH 09/15] fix: exclude node_modules/.vite-temp from cache input tracking Add negative input glob `!node_modules/.vite-temp/**` to Pack and Build subcommands to exclude Vite's transient config files from fspy tracking. Bump vite-task to 8c3cc35e which merges synthetic task input config in the inherited cache path. Closes #1095 --- Cargo.lock | 36 ++++++++++++++++----------------- Cargo.toml | 12 +++++------ packages/cli/binding/src/cli.rs | 12 ++++++++--- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc588dda2b..9bd8f84a4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1772,7 +1772,7 @@ dependencies = [ [[package]] name = "fspy" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "allocator-api2", "anyhow", @@ -1807,7 +1807,7 @@ dependencies = [ [[package]] name = "fspy_detours_sys" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "cc", "winapi", @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "fspy_preload_unix" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "bincode", @@ -1831,7 +1831,7 @@ dependencies = [ [[package]] name = "fspy_preload_windows" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "constcat", @@ -1847,7 +1847,7 @@ dependencies = [ [[package]] name = "fspy_seccomp_unotify" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "futures-util", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "fspy_shared" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "allocator-api2", "bincode", @@ -1882,7 +1882,7 @@ dependencies = [ [[package]] name = "fspy_shared_unix" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "base64 0.22.1", @@ -4600,7 +4600,7 @@ dependencies = [ [[package]] name = "pty_terminal_test_client" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" [[package]] name = "quote" @@ -7237,7 +7237,7 @@ dependencies = [ [[package]] name = "vite_glob" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "thiserror 2.0.18", "vite_path", @@ -7281,7 +7281,7 @@ dependencies = [ [[package]] name = "vite_graph_ser" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "petgraph 0.8.3", "serde", @@ -7363,7 +7363,7 @@ dependencies = [ [[package]] name = "vite_path" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "diff-struct", @@ -7377,7 +7377,7 @@ dependencies = [ [[package]] name = "vite_select" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "crossterm", @@ -7404,7 +7404,7 @@ dependencies = [ [[package]] name = "vite_shell" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "brush-parser 0.3.0 (git+https://github.com/reubeno/brush?rev=dcb760933b10ee0433d7b740a5709b06f5c67c6b)", @@ -7431,7 +7431,7 @@ dependencies = [ [[package]] name = "vite_str" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "compact_str", @@ -7442,7 +7442,7 @@ dependencies = [ [[package]] name = "vite_task" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "async-trait", @@ -7477,7 +7477,7 @@ dependencies = [ [[package]] name = "vite_task_graph" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "async-trait", @@ -7499,7 +7499,7 @@ dependencies = [ [[package]] name = "vite_task_plan" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "async-trait", @@ -7529,7 +7529,7 @@ version = "0.0.0" [[package]] name = "vite_workspace" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6#ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "clap", "petgraph 0.8.3", diff --git a/Cargo.toml b/Cargo.toml index bb85422f85..4046bff285 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,7 @@ dunce = "1.0.5" fast-glob = "1.0.0" flate2 = { version = "=1.1.9", features = ["zlib-rs"] } form_urlencoded = "1.2.1" -fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } +fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } futures = "0.3.31" futures-util = "0.3.31" glob = "0.3.2" @@ -185,15 +185,15 @@ vfs = "0.13.0" vite_command = { path = "crates/vite_command" } vite_error = { path = "crates/vite_error" } vite_js_runtime = { path = "crates/vite_js_runtime" } -vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } +vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } vite_install = { path = "crates/vite_install" } vite_migration = { path = "crates/vite_migration" } vite_shared = { path = "crates/vite_shared" } vite_static_config = { path = "crates/vite_static_config" } -vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } -vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } -vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } -vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ffd0eed36cf20d3fbefc1e451b5a7c2b3ca44cd6" } +vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } +vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } +vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } +vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } walkdir = "2.5.0" wax = "0.6.0" which = "8.0.0" diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index d33c960f9c..d0982d7aa8 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -23,7 +23,7 @@ use vite_task::{ Command, CommandHandler, ExitStatus, HandledCommand, ScriptCommand, Session, SessionConfig, config::{ UserRunConfig, - user::{EnabledCacheConfig, UserCacheConfig}, + user::{EnabledCacheConfig, UserCacheConfig, UserInputEntry}, }, loader::UserConfigLoader, plan_request::SyntheticPlanRequest, @@ -329,7 +329,10 @@ impl SubcommandResolver { cache_config: UserCacheConfig::with_config(EnabledCacheConfig { env: Some(Box::new([Str::from("VITE_*")])), untracked_env: None, - input: None, + input: Some(vec![ + UserInputEntry::Auto { auto: true }, + UserInputEntry::Glob(Str::from("!node_modules/.vite-temp/**")), + ]), }), envs: merge_resolved_envs_with_version(envs, resolved.envs), }) @@ -381,7 +384,10 @@ impl SubcommandResolver { cache_config: UserCacheConfig::with_config(EnabledCacheConfig { env: None, untracked_env: None, - input: None, + input: Some(vec![ + UserInputEntry::Auto { auto: true }, + UserInputEntry::Glob(Str::from("!node_modules/.vite-temp/**")), + ]), }), envs: merge_resolved_envs(envs, resolved.envs), }) From 55e16aae7fd2ca5e277c93fcbd234f11ff19d240 Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Mar 2026 11:25:00 +0800 Subject: [PATCH 10/15] test: add snap tests for cache disabled with vp pack and vp build --- .../snap-tests/vp-build-cache-disabled/package.json | 8 ++++++++ .../vp-build-cache-disabled/packages/app/index.html | 8 ++++++++ .../vp-build-cache-disabled/packages/app/package.json | 7 +++++++ .../cli/snap-tests/vp-build-cache-disabled/snap.txt | 11 +++++++++++ .../cli/snap-tests/vp-build-cache-disabled/steps.json | 11 +++++++++++ .../snap-tests/vp-build-cache-disabled/vite.config.ts | 5 +++++ .../snap-tests/vp-pack-cache-disabled/package.json | 8 ++++++++ .../packages/hello/package.json | 9 +++++++++ .../packages/hello/src/hello.ts | 3 +++ .../packages/hello/src/index.ts | 3 +++ .../packages/hello/vite.config.ts | 6 ++++++ .../cli/snap-tests/vp-pack-cache-disabled/snap.txt | 10 ++++++++++ .../cli/snap-tests/vp-pack-cache-disabled/steps.json | 11 +++++++++++ .../snap-tests/vp-pack-cache-disabled/vite.config.ts | 5 +++++ 14 files changed, 105 insertions(+) create mode 100644 packages/cli/snap-tests/vp-build-cache-disabled/package.json create mode 100644 packages/cli/snap-tests/vp-build-cache-disabled/packages/app/index.html create mode 100644 packages/cli/snap-tests/vp-build-cache-disabled/packages/app/package.json create mode 100644 packages/cli/snap-tests/vp-build-cache-disabled/snap.txt create mode 100644 packages/cli/snap-tests/vp-build-cache-disabled/steps.json create mode 100644 packages/cli/snap-tests/vp-build-cache-disabled/vite.config.ts create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/package.json create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/package.json create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/hello.ts create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/index.ts create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/vite.config.ts create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/snap.txt create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/steps.json create mode 100644 packages/cli/snap-tests/vp-pack-cache-disabled/vite.config.ts diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/package.json b/packages/cli/snap-tests/vp-build-cache-disabled/package.json new file mode 100644 index 0000000000..73c7e3ef15 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/package.json @@ -0,0 +1,8 @@ +{ + "name": "vp-build-cache-disabled", + "private": true, + "workspaces": [ + "packages/*" + ], + "packageManager": "pnpm@10.32.1" +} diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/index.html b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/index.html new file mode 100644 index 0000000000..8d691b4891 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/package.json b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/package.json new file mode 100644 index 0000000000..5958e45892 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/package.json @@ -0,0 +1,7 @@ +{ + "name": "app", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/snap.txt b/packages/cli/snap-tests/vp-build-cache-disabled/snap.txt new file mode 100644 index 0000000000..45652564fa --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/snap.txt @@ -0,0 +1,11 @@ +> vp run app#build # first build +> ls packages/app/dist # should have the build output +assets +index.html + +> vp run app#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit +0 +no cache hit + +> vp run app#build 2>&1 | grep 'cache disabled' # should show cache disabled +~/packages/app$ vp build ⊘ cache disabled diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/steps.json b/packages/cli/snap-tests/vp-build-cache-disabled/steps.json new file mode 100644 index 0000000000..e200ca1953 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/steps.json @@ -0,0 +1,11 @@ +{ + "commands": [ + { + "command": "vp run app#build # first build", + "ignoreOutput": true + }, + "ls packages/app/dist # should have the build output", + "vp run app#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit", + "vp run app#build 2>&1 | grep 'cache disabled' # should show cache disabled" + ] +} diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/vite.config.ts b/packages/cli/snap-tests/vp-build-cache-disabled/vite.config.ts new file mode 100644 index 0000000000..de01bdfd87 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: false, + }, +}; diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/package.json b/packages/cli/snap-tests/vp-pack-cache-disabled/package.json new file mode 100644 index 0000000000..8868be9ef7 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/package.json @@ -0,0 +1,8 @@ +{ + "name": "vp-pack-cache-disabled", + "private": true, + "workspaces": [ + "packages/*" + ], + "packageManager": "pnpm@10.32.1" +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/package.json b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/package.json new file mode 100644 index 0000000000..d487f706fd --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/package.json @@ -0,0 +1,9 @@ +{ + "name": "hello", + "version": "1.0.0", + "type": "module", + "main": "src/index.ts", + "scripts": { + "build": "vp pack" + } +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/hello.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/hello.ts new file mode 100644 index 0000000000..b7c0fbaea2 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/hello.ts @@ -0,0 +1,3 @@ +export function hello() { + console.log('Hello tsdown!'); +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/index.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/index.ts new file mode 100644 index 0000000000..96fc953b72 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/index.ts @@ -0,0 +1,3 @@ +import { hello } from './hello.ts'; + +hello(); diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/vite.config.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/vite.config.ts new file mode 100644 index 0000000000..3f312c1769 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/vite.config.ts @@ -0,0 +1,6 @@ +export default { + pack: { + entry: 'src/index.ts', + format: ['cjs'], + }, +}; diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/snap.txt b/packages/cli/snap-tests/vp-pack-cache-disabled/snap.txt new file mode 100644 index 0000000000..c20d936c4b --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/snap.txt @@ -0,0 +1,10 @@ +> vp run hello#build # first build +> ls packages/hello/dist # should have the library +index.cjs + +> vp run hello#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit +0 +no cache hit + +> vp run hello#build 2>&1 | grep 'cache disabled' # should show cache disabled +~/packages/hello$ vp pack ⊘ cache disabled diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/steps.json b/packages/cli/snap-tests/vp-pack-cache-disabled/steps.json new file mode 100644 index 0000000000..6c7ba41b32 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/steps.json @@ -0,0 +1,11 @@ +{ + "commands": [ + { + "command": "vp run hello#build # first build", + "ignoreOutput": true + }, + "ls packages/hello/dist # should have the library", + "vp run hello#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit", + "vp run hello#build 2>&1 | grep 'cache disabled' # should show cache disabled" + ] +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/vite.config.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/vite.config.ts new file mode 100644 index 0000000000..de01bdfd87 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: false, + }, +}; From d29cd38d918cb2d5bbe25cfb5a880be8b49df8de Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Mar 2026 11:26:03 +0800 Subject: [PATCH 11/15] test: verify direct vp pack/vp build are not cached --- packages/cli/snap-tests/command-pack-monorepo/snap.txt | 5 +++++ packages/cli/snap-tests/command-pack-monorepo/steps.json | 5 +++++ packages/cli/snap-tests/command-vp-alias/snap.txt | 6 ++++-- packages/cli/snap-tests/pass-no-color-env/snap.txt | 4 ++-- packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt | 5 +++++ packages/cli/snap-tests/vp-build-cache-monorepo/steps.json | 5 +++++ packages/cli/snap-tests/vp-build-cache/snap.txt | 5 +++++ packages/cli/snap-tests/vp-build-cache/steps.json | 7 ++++++- 8 files changed, 37 insertions(+), 5 deletions(-) diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index 525d0fd6a6..7cceeaf0a8 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -10,6 +10,11 @@ vp run: cache hit, ms saved. ~/packages/hello$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. +> cd packages/hello && vp pack 2>&1 # direct vp pack should not be cached +> cd packages/hello && vp pack 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp pack has no cache +0 +no cache + > echo 'export function hello() { console.log("changed"); }' > packages/hello/src/hello.ts > vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change ~/packages/hello$ vp pack ○ cache miss: 'packages/hello/src/hello.ts' modified, executing diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index 69c7cdea40..eadbb1f510 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -7,6 +7,11 @@ "ls packages/hello/dist # should have the library", "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache", "cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir", + { + "command": "cd packages/hello && vp pack 2>&1 # direct vp pack should not be cached", + "ignoreOutput": true + }, + "cd packages/hello && vp pack 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp pack has no cache", "echo 'export function hello() { console.log(\"changed\"); }' > packages/hello/src/hello.ts", "vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change", { diff --git a/packages/cli/snap-tests/command-vp-alias/snap.txt b/packages/cli/snap-tests/command-vp-alias/snap.txt index 424eb25c87..5082487baa 100644 --- a/packages/cli/snap-tests/command-vp-alias/snap.txt +++ b/packages/cli/snap-tests/command-vp-alias/snap.txt @@ -30,8 +30,10 @@ Run tasks Usage: vp run [OPTIONS] [TASK_SPECIFIER] [ADDITIONAL_ARGS]... Arguments: - [TASK_SPECIFIER] `packageName#taskName` or `taskName`. If omitted, lists all available tasks - [ADDITIONAL_ARGS]... Additional arguments to pass to the tasks + [TASK_SPECIFIER] [ADDITIONAL_ARGS]... + Task to run, as `packageName#taskName` or just `taskName`. + Any arguments after the task name are forwarded to the task process. + Running `vp run` without a task name shows an interactive task selector. Options: -r, --recursive Select all packages in the workspace diff --git a/packages/cli/snap-tests/pass-no-color-env/snap.txt b/packages/cli/snap-tests/pass-no-color-env/snap.txt index b8cd705caf..dab568862b 100644 --- a/packages/cli/snap-tests/pass-no-color-env/snap.txt +++ b/packages/cli/snap-tests/pass-no-color-env/snap.txt @@ -1,9 +1,9 @@ > vp run check -- --foo # get NO_COLOR=true from default env -$ node check.js --foo +$ node check.js -- --foo NO_COLOR=true, CI=true > NO_COLOR=false vp run check -- --bar # get NO_COLOR=false from custom env -$ node check.js --bar +$ node check.js -- --bar NO_COLOR=false, CI=true diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt index 49e9f6bb9e..2fd5470b38 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -11,6 +11,11 @@ vp run: cache hit, ms saved. ~/packages/app$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. +> cd packages/app && vp build 2>&1 # direct vp build should not be cached +> cd packages/app && vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache +0 +no cache + > echo '' > packages/app/index.html > vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change ~/packages/app$ vp build ○ cache miss: 'packages/app/index.html' modified, executing diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json index 46b88d99bc..ec29feed73 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -7,6 +7,11 @@ "ls packages/app/dist # should have the build output", "vp run app#build 2>&1 | grep 'cache hit' # should hit cache", "cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir", + { + "command": "cd packages/app && vp build 2>&1 # direct vp build should not be cached", + "ignoreOutput": true + }, + "cd packages/app && vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache", "echo '' > packages/app/index.html", "vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change", { diff --git a/packages/cli/snap-tests/vp-build-cache/snap.txt b/packages/cli/snap-tests/vp-build-cache/snap.txt index 594800c765..c3ec8b0fb5 100644 --- a/packages/cli/snap-tests/vp-build-cache/snap.txt +++ b/packages/cli/snap-tests/vp-build-cache/snap.txt @@ -2,3 +2,8 @@ > vp run build 2>&1 | grep 'cache hit' # should hit cache $ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. + +> vp build 2>&1 # direct vp build should not be cached +> vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache +0 +no cache diff --git a/packages/cli/snap-tests/vp-build-cache/steps.json b/packages/cli/snap-tests/vp-build-cache/steps.json index 312d648c75..6c6e68595f 100644 --- a/packages/cli/snap-tests/vp-build-cache/steps.json +++ b/packages/cli/snap-tests/vp-build-cache/steps.json @@ -4,6 +4,11 @@ "command": "vp run build # first build", "ignoreOutput": true }, - "vp run build 2>&1 | grep 'cache hit' # should hit cache" + "vp run build 2>&1 | grep 'cache hit' # should hit cache", + { + "command": "vp build 2>&1 # direct vp build should not be cached", + "ignoreOutput": true + }, + "vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache" ] } From d997006a8850892187521615939dc93bb051cf4a Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Mar 2026 11:38:38 +0800 Subject: [PATCH 12/15] fix: update test for trailing_var_arg CLI parsing change vite-task now accepts unknown flags as task arguments via trailing_var_arg, so `vp run --yolo` is valid instead of an error. --- packages/cli/binding/src/cli.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index d0982d7aa8..1aa1e1e833 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -1576,11 +1576,11 @@ mod tests { } #[test] - fn unknown_argument_detected_with_pass_as_value_hint() { - let error = - CLIArgs::try_parse_from(["vp", "run", "--yolo"]).expect_err("Expected parse error"); - assert_eq!(extract_unknown_argument(&error).as_deref(), Some("--yolo")); - assert!(has_pass_as_value_suggestion(&error)); + fn run_accepts_unknown_flags_as_task_args() { + // After trailing_var_arg change, unknown flags like --yolo are + // accepted as task arguments instead of producing a parse error. + let args = CLIArgs::try_parse_from(["vp", "run", "--yolo"]).unwrap(); + assert!(matches!(args, CLIArgs::ViteTask(_))); } #[test] From 85a99e9912e1395041f34f11cdddab79b3d2f1b3 Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Mar 2026 11:43:43 +0800 Subject: [PATCH 13/15] fix: assert --yolo is in task_and_args, not just fuzzy match --- packages/cli/binding/src/cli.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index 1aa1e1e833..89735263d5 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -1540,7 +1540,8 @@ mod tests { use clap::Parser; use serde_json::json; - use vite_task::config::UserRunConfig; + use vite_str::Str; + use vite_task::{Command, config::UserRunConfig}; use super::{ CLIArgs, LintMessageKind, SynthesizableSubcommand, extract_unknown_argument, @@ -1580,7 +1581,9 @@ mod tests { // After trailing_var_arg change, unknown flags like --yolo are // accepted as task arguments instead of producing a parse error. let args = CLIArgs::try_parse_from(["vp", "run", "--yolo"]).unwrap(); - assert!(matches!(args, CLIArgs::ViteTask(_))); + let debug = vite_str::format!("{args:?}"); + assert!(debug.contains("\"--yolo\""), "Expected --yolo in task args, got: {debug}",); + assert!(matches!(args, CLIArgs::ViteTask(Command::Run(_)))); } #[test] From 39374ec082f7fc34e836e4b0919bfb46f2b2e26f Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Mar 2026 11:45:38 +0800 Subject: [PATCH 14/15] test: add sub workspace vp run cache tests Test that cache works when first build is from sub dir and second from root, and vice versa. Ensures cache is shared between root and sub workspace invocations. --- .../snap-tests/command-pack-monorepo/snap.txt | 18 +++++++++++------- .../command-pack-monorepo/steps.json | 15 ++++++++------- .../vp-build-cache-monorepo/snap.txt | 14 +++++++++----- .../vp-build-cache-monorepo/steps.json | 11 ++++++----- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index 7cceeaf0a8..f45b45ac7f 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -1,12 +1,12 @@ -> vp run hello#build # should build the library +> vp run hello#build # should build the library from root > ls packages/hello/dist # should have the library index.cjs -> vp run hello#build 2>&1 | grep 'cache hit' # should hit cache +> vp run hello#build 2>&1 | grep 'cache hit' # should hit cache from root ~/packages/hello$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. -> cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir +> cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir ~/packages/hello$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. @@ -19,19 +19,23 @@ no cache > vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change ~/packages/hello$ vp pack ○ cache miss: 'packages/hello/src/hello.ts' modified, executing -> vp run array-config#build # should build the library supports array config +> cd packages/array-config && vp run build # should build the library from sub dir > ls packages/array-config/dist # should have the library index.d.mts index.mjs -> vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache +> cd packages/array-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir ~/packages/array-config$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. -> vp run default-config#build # should build the library supports default config +> vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build +~/packages/array-config$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. + +> vp run default-config#build # should build the library from root > ls packages/default-config/dist # should have the library index.mjs -> vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache +> cd packages/default-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir ~/packages/default-config$ vp pack ◉ cache hit, replaying vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index eadbb1f510..59c31fe580 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -1,12 +1,12 @@ { "commands": [ { - "command": "vp run hello#build # should build the library", + "command": "vp run hello#build # should build the library from root", "ignoreOutput": true }, "ls packages/hello/dist # should have the library", - "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache", - "cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir", + "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache from root", + "cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", { "command": "cd packages/hello && vp pack 2>&1 # direct vp pack should not be cached", "ignoreOutput": true @@ -15,16 +15,17 @@ "echo 'export function hello() { console.log(\"changed\"); }' > packages/hello/src/hello.ts", "vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change", { - "command": "vp run array-config#build # should build the library supports array config", + "command": "cd packages/array-config && vp run build # should build the library from sub dir", "ignoreOutput": true }, "ls packages/array-config/dist # should have the library", - "vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache", + "cd packages/array-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", + "vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build", { - "command": "vp run default-config#build # should build the library supports default config", + "command": "vp run default-config#build # should build the library from root", "ignoreOutput": true }, "ls packages/default-config/dist # should have the library", - "vp run default-config#build 2>&1 | grep 'cache hit' # should hit cache" + "cd packages/default-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir" ] } diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt index 2fd5470b38..5a68d8b277 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -1,13 +1,13 @@ -> vp run app#build # should build the app +> vp run app#build # should build the app from root > ls packages/app/dist # should have the build output assets index.html -> vp run app#build 2>&1 | grep 'cache hit' # should hit cache +> vp run app#build 2>&1 | grep 'cache hit' # should hit cache from root ~/packages/app$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. -> cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir +> cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir ~/packages/app$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. @@ -20,11 +20,15 @@ no cache > vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change ~/packages/app$ vp build ○ cache miss: 'packages/app/index.html' modified, executing -> vp run web#build # should build the web +> cd packages/web && vp run build # should build from sub dir first > ls packages/web/dist # should have the build output assets index.html -> vp run web#build 2>&1 | grep 'cache hit' # should hit cache +> cd packages/web && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir +~/packages/web$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. + +> vp run web#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build ~/packages/web$ vp build ◉ cache hit, replaying vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json index ec29feed73..140bd2b6cd 100644 --- a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -1,12 +1,12 @@ { "commands": [ { - "command": "vp run app#build # should build the app", + "command": "vp run app#build # should build the app from root", "ignoreOutput": true }, "ls packages/app/dist # should have the build output", - "vp run app#build 2>&1 | grep 'cache hit' # should hit cache", - "cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache in sub dir", + "vp run app#build 2>&1 | grep 'cache hit' # should hit cache from root", + "cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", { "command": "cd packages/app && vp build 2>&1 # direct vp build should not be cached", "ignoreOutput": true @@ -15,10 +15,11 @@ "echo '' > packages/app/index.html", "vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change", { - "command": "vp run web#build # should build the web", + "command": "cd packages/web && vp run build # should build from sub dir first", "ignoreOutput": true }, "ls packages/web/dist # should have the build output", - "vp run web#build 2>&1 | grep 'cache hit' # should hit cache" + "cd packages/web && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", + "vp run web#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build" ] } From 3531d036b86fea85db770329bf7c958c81f675b7 Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Mar 2026 11:49:25 +0800 Subject: [PATCH 15/15] fix: remove unused vite_str::Str import --- packages/cli/binding/src/cli.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index 89735263d5..a5e0b82119 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -1540,7 +1540,6 @@ mod tests { use clap::Parser; use serde_json::json; - use vite_str::Str; use vite_task::{Command, config::UserRunConfig}; use super::{