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";
55import type vite from "vite" ;
66
77import { createConfigLoader } from "../config/config" ;
8+ import type { RouteManifestEntry } from "../config/routes" ;
89
910import { generate } from "./generate" ;
1011import type { Context } from "./context" ;
@@ -71,11 +72,21 @@ async function createContext({
7172 } ;
7273}
7374
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+
7480async function writeAll ( ctx : Context ) : Promise < void > {
7581 const typegenDir = getTypesDir ( ctx ) ;
7682
7783 fs . rmSync ( typegenDir , { recursive : true , force : true } ) ;
7884 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+
7990 const typesPath = getTypesPath ( ctx , route ) ;
8091 const content = generate ( ctx , route ) ;
8192 fs . mkdirSync ( Path . dirname ( typesPath ) , { recursive : true } ) ;
You can’t perform that action at this time.
0 commit comments