@@ -170,82 +170,89 @@ export function generateRoutes(ctx: Context): VirtualFile {
170
170
export function generateRouteModuleAnnotations (
171
171
ctx : Context
172
172
) : Array < VirtualFile > {
173
- return Object . values ( ctx . config . routes ) . map ( ( route ) => {
174
- const filename = getRouteModuleAnnotationsFilepath ( ctx , route ) ;
173
+ return Object . values ( ctx . config . routes )
174
+ . filter ( ( route ) => isRouteInAppDirectory ( ctx , route ) )
175
+ . map ( ( route ) => {
176
+ const filename = getRouteModuleAnnotationsFilepath ( ctx , route ) ;
175
177
176
- const parents = getParents ( ctx , route ) ;
178
+ const parents = getParents ( ctx , route ) ;
177
179
178
- const content = ts `
179
- // Generated by React Router
180
+ const content = ts `
181
+ // Generated by React Router
180
182
181
- import type {
182
- Params,
183
- RouteModuleAnnotations,
184
- CreateLoaderData,
185
- CreateActionData,
186
- } from "react-router/internal";
183
+ import type {
184
+ Params,
185
+ RouteModuleAnnotations,
186
+ CreateLoaderData,
187
+ CreateActionData,
188
+ } from "react-router/internal";
187
189
188
- ${ parents . map ( ( parent ) => parent . import ) . join ( "\n" + " " . repeat ( 3 ) ) }
189
- type Parents = [${ parents . map ( ( parent ) => parent . name ) . join ( ", " ) } ]
190
+ ${ parents . map ( ( parent ) => parent . import ) . join ( "\n" + " " . repeat ( 3 ) ) }
191
+ type Parents = [${ parents . map ( ( parent ) => parent . name ) . join ( ", " ) } ]
190
192
191
- type Id = "${ route . id } "
192
- type Module = typeof import("../${ Pathe . filename ( route . file ) } .js")
193
+ type Id = "${ route . id } "
194
+ type Module = typeof import("../${ Pathe . filename ( route . file ) } .js")
193
195
194
- export type unstable_Props = {
195
- params: Params[Id]
196
- loaderData: CreateLoaderData<Module>
197
- actionData: CreateActionData<Module>
198
- }
196
+ export type unstable_Props = {
197
+ params: Params[Id]
198
+ loaderData: CreateLoaderData<Module>
199
+ actionData: CreateActionData<Module>
200
+ }
199
201
200
- type Annotations = RouteModuleAnnotations<unstable_Props & {
201
- parents: Parents,
202
- module: Module,
203
- }>;
202
+ type Annotations = RouteModuleAnnotations<unstable_Props & {
203
+ parents: Parents,
204
+ module: Module,
205
+ }>;
204
206
205
- export namespace Route {
206
- // links
207
- export type LinkDescriptors = Annotations["LinkDescriptors"];
208
- export type LinksFunction = Annotations["LinksFunction"];
207
+ export namespace Route {
208
+ // links
209
+ export type LinkDescriptors = Annotations["LinkDescriptors"];
210
+ export type LinksFunction = Annotations["LinksFunction"];
209
211
210
- // meta
211
- export type MetaArgs = Annotations["MetaArgs"];
212
- export type MetaDescriptors = Annotations["MetaDescriptors"];
213
- export type MetaFunction = Annotations["MetaFunction"];
212
+ // meta
213
+ export type MetaArgs = Annotations["MetaArgs"];
214
+ export type MetaDescriptors = Annotations["MetaDescriptors"];
215
+ export type MetaFunction = Annotations["MetaFunction"];
214
216
215
- // headers
216
- export type HeadersArgs = Annotations["HeadersArgs"];
217
- export type HeadersFunction = Annotations["HeadersFunction"];
217
+ // headers
218
+ export type HeadersArgs = Annotations["HeadersArgs"];
219
+ export type HeadersFunction = Annotations["HeadersFunction"];
218
220
219
- // unstable_middleware
220
- export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
221
+ // unstable_middleware
222
+ export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
221
223
222
- // unstable_clientMiddleware
223
- export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
224
+ // unstable_clientMiddleware
225
+ export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
224
226
225
- // loader
226
- export type LoaderArgs = Annotations["LoaderArgs"];
227
+ // loader
228
+ export type LoaderArgs = Annotations["LoaderArgs"];
227
229
228
- // clientLoader
229
- export type ClientLoaderArgs = Annotations["ClientLoaderArgs"];
230
+ // clientLoader
231
+ export type ClientLoaderArgs = Annotations["ClientLoaderArgs"];
230
232
231
- // action
232
- export type ActionArgs = Annotations["ActionArgs"];
233
+ // action
234
+ export type ActionArgs = Annotations["ActionArgs"];
233
235
234
- // clientAction
235
- export type ClientActionArgs = Annotations["ClientActionArgs"];
236
+ // clientAction
237
+ export type ClientActionArgs = Annotations["ClientActionArgs"];
236
238
237
- // HydrateFallback
238
- export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
239
+ // HydrateFallback
240
+ export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
239
241
240
- // Component
241
- export type ComponentProps = Annotations["ComponentProps"];
242
+ // Component
243
+ export type ComponentProps = Annotations["ComponentProps"];
242
244
243
- // ErrorBoundary
244
- export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
245
- }
246
- ` ;
247
- return { filename, content } ;
248
- } ) ;
245
+ // ErrorBoundary
246
+ export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
247
+ }
248
+ ` ;
249
+ return { filename, content } ;
250
+ } ) ;
251
+ }
252
+
253
+ function isRouteInAppDirectory ( ctx : Context , route : RouteManifestEntry ) {
254
+ const absoluteRoutePath = Path . resolve ( ctx . config . appDirectory , route . file ) ;
255
+ return absoluteRoutePath . startsWith ( ctx . config . appDirectory ) ;
249
256
}
250
257
251
258
function getRouteModuleAnnotationsFilepath (
0 commit comments