You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: strip UTF-8 BOM from package.json before parsing (#424)
## Problem
`vp run XYZ` fails to load the task graph when a `package.json` is
encoded with a UTF-8 byte order mark (BOM, `EF BB BF`):
```
error: Failed to load task graph
* Failed to load package graph
* Failed to parse JSON file at ".../utf8-bom-package/package.json"
```
`serde_json::from_slice` does not tolerate a leading BOM, so a single
BOM-encoded `package.json` (as written by some editors/tools, especially
on Windows) aborts the entire package-graph load.
## Fix
Added a `strip_bom` helper in `vite_workspace` and applied it at every
`package.json` / workspace-JSON parse site before deserializing:
- `package_manager.rs` — workspace detection (`find_workspace_root`)
- `lib.rs` — npm/yarn workspace JSON, non-workspace package, workspace
members (glob walk), and the root package fallback
Only a *leading* BOM is stripped; everything else is passed through
unchanged.
## Tests
- `test_strip_bom` — unit coverage (leading BOM, no BOM, non-leading
bytes, empty)
- `test_get_package_graph_package_json_with_bom` — pnpm workspace with
BOMs in root + member `package.json`
- `test_get_package_graph_single_package_with_bom` — non-workspace
package path
All `vite_workspace` tests pass; `cargo fmt` and `cargo clippy` are
clean.
https://claude.ai/code/session_017dv1DPTTkkt65M9s55wPHb
---
_Generated by [Claude
Code](https://claude.ai/code/session_017dv1DPTTkkt65M9s55wPHb)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
# Changelog
2
2
3
+
-**Fixed**`package.json` and `pnpm-workspace.yaml` files with a UTF-8 BOM no longer fail to parse ([#424](https://github.com/voidzero-dev/vite-task/pull/424))
3
4
-**Changed**`vp run --filter <expr>` now exits 0 with a warning when the filter matches no packages, matching pnpm. Use `--fail-if-no-match` to restore the previous strict behavior ([#393](https://github.com/voidzero-dev/vite-task/pull/393))
4
5
-**Added** task command shorthands for defining tasks as command strings or command string arrays ([#391](https://github.com/voidzero-dev/vite-task/pull/391))
5
6
-**Changed** Cached logs are stored with colors intact (`FORCE_COLOR=1` is auto-injected into spawned tasks). Colors are then stripped at display time when the terminal does not support them. Other color-related env vars (`NO_COLOR`, `COLORTERM`, `TERM`, `TERM_PROGRAM`) are no longer passed through by default. Opt in via a task's `env`/`untrackedEnv` ([#378](https://github.com/voidzero-dev/vite-task/pull/378))
0 commit comments