File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
packages/react-router-dev/typegen Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import pc from "picocolors";
5
5
import type vite from "vite" ;
6
6
7
7
import { createConfigLoader } from "../config/config" ;
8
+ import type { RouteManifestEntry } from "../config/routes" ;
8
9
9
10
import { generate } from "./generate" ;
10
11
import type { Context } from "./context" ;
@@ -71,11 +72,24 @@ async function createContext({
71
72
} ;
72
73
}
73
74
75
+ function isRouteInAppDirectory ( ctx : Context , route : RouteManifestEntry ) {
76
+ const absoluteRoutePath = Path . isAbsolute ( route . file )
77
+ ? route . file
78
+ : Path . resolve ( ctx . config . appDirectory , route . file ) ;
79
+
80
+ return absoluteRoutePath . startsWith ( ctx . config . appDirectory ) ;
81
+ }
82
+
74
83
async function writeAll ( ctx : Context ) : Promise < void > {
75
84
const typegenDir = getTypesDir ( ctx ) ;
76
85
77
86
fs . rmSync ( typegenDir , { recursive : true , force : true } ) ;
78
87
Object . values ( ctx . config . routes ) . forEach ( ( route ) => {
88
+ // We only generate types for routes in the app directory
89
+ if ( ! isRouteInAppDirectory ( ctx , route ) ) {
90
+ return ;
91
+ }
92
+
79
93
const typesPath = getTypesPath ( ctx , route ) ;
80
94
const content = generate ( ctx , route ) ;
81
95
fs . mkdirSync ( Path . dirname ( typesPath ) , { recursive : true } ) ;
You can’t perform that action at this time.
0 commit comments