I'm not sure this resolves the issue, the vite dev react-router is not for releases. I have also tried to configure the react-router package without any luck.
export default defineConfig({
optimizeDeps: {
include: ['react-router-dom'],
},
build: {
commonjsOptions: {
include: [/react-router/, /node_modules/],
},
}
});