Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Allow `vp staged` to resolve workspace-root config from subdirectories

Đang mở
#2,177 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Bắt đầu với packages/cli/src/staged/bin.ts, sau đó đọc cơ chế duyệt giới hạn trong workspace ở packages/cli/src/resolve-vite-config.ts và cách nó được sử dụng trong packages/cli/src/pack-bin.ts. Tái hiện kịch bản root-config-from-package được mô tả ở trên, rồi thiết lập và xác thực một chính sách duy nhất về việc phân giải config và phạm vi thực thi, bao gồm cả trường hợp biên của Vite config cục bộ trong package.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

pending triage
Description

In a monorepo, vp staged fails when invoked from a workspace package if the staged config exists only in the workspace-root vite.config.ts.

This is common with coding agents: after inspecting or editing one package, they often keep that package as the working directory when running validation commands.

repo/
├── package.json          # workspaces: ["packages/*"]
├── vite.config.ts        # contains staged config
└── packages/
    └── app/
        └── src/index.ts
// repo/vite.config.ts
export default {
  staged: {
    '*.{js,ts,tsx}': 'vp check --fix',
  },
}
git add packages/app/src/index.ts
cd packages/app
vp staged

Actual result:

error: No "staged" config found in vite.config.ts. Please add a staged config

A normal pre-commit hook usually hides this behavior because Git starts client-side hooks from the worktree root, regardless of where git commit was entered.

Current behavior

The following was verified with an isolated Git monorepo:

Invocation Config File/task scope
Run from repository root Root vite.config.ts Repository
Run from a package with no local staged config None; exits with an error Nothing runs
Run from a package with a local staged config Package config Package CWD
Run from a package with --cwd <workspace-root> Root config Repository
Run through a Git pre-commit hook Root config, because Git uses the worktree root Repository

Internally, Vite+ resolves one staged object from the invocation CWD and passes it through lint-staged's programmatic config option. lint-staged still resolves the Git repository and staged files, but its own multi-config discovery is bypassed.

Ecosystem patterns

Existing tools use different models:

Model Tools Behavior
Hook manager Git, Husky, simple-git-hooks Git starts hooks at the worktree root. The manager executes a literal hook command; package-specific CWD or filtering is left to that command.
Central root config pre-commit, Lefthook The tool resolves the Git root and loads a repository-level config. Package behavior is expressed through filters or per-command root settings.
Distributed config lint-staged The tool can discover multiple configs, assign each staged file to its closest config, and run tasks from the selected config directory. Configs are isolated rather than merged.
Current Vite+ behavior vp staged Git state is repository-aware through lint-staged, while Vite config lookup remains limited to the invocation CWD.

Relevant details:

Design choices

There are two separate decisions. This issue does not propose a preferred combination.

1. Where should config come from?
  • Current CWD only: preserve existing behavior; improve documentation/error output and require callers to use root CWD or --cwd.
  • Workspace/Git root: always use one central root policy.
  • Nearest ancestor config: walk upward to the workspace root. This could stop at the first Vite config, or continue until finding one that defines staged.
  • Multiple configs: discover package/root staged configs and assign files to them independently.
  • Explicit selection: add an option such as --config or --root; this can supplement any implicit rule.

Important edge case: a package may have a vite.config.ts for build settings but keep staged only at the workspace root. “Nearest Vite config” and “nearest config defining staged” produce different results.

2. What should the execution scope be?
  • Repository root: task CWD, glob base, and staged-file scope all use the root.
  • Invocation directory: an inherited/root config can be used while files and tasks remain scoped to the package from which the command was launched.
  • Config directory: tasks and file matching follow whichever config was selected.

These choices have different consequences. Root scope may process staged files in sibling packages; invocation scope may run root-defined commands from a package CWD; config-directory scope becomes more complex if multiple configs are supported.

Possible combinations include:

  • root config + root scope;
  • nearest ancestor config + invocation scope;
  • current behavior + an explicit config/root option;
  • multiple configs + per-config task scope.
Relevant implementation
Validations
  • Read the Contributing Guidelines.
  • Confirm this request is for Vite+ itself and not for Vite, Vitest, tsdown, Rolldown, or Oxc.
  • Checked that there is not already an open issue requesting the same behavior.
Ngôn ngữ chính
Rust
Star
6k
Fork
274
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
203

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của voidzero-dev/vite-plus

Tất cả issue của voidzero-dev/vite-plus

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.