feat: add object form for input globs with base directory#295
feat: add object form for input globs with base directory#295branchseer merged 4 commits intomainfrom
Conversation
Allow glob patterns to resolve relative to the workspace root using
`{ "pattern": "...", "base": "workspace" | "package" }` syntax.
https://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The fixture was a root package where package_dir == workspace_root, making workspace-base indistinguishable from package-base. Now uses a packages/app subpackage so the snapshot clearly shows the difference. https://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw
There was a problem hiding this comment.
Pull request overview
Adds support for specifying a base directory for input glob patterns via an object form, enabling workspace-root-relative glob resolution while preserving existing package-relative string behavior.
Changes:
- Introduces
{ pattern, base }input entry form withbase: "workspace" | "package"and updates input resolution logic accordingly. - Adds unit tests and a snapshot fixture to validate deserialization and resolution across bases (including negation).
- Updates docs, TypeScript type generation output, and changelog to describe the new capability.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/inputs.md | Documents the new object form, updates behavior summary, and clarifies base resolution behavior. |
| crates/vite_task_graph/src/config/user.rs | Adds InputBase and a new UserInputEntry variant; extends serde tests for the new form. |
| crates/vite_task_graph/src/config/mod.rs | Implements base-aware glob resolution via a shared insert_glob helper and adds resolution tests. |
| crates/vite_task_graph/run-config.ts | Updates generated TS types/docs to include InputBase and the object input entry shape. |
| crates/vite_task_plan/tests/plan_snapshots/fixtures/input-workspace-base/** | Adds a workspace-based fixture and snapshot verifying workspace-relative resolution in the plan output. |
| CLAUDE.md | Updates example configuration to include the new object-form input entry. |
| CHANGELOG.md | Records the new feature in the changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
docs/inputs.md
Outdated
| "inputs": [ | ||
| "src/**", | ||
| { "pattern": "configs/tsconfig.json", "base": "workspace" }, | ||
| { "pattern": "!dist/**", "base": "workspace" } | ||
| ] |
There was a problem hiding this comment.
The configuration key is inconsistent with the rest of the PR (and the examples/fixtures), which use \"input\" (singular). This new example uses \"inputs\", which will mislead users and likely won’t match actual config parsing. Rename \"inputs\" to \"input\" here (and consider aligning the Behavior Summary rows you touched in the same doc section to use input: as well).
| #[serde(untagged)] | ||
| pub enum UserInputEntry { | ||
| /// Glob pattern (positive or negative starting with `!`) | ||
| /// Glob pattern (positive or negative starting with `!`), resolved relative to package dir | ||
| Glob(Str), | ||
| /// Glob pattern with explicit base directory | ||
| GlobWithBase { | ||
| /// The glob pattern (positive or negative starting with `!`) | ||
| pattern: Str, | ||
| /// The base directory for resolving the pattern | ||
| base: InputBase, | ||
| }, |
There was a problem hiding this comment.
Because GlobWithBase is an inline struct variant under #[serde(untagged)] and does not deny unknown fields, objects that accidentally include extra keys (e.g. { \"auto\": true, \"pattern\": \"...\", \"base\": \"workspace\" }) may deserialize successfully but silently ignore the extra fields. To make configuration errors fail fast, consider using deny_unknown_fields for object variants (typically by moving GlobWithBase/Auto into dedicated structs annotated with #[serde(deny_unknown_fields)], then referencing those structs from the enum variants).
- Fix `"inputs"` → `"input"` in docs/inputs.md to match actual config field name
- Extract GlobWithBase and AutoInput into dedicated structs with
`#[serde(deny_unknown_fields)]` so ambiguous objects like
`{ "auto": true, "pattern": "...", "base": "workspace" }` are rejected
- Add test for mixed auto+glob fields rejection
- Regenerate TypeScript type definitions
https://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw
Summary
{ "base": "workspace" | "package", "pattern": "..."}to resolve glob patterns relative to the workspace root instead of the package directory!) is supported in both the bare string and object formsbaseis required in the object form — if you want package-relative, just use a bare string.{ "base": "package", "pattern": "src/**" }is equivalent to"src/**".Example
{ "input": [ "src/**", { "base": "workspace", "pattern": "configs/tsconfig.json" }, { "base": "workspace", "pattern": "!dist/**"}, { "auto": true } ] }Test plan
baseerror, invalidbaseerror, mixed arrays)input-workspace-base) verifying workspace-relative resolutionhttps://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw