fix(vite): use manifest entry filename for server entry import (#3595)

## Summary
When `rollupOptions.output.entryFileNames` is customized in vite config
(e.g. `[hash].mjs`), the generated `server.js` was hardcoding
`server-entry.mjs` as the import path, causing the server to fail to
start.

This fix reads the actual entry filename from the Vite manifest and uses
it in the generated `server.js` import, falling back to
`server-entry.mjs` when no custom naming is configured.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Peiyu Cui
2026-03-25 18:47:02 +00:00
committed by GitHub
co-authored by Bartek Iwańczuk Claude Opus 4.6
parent cdc14a0c6e
commit 421e3394a2
3 changed files with 44 additions and 2 deletions
+11 -1
View File
@@ -133,7 +133,14 @@ export async function withDevServer(
export async function buildVite(
fixtureDir: string,
options?: { base?: string },
options?: {
base?: string;
rollupOutput?: {
entryFileNames?: string;
chunkFileNames?: string;
assetFileNames?: string;
};
},
) {
const tmp = await withTmpDir({
dir: path.join(import.meta.dirname!, ".."),
@@ -151,6 +158,9 @@ export async function buildVite(
ssr: {
build: {
outDir: path.join(tmp.dir, "_fresh", "server"),
rollupOptions: options?.rollupOutput
? { output: options.rollupOutput }
: undefined,
},
},
client: {