Allow `vp staged` to resolve workspace-root config from subdirectories
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 静か
- 技術スタック
- typescript
調査の方向性
packages/cli/src/staged/bin.ts から始め、次に packages/cli/src/resolve-vite-config.ts にある workspace に限定されたトラバーサルと、packages/cli/src/pack-bin.ts でのその使用箇所を読みます。上記で説明されている root-config-from-package シナリオを再現し、その後、package-local な Vite config のエッジケースを含め、単一の config 解決および実行スコープのポリシーを確立して検証します。
索引モデルが issue の本文から書いたものです。
説明
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:
- Git changes to the worktree root before client-side hooks: https://git-scm.com/docs/githooks
- Husky requires an explicit
cdwhen a hook should run inside a nested project: https://typicode.github.io/husky/how-to.html#project-not-in-git-root-directory - lint-staged documents closest-config selection, isolated configs, config-directory task CWD, and package scoping with
--cwd: https://github.com/lint-staged/lint-staged#how-to-use-lint-staged-in-a-multi-package-monorepo - Lefthook loads from the Git root and uses a command-level
rootoption to change CWD and filter files; globs remain relative to the Git root: https://lefthook.dev/configuration/root/ - pre-commit resolves the Git top level and changes into it before running most commands: https://github.com/pre-commit/pre-commit/blob/main/pre_commit/main.py#L175-L199
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
--configor--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
- Current staged config resolution and inline lint-staged config: https://github.com/voidzero-dev/vite-plus/blob/main/packages/cli/src/staged/bin.ts#L139-L164
- Existing workspace-bounded config traversal: https://github.com/voidzero-dev/vite-plus/blob/main/packages/cli/src/resolve-vite-config.ts#L98-L115
- Existing use of traversal in
vp pack: https://github.com/voidzero-dev/vite-plus/blob/main/packages/cli/src/pack-bin.ts#L148-L150
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.
- 主要言語
- Rust
- スター
- 6k
- フォーク
- 271
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 198
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/vite-plus のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
voidzero-dev/vite-plus#2970 ·
メンテナーはふだん 1 日以内に返信
-
PowerShell `vp` wrapper hides failures: `$?` is `True` and `&&` keeps going after `vp` fails対応中かも @fengmk2 が 2 日前に担当しました。 オープンbug pending triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
voidzero-dev/vite-plus#2934 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Skip the `vpr` hint when the script runs the same built-in対応中かも @kshanxs が今日担当しました。 オープンpending triage
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
voidzero-dev/vite-plus#2892 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
pending triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
voidzero-dev/vite-plus#2882 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
`lazyPlugins` docs: dynamic import of a local module still slows down config loading対応中かも @kshanxs が今日担当しました。 オープンdocumentation pending triage
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
voidzero-dev/vite-plus#2875 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/vite-plus の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
chroma-core/chroma#7879 ·
メンテナーはふだん 1 日以内に返信
-
priority middle
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
KATO-Hiro/AtCoderClans#12838 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信