Repository: nuxt/nuxt
File: packages/nuxt/src/pages/runtime/page.ts (TypeScript)

Code before:
                }).finally(done))
              },
            }, {
              default: () => {
                const routeProviderProps = {
                  key: key || undefined,
                  vnode: pageVnode,
                  route: routeProps.route,
                  renderKey: key || undefined,
                  trackRootNodes: hasTransition,
                  vnodeRef: pageRef,
                }

                if (!keepaliveConfig) {
                  return h(RouteProvider, routeProviderProps)
                }

                const routerComponentType = routeProps.Component.type as any
                const routerComponentName = routerComponentType.name || routerComponentType.__name

                let PageRouteProvider = routerProviderLookup[routerComponentName]

                if (!PageRouteProvider) {
                  PageRouteProvider = defineRouteProvider(routerComponentName)
                  routerProviderLookup[routerComponentName] = PageRouteProvider
                }

                return h(PageRouteProvider, routeProviderProps)
              },
            }),
            )).default()

          return vnode
        },
      })
    }
  },
})

function _mergeTransitionProps (routeProps: TransitionProps[]): TransitionProps {
  const _props: TransitionProps[] = routeProps.map(prop => ({
    ...prop,
    onAfterLeave: prop.onAfterLeave ? toArray(prop.onAfterLeave) : undefined,
  }))
  return defu(..._props as [TransitionProps, TransitionProps])
}

function haveParentRoutesRendered (fork: RouteLocationNormalizedLoaded | null, newRoute: RouteLocationNormalizedLoaded, Component?: VNode) {
  if (!fork) { return false }

  const index = newRoute.matched.findIndex(m => m.components?.default === Component?.type)

Review comment (suggestion):
```suggestion
                const PageRouteProvider = routerProviderLookup[routerComponentName] ||= defineRouteProvider(routerComponentName)
```

Code after:
            defaultPageTransition,
            { onAfterLeave: () => { nuxtApp.callHook('page:transition:finish', routeProps.Component) } },
          ].filter(Boolean))

          const keepaliveConfig = props.keepalive ?? routeProps.route.meta.keepalive ?? (defaultKeepaliveConfig as KeepAliveProps)
          vnode = _wrapInTransition(hasTransition && transitionProps,
            wrapInKeepAlive(keepaliveConfig, h(Suspense, {
              suspensible: true,
              onPending: () => nuxtApp.callHook('page:start', routeProps.Component),
              onResolve: () => {
                nextTick(() => nuxtApp.callHook('page:finish', routeProps.Component).then(() => {
                  if (!pageLoadingEndHookAlreadyCalled) {
                    return nuxtApp.callHook('page:loading:end')
                  }
                  pageLoadingEndHookAlreadyCalled = false
                }).finally(done))
              },
            }, {
              default: () => {
                const routeProviderProps = {
                  key: key || undefined,
                  vnode: slots.default ? normalizeSlot(slots.default, routeProps) : routeProps.Component,
                  route: routeProps.route,
                  renderKey: key || undefined,
                  trackRootNodes: hasTransition,
                  vnodeRef: pageRef,
                }

                if (!keepaliveConfig) {
                  return h(RouteProvider, routeProviderProps)
                }

                const routerComponentType = routeProps.Component.type as any
                let PageRouteProvider = routerProviderLookup.get(routerComponentType)

                if (!PageRouteProvider) {
                  PageRouteProvider = defineRouteProvider(routerComponentType.name || routerComponentType.__name)
                  routerProviderLookup.set(routerComponentType, PageRouteProvider)
                }

                return h(PageRouteProvider, routeProviderProps)
              },
            }),
            )).default()

          return vnode
        },
      })
    }
  },
}) as unknown as {