File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
packages/react-router-dev/typegen Expand file tree Collapse file tree 1 file changed +11
-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,21 @@ async function createContext({
71
72
} ;
72
73
}
73
74
75
+ function isRouteInAppDirectory ( ctx : Context , route : RouteManifestEntry ) {
76
+ const absoluteRoutePath = Path . resolve ( ctx . config . appDirectory , route . file ) ;
77
+ return absoluteRoutePath . startsWith ( ctx . config . appDirectory ) ;
78
+ }
79
+
74
80
async function writeAll ( ctx : Context ) : Promise < void > {
75
81
const typegenDir = getTypesDir ( ctx ) ;
76
82
77
83
fs . rmSync ( typegenDir , { recursive : true , force : true } ) ;
78
84
Object . values ( ctx . config . routes ) . forEach ( ( route ) => {
85
+ // We only generate types for routes in the app directory
86
+ if ( ! isRouteInAppDirectory ( ctx , route ) ) {
87
+ return ;
88
+ }
89
+
79
90
const typesPath = getTypesPath ( ctx , route ) ;
80
91
const content = generate ( ctx , route ) ;
81
92
fs . mkdirSync ( Path . dirname ( typesPath ) , { recursive : true } ) ;
You can’t perform that action at this time.
0 commit comments