@@ -13,7 +13,6 @@ import type { Context } from "./context";
13
13
import { getTypesDir , getTypesPath } from "./paths" ;
14
14
import * as Params from "./params" ;
15
15
import * as Route from "./route" ;
16
- import type { RouteManifestEntry } from "../config/routes" ;
17
16
18
17
export async function run ( rootDirectory : string , { mode } : { mode : string } ) {
19
18
const ctx = await createContext ( { rootDirectory, mode, watch : false } ) ;
@@ -109,24 +108,19 @@ function register(ctx: Context) {
109
108
110
109
const { t } = Babel ;
111
110
112
- const fullpaths : Record < string , RouteManifestEntry [ ] > = { } ;
113
- for ( const route of Object . values ( ctx . config . routes ) ) {
114
- // skip pathless (layout) routes
115
- if ( route . id !== "root" && ! route . path ) continue ;
116
-
111
+ const fullpaths = new Set < string > ( ) ;
112
+ Object . values ( ctx . config . routes ) . forEach ( ( route ) => {
113
+ if ( route . id !== "root" && ! route . path ) return ;
117
114
const lineage = Route . lineage ( ctx . config . routes , route ) ;
118
115
const fullpath = Route . fullpath ( lineage ) ;
119
- const existing = fullpaths [ fullpath ] ;
120
- if ( ! existing || existing . length < lineage . length ) {
121
- fullpaths [ fullpath ] = lineage ;
122
- }
123
- }
116
+ fullpaths . add ( fullpath ) ;
117
+ } ) ;
124
118
125
119
const typeParams = t . tsTypeAliasDeclaration (
126
120
t . identifier ( "Params" ) ,
127
121
null ,
128
122
t . tsTypeLiteral (
129
- Object . keys ( fullpaths ) . map ( ( fullpath ) => {
123
+ Array . from ( fullpaths ) . map ( ( fullpath ) => {
130
124
const params = Params . parse ( fullpath ) ;
131
125
return t . tsPropertySignature (
132
126
t . stringLiteral ( fullpath ) ,
0 commit comments