fix(build): run build-mode checkers from the resolved Vite root - #802
Open
DanMat wants to merge 1 commit into
Open
fix(build): run build-mode checkers from the resolved Vite root#802DanMat wants to merge 1 commit into
DanMat wants to merge 1 commit into
Conversation
In serve mode, checker commands run with cwd set to userConfig.root || config.root (see configureServer). In build mode they were spawned with process.cwd() instead, so lintCommand-based checkers (eslint, oxlint) behaved inconsistently in monorepos where Vite's root differs from the current working directory. Capture the resolved root in configResolved and use it (falling back to an explicit root option, then process.cwd()) as the cwd for the spawned build commands and their npm-run-path env, matching serve mode. This is a no-op when the root already equals process.cwd().
✅ Deploy Preview for vite-plugin-checker ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #631
Problem
Checker commands run from a different working directory in serve vs build mode:
configureServer):cwdisuserConfig.root || server.config.root.spawnChecker):cwdwasprocess.cwd().For
lintCommand-based checkers (eslint, oxlint) this is inconsistent in monorepos where Vite'srootdiffers from the current working directory: the same lint command resolves configs/paths differently betweenviteandvite build.Fix
Capture the resolved root in
configResolvedand useuserConfig.root || resolvedRootas thecwdfor the spawned build commands (and theirnpm-run-pathenv), matching serve mode.This is a no-op when
rootalready equalsprocess.cwd()(the common case, and what the e2e playground harness exercises, since it runsvite buildwithcwdset to the project root). Behavior only changes in the monorepo case the issue describes.Tests
Added
__tests__/spawnChecker.spec.tsasserting the build command spawns with the providedcwd.spawnCheckeris exported so it can be unit-tested in isolation. Full unit project passes (43 tests),tsc --noEmitand biome are clean.Written with AI assistance; I've reviewed and tested the change and will maintain it.