Skip to content

Commit 938ea44

Browse files
branchseerclaude
andcommitted
feat: allow comments (JSONC) in vite-task.json
Use jsonc-parser to parse vite-task.json, enabling // line comments, /* */ block comments, and trailing commas. Add comments to several test fixture files to exercise this. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b16e3cd commit 938ea44

File tree

8 files changed

+20
-1
lines changed

8 files changed

+20
-1
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ fspy_test_utils = { path = "crates/fspy_test_utils" }
7575
futures = "0.3.31"
7676
futures-util = "0.3.31"
7777
insta = "1.44.3"
78+
jsonc-parser = { version = "0.29.0", features = ["serde"] }
7879
libc = "0.2.172"
7980
memmap2 = "0.9.7"
8081
monostate = "1.0.2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
// Smoke test: enables caching for all package.json scripts.
23
"cacheScripts": true
34
}

crates/vite_task_graph/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ rust-version.workspace = true
1010
anyhow = { workspace = true }
1111
async-trait = { workspace = true }
1212
clap = { workspace = true, features = ["derive"] }
13+
jsonc-parser = { workspace = true }
1314
monostate = { workspace = true }
1415
petgraph = { workspace = true }
1516
serde = { workspace = true, features = ["derive"] }

crates/vite_task_graph/src/loader.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ impl UserConfigLoader for JsonUserConfigLoader {
3333
}
3434
Err(err) => return Err(err.into()),
3535
};
36-
let user_config: UserRunConfig = serde_json::from_str(&config_content)?;
36+
let json_value = jsonc_parser::parse_to_serde_value(&config_content, &Default::default())?
37+
.unwrap_or_default();
38+
let user_config: UserRunConfig = serde_json::from_value(json_value)?;
3739
Ok(Some(user_config))
3840
}
3941
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
// Enables caching for all package.json scripts in the workspace.
23
"cacheScripts": true
34
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
// Enables caching for all package.json scripts in the workspace.
23
"cacheScripts": true
34
}

crates/vite_task_plan/tests/plan_snapshots/fixtures/workspace-root-no-package-json/vite-task.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
// This workspace root has no package.json — only pnpm-workspace.yaml.
3+
// vite-task.json should still be loaded and applied.
24
"cacheScripts": true,
35
"tasks": {
46
"deploy": {

0 commit comments

Comments
 (0)