Skip to content

fix: resolve outDir against Vite root in buildApp#154

Merged
uhyo merged 1 commit into
masterfrom
claude/issue-141-v4axos
Jul 19, 2026
Merged

fix: resolve outDir against Vite root in buildApp#154
uhyo merged 1 commit into
masterfrom
claude/issue-141-v4axos

Conversation

@uhyo

@uhyo uhyo commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #141.

buildApp used the configured outDir values of the rsc and client environments directly. Since outDir may be a relative path, these resolved against process.cwd() — so running vite build from a directory other than the Vite root (e.g. monorepo root with --config) could break the RSC entry import or write output to the wrong location. Both paths are now resolved with path.resolve(config.root, outDir), matching what serverPlugin already does.

This also guarantees BuildEntryContext.outDir is absolute, as its documentation promises.

Note

While verifying, I found the bug is currently masked in practice: @vitejs/plugin-rsc (0.5.28) rewrites every environment's build.outDir to an absolute path in its own configResolved hook. The fix is still worthwhile — it stops buildApp from silently depending on a dependency's internal behavior, and path.resolve is a no-op on already-absolute paths, so there is no behavior change today.

Verification

  • Built the example app with an explicit root in the Vite config while running vite build from a different working directory; output landed correctly under the Vite root with nothing leaked into the cwd.
  • pnpm build, pnpm typecheck, pnpm lint, all 77 unit tests, and all 29 Playwright e2e tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DEURCLVLKQvqYUrAkqcHpE


Generated by Claude Code

buildApp used the configured outDir values of the rsc and client
environments directly, which resolve against process.cwd() when
relative. If vite build is run from a directory other than the Vite
root (e.g. monorepo root with --config), the RSC entry import and
output writes could target the wrong location. Resolve both against
config.root, matching what serverPlugin already does. This also
guarantees BuildEntryContext.outDir is absolute, as documented.

Closes #141

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DEURCLVLKQvqYUrAkqcHpE
@uhyo
uhyo merged commit ea37f00 into master Jul 19, 2026
2 checks passed
@uhyo
uhyo deleted the claude/issue-141-v4axos branch July 19, 2026 10:12
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.

buildApp resolves outDir against process.cwd() instead of the Vite root

2 participants