@@ -223,26 +223,21 @@ export async function getClientComponentAsync(id: string): Promise<any> {
223223 const clientComponentPaths = ( globalThis as unknown as GlobalWithRari ) [ '~clientComponentPaths' ] || { }
224224 const clientComponentNames = ( globalThis as unknown as GlobalWithRari ) [ '~clientComponentNames' ] || { }
225225
226- let componentInfo = clientComponents [ id ] as LazyComponentInfo
226+ const hashIndex = id . indexOf ( '#' )
227+ const baseId = hashIndex === - 1 ? id : id . slice ( 0 , hashIndex )
228+ const exportName = hashIndex === - 1 ? undefined : id . slice ( hashIndex + 1 )
227229
228- if ( componentInfo ) {
229- const exportName = id . includes ( '#' ) ? id . slice ( id . indexOf ( '#' ) + 1 ) : undefined
230+ let componentInfo = clientComponents [ baseId ] as LazyComponentInfo
231+ if ( componentInfo )
230232 return await ensureComponentLoaded ( componentInfo , exportName )
231- }
232233
233- if ( id . includes ( '#' ) ) {
234- const hashIndex = id . indexOf ( '#' )
235- const path = id . slice ( 0 , hashIndex )
236- const exportName = id . slice ( hashIndex + 1 )
237- const variants = getPathVariants ( path )
238-
239- for ( const variant of variants ) {
240- const componentId = clientComponentPaths [ variant ]
241- if ( componentId ) {
242- componentInfo = clientComponents [ componentId ] as LazyComponentInfo
243- if ( componentInfo )
244- return await ensureComponentLoaded ( componentInfo , exportName )
245- }
234+ const variants = getPathVariants ( baseId )
235+ for ( const variant of variants ) {
236+ const componentId = clientComponentPaths [ variant ]
237+ if ( componentId ) {
238+ componentInfo = clientComponents [ componentId ] as LazyComponentInfo
239+ if ( componentInfo )
240+ return await ensureComponentLoaded ( componentInfo , exportName )
246241 }
247242 }
248243
0 commit comments