Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions packages/cli/binding/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserInputEntry> {
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
Expand Down Expand Up @@ -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 =
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/snap-tests/check-cache-disabled/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "check-cache-disabled-test",
"type": "module",
"scripts": {
"check": "vp check"
}
}
5 changes: 5 additions & 0 deletions packages/cli/snap-tests/check-cache-disabled/snap.txt
Original file line number Diff line number Diff line change
@@ -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 (<variable>ms, <variable> threads)
pass: Found no warnings or lint errors in 1 file (<variable>ms, <variable> threads)

5 changes: 5 additions & 0 deletions packages/cli/snap-tests/check-cache-disabled/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function hello() {
return "hello";
}

export { hello };
3 changes: 3 additions & 0 deletions packages/cli/snap-tests/check-cache-disabled/steps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"commands": ["vp run check # vp check should have cache disabled without run.cache"]
}
7 changes: 7 additions & 0 deletions packages/cli/snap-tests/check-cache-enabled/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "check-cache-enabled-test",
"type": "module",
"scripts": {
"check": "vp check"
}
}
20 changes: 20 additions & 0 deletions packages/cli/snap-tests/check-cache-enabled/snap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
> vp run check # first run should be cache miss
$ vp check
pass: All 4 files are correctly formatted (<variable>ms, <variable> threads)
pass: Found no warnings or lint errors in 2 files (<variable>ms, <variable> threads)


> vp run check # second run should be cache hit
$ vp check ◉ cache hit, replaying
pass: All 4 files are correctly formatted (<variable>ms, <variable> threads)
pass: Found no warnings or lint errors in 2 files (<variable>ms, <variable> threads)

---
vp run: cache hit, <variable>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 (<variable>ms, <variable> threads)
pass: Found no warnings or lint errors in 3 files (<variable>ms, <variable> threads)

5 changes: 5 additions & 0 deletions packages/cli/snap-tests/check-cache-enabled/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function hello() {
return "hello";
}

export { hello };
9 changes: 9 additions & 0 deletions packages/cli/snap-tests/check-cache-enabled/steps.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
5 changes: 5 additions & 0 deletions packages/cli/snap-tests/check-cache-enabled/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
run: {
cache: true,
},
};
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading