Skip to content

fix(build): run build-mode checkers from the resolved Vite root - #802

Open
DanMat wants to merge 1 commit into
fi3ework:mainfrom
DanMat:fix/build-checker-cwd-root
Open

fix(build): run build-mode checkers from the resolved Vite root#802
DanMat wants to merge 1 commit into
fi3ework:mainfrom
DanMat:fix/build-checker-cwd-root

Conversation

@DanMat

@DanMat DanMat commented Aug 18, 2026

Copy link
Copy Markdown

Closes #631

Problem

Checker commands run from a different working directory in serve vs build mode:

  • Serve (configureServer): cwd is userConfig.root || server.config.root.
  • Build (spawnChecker): cwd was process.cwd().

For lintCommand-based checkers (eslint, oxlint) this is inconsistent in monorepos where Vite's root differs from the current working directory: the same lint command resolves configs/paths differently between vite and vite build.

Fix

Capture the resolved root in configResolved and use userConfig.root || resolvedRoot as the cwd for the spawned build commands (and their npm-run-path env), matching serve mode.

This is a no-op when root already equals process.cwd() (the common case, and what the e2e playground harness exercises, since it runs vite build with cwd set to the project root). Behavior only changes in the monorepo case the issue describes.

Tests

Added __tests__/spawnChecker.spec.ts asserting the build command spawns with the provided cwd. spawnChecker is exported so it can be unit-tested in isolation. Full unit project passes (43 tests), tsc --noEmit and biome are clean.

Written with AI assistance; I've reviewed and tested the change and will maintain it.

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().
@netlify

netlify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Deploy Preview for vite-plugin-checker ready!

Name Link
🔨 Latest commit 2c626c4
🔍 Latest deploy log https://app.netlify.com/projects/vite-plugin-checker/deploys/6a84b1a38c9b92000877c2cb
😎 Deploy Preview https://deploy-preview-802--vite-plugin-checker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Aug 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/vite-plugin-checker@802

commit: 2c626c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config.root not used by build but is used by server

1 participant