@@ -22,7 +22,6 @@ import {
2222 configRoutesToRouteManifest ,
2323} from "./routes" ;
2424import { detectPackageManager } from "../cli/detectPackageManager" ;
25- import { ssrExternals } from "../vite/ssr-externals" ;
2625
2726const excludedConfigPresetKeys = [ "presets" ] as const satisfies ReadonlyArray <
2827 keyof ReactRouterConfig
@@ -702,6 +701,34 @@ export async function resolveEntryFiles({
702701 return { entryClientFilePath, entryServerFilePath } ;
703702}
704703
704+ export const ssrExternals = isInReactRouterMonorepo ( )
705+ ? [
706+ // This is only needed within this repo because these packages
707+ // are linked to a directory outside of node_modules so Vite
708+ // treats them as internal code by default.
709+ "react-router" ,
710+ "react-router-dom" ,
711+ "@react-router/architect" ,
712+ "@react-router/cloudflare" ,
713+ "@react-router/dev" ,
714+ "@react-router/express" ,
715+ "@react-router/node" ,
716+ "@react-router/serve" ,
717+ ]
718+ : undefined ;
719+
720+ function isInReactRouterMonorepo ( ) {
721+ // We use '@react-router/node' for this check since it's a
722+ // dependency of this package and guaranteed to be in node_modules
723+ let serverRuntimePath = path . dirname (
724+ require . resolve ( "@react-router/node/package.json" )
725+ ) ;
726+ let serverRuntimeParentDir = path . basename (
727+ path . resolve ( serverRuntimePath , ".." )
728+ ) ;
729+ return serverRuntimeParentDir === "packages" ;
730+ }
731+
705732const entryExts = [ ".js" , ".jsx" , ".ts" , ".tsx" ] ;
706733
707734function findEntry (
0 commit comments