Skip to content

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

Description

@uhyo

Problem

In packages/static/src/build/buildApp.ts, both the RSC entry import and all output writes use the configured outDir values directly:

const entryPath = path.join(config.environments.rsc.build.outDir, "index.js");
// ...imported via pathToFileURL(entryPath)
const baseDir = config.environments.client.build.outDir;

outDir may be a relative path, in which case these resolve against process.cwd(). If vite build is run from a directory other than the Vite root (e.g. monorepo root with --config), the entry import fails or output is written to the wrong location.

serverPlugin in packages/static/src/plugin/server.ts already handles this correctly with path.resolve(config.root, config.environments.client.build.outDir).

Suggested fix

Resolve both paths against config.root in buildApp. Note this also affects the outDir passed to the user's custom build entry (BuildEntryContext.outDir), which is documented as an absolute path but currently may not be.

Found during a framework audit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions