File tree Expand file tree Collapse file tree 3 files changed +50
-25
lines changed
packages/react-router-dev Expand file tree Collapse file tree 3 files changed +50
-25
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { transpile as convertFileToJS } from "./useJavascript";
16
16
import * as profiler from "../vite/profiler" ;
17
17
import * as Typegen from "../typegen" ;
18
18
import { preloadVite , getVite } from "../vite/vite" ;
19
+ import { hasReactRouterRscPlugin } from "../vite/has-rsc-plugin" ;
19
20
20
21
export async function routes (
21
22
rootDirectory ?: string ,
@@ -89,14 +90,32 @@ export async function generateEntry(
89
90
mode ?: string ;
90
91
} = { } ,
91
92
) {
93
+ rootDirectory = resolveRootDirectory ( rootDirectory , flags ) ;
94
+
95
+ if (
96
+ await hasReactRouterRscPlugin ( {
97
+ root : rootDirectory ,
98
+ viteBuildOptions : {
99
+ config : flags . config ,
100
+ mode : flags . mode ,
101
+ } ,
102
+ } )
103
+ ) {
104
+ console . error (
105
+ colors . red (
106
+ `The reveal command is currently not supported in RSC Framework Mode.` ,
107
+ ) ,
108
+ ) ;
109
+ process . exit ( 1 ) ;
110
+ }
111
+
92
112
// if no entry passed, attempt to create both
93
113
if ( ! entry ) {
94
114
await generateEntry ( "entry.client" , rootDirectory , flags ) ;
95
115
await generateEntry ( "entry.server" , rootDirectory , flags ) ;
96
116
return ;
97
117
}
98
118
99
- rootDirectory = resolveRootDirectory ( rootDirectory , flags ) ;
100
119
let configResult = await loadConfig ( {
101
120
rootDirectory,
102
121
mode : flags . mode ?? "production" ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
} from "./plugin" ;
16
16
import invariant from "../invariant" ;
17
17
import { preloadVite , getVite } from "./vite" ;
18
+ import { hasReactRouterRscPlugin } from "./has-rsc-plugin" ;
18
19
export interface ViteBuildOptions {
19
20
assetsInlineLimit ?: number ;
20
21
clearScreen ?: boolean ;
@@ -234,27 +235,3 @@ async function viteBuild(
234
235
viteConfig,
235
236
} ) ;
236
237
}
237
-
238
- async function hasReactRouterRscPlugin ( {
239
- root,
240
- viteBuildOptions : { config, logLevel, mode } ,
241
- } : {
242
- root : string ;
243
- viteBuildOptions : ViteBuildOptions ;
244
- } ) : Promise < boolean > {
245
- const vite = await import ( "vite" ) ;
246
- const viteConfig = await vite . resolveConfig (
247
- {
248
- configFile : config ,
249
- logLevel,
250
- mode : mode ?? "production" ,
251
- root,
252
- } ,
253
- "build" , // command
254
- "production" , // default mode
255
- "production" , // default NODE_ENV
256
- ) ;
257
- return viteConfig . plugins . some (
258
- ( plugin ) => plugin ?. name === "react-router/rsc" ,
259
- ) ;
260
- }
Original file line number Diff line number Diff line change
1
+ import type * as Vite from "vite" ;
2
+
3
+ export async function hasReactRouterRscPlugin ( {
4
+ root,
5
+ viteBuildOptions : { config, logLevel, mode } ,
6
+ } : {
7
+ root : string ;
8
+ viteBuildOptions : {
9
+ config ?: string ;
10
+ logLevel ?: Vite . LogLevel ;
11
+ mode ?: string ;
12
+ } ;
13
+ } ) : Promise < boolean > {
14
+ const vite = await import ( "vite" ) ;
15
+ const viteConfig = await vite . resolveConfig (
16
+ {
17
+ configFile : config ,
18
+ logLevel,
19
+ mode : mode ?? "production" ,
20
+ root,
21
+ } ,
22
+ "build" , // command
23
+ "production" , // default mode
24
+ "production" , // default NODE_ENV
25
+ ) ;
26
+ return viteConfig . plugins . some (
27
+ ( plugin ) => plugin ?. name === "react-router/rsc" ,
28
+ ) ;
29
+ }
You can’t perform that action at this time.
0 commit comments