@@ -16,6 +16,7 @@ interface FutureConfig {
1616 v3_fetcherPersist : boolean ;
1717 v3_relativeSplatPath : boolean ;
1818 v3_throwAbortReason : boolean ;
19+ unstable_serverComponents : boolean ;
1920 unstable_singleFetch : boolean ;
2021}
2122
@@ -80,6 +81,11 @@ export interface RemixConfig {
8081 */
8182 entryServerFilePath : string ;
8283
84+ /**
85+ * The absolute path to the entry.react-server file.
86+ */
87+ entryReactServerFilePath : string ;
88+
8389 /**
8490 * An object of all available routes, keyed by route id.
8591 */
@@ -120,9 +126,15 @@ export async function resolveConfig(
120126
121127 let userEntryClientFile = findEntry ( appDirectory , "entry.client" ) ;
122128 let userEntryServerFile = findEntry ( appDirectory , "entry.server" ) ;
129+ let userEntryReactServerFile = findEntry ( appDirectory , "entry.react-server" ) ;
123130
124131 let entryServerFile : string ;
125- let entryClientFile = userEntryClientFile || "entry.client.tsx" ;
132+ let entryClientFile =
133+ userEntryClientFile ||
134+ ( appConfig . future ?. unstable_serverComponents
135+ ? "entry.client-rsc.tsx"
136+ : "entry.client.tsx" ) ;
137+ let entryReactServerFile ;
126138
127139 let pkgJson = await PackageJson . load ( rootDirectory ) ;
128140 let deps = pkgJson . content . dependencies ?? { } ;
@@ -185,6 +197,34 @@ export async function resolveConfig(
185197 entryServerFile = `entry.server.${ serverRuntime } .tsx` ;
186198 }
187199
200+ if ( userEntryReactServerFile ) {
201+ entryReactServerFile = userEntryReactServerFile ;
202+ } else {
203+ let serverRuntime = deps [ "@react-router/deno" ]
204+ ? "deno"
205+ : deps [ "@react-router/cloudflare" ]
206+ ? "cloudflare"
207+ : deps [ "@react-router/node" ]
208+ ? "node"
209+ : undefined ;
210+
211+ if ( ! serverRuntime ) {
212+ let serverRuntimes = [
213+ "@react-router/deno" ,
214+ "@react-router/cloudflare" ,
215+ "@react-router/node" ,
216+ ] ;
217+ let formattedList = disjunctionListFormat . format ( serverRuntimes ) ;
218+ throw new Error (
219+ `Could not determine server runtime. Please install one of the following: ${ formattedList } `
220+ ) ;
221+ }
222+
223+ entryReactServerFile = `entry.react-server.${
224+ serverRuntime === "node" ? "node" : "web"
225+ } .tsx`;
226+ }
227+
188228 let entryClientFilePath = userEntryClientFile
189229 ? path . resolve ( appDirectory , userEntryClientFile )
190230 : path . resolve ( defaultsDirectory , entryClientFile ) ;
@@ -193,6 +233,10 @@ export async function resolveConfig(
193233 ? path . resolve ( appDirectory , userEntryServerFile )
194234 : path . resolve ( defaultsDirectory , entryServerFile ) ;
195235
236+ let entryReactServerFilePath = userEntryReactServerFile
237+ ? path . resolve ( appDirectory , userEntryReactServerFile )
238+ : path . resolve ( defaultsDirectory , entryReactServerFile ) ;
239+
196240 let rootRouteFile = findEntry ( appDirectory , "root" ) ;
197241 if ( ! rootRouteFile ) {
198242 throw new Error ( `Missing "root" route file in ${ appDirectory } ` ) ;
@@ -215,17 +259,23 @@ export async function resolveConfig(
215259 }
216260 }
217261
262+ let unstable_serverComponents =
263+ appConfig . future ?. unstable_serverComponents === true ;
218264 let future : FutureConfig = {
219265 v3_fetcherPersist : appConfig . future ?. v3_fetcherPersist === true ,
220266 v3_relativeSplatPath : appConfig . future ?. v3_relativeSplatPath === true ,
221267 v3_throwAbortReason : appConfig . future ?. v3_throwAbortReason === true ,
222- unstable_singleFetch : appConfig . future ?. unstable_singleFetch === true ,
268+ unstable_singleFetch :
269+ appConfig . future ?. unstable_singleFetch === true ||
270+ unstable_serverComponents ,
271+ unstable_serverComponents,
223272 } ;
224273
225274 return {
226275 appDirectory,
227276 entryClientFilePath,
228277 entryServerFilePath,
278+ entryReactServerFilePath,
229279 routes,
230280 serverModuleFormat,
231281 future,
0 commit comments