The newly released React Router 7.11.0 introduced vite preview support(remix-run/react-router#14507). This change has a bug that affects SPA mode (ssr: false).
When building in SPA mode, React Router correctly builds the server bundle (build/server/index.js) and then removes it with the message Removing the server build... due to ssr:false.
The new vite preview implementation doesn't account for this removal and attempts to import the deleted build/server/index.js file when starting the preview server, causing:
Cannot find module '/build/server/index.js'
Note
The pull request "chore(e2e): Pin to react-router 7.10.1 in spa e2e test" was created by @andreiborza but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.
The newly released React Router 7.11.0 introduced vite preview support(remix-run/react-router#14507). This change has a bug that affects SPA mode (
ssr: false).When building in SPA mode, React Router correctly builds the server bundle (
build/server/index.js) and then removes it with the messageRemoving the server build... due to ssr:false.The new vite preview implementation doesn't account for this removal and attempts to import the deleted
build/server/index.jsfile when starting the preview server, causing: