Repository navigation
fix(@angular/ssr): preserve preload metadata for nested empty-path routes - #34325
alan-agius4 wants to merge 1 commit into
Conversation
…utes
Previously, `handleRoute` yielded a parent route's metadata before appending `loadChildren` preloads or traversing child routes, while `traverseRoutesConfig` appended a trailing slash only to empty-path routes. Under a non-empty parent, the parent ('/pricing') and its empty-path child ('/pricing/') received distinct keys during `getRoutesFromAngularRouterConfig` deduplication (`seenRoutes`) and were only merged later by `RouteTree.insert`. However, when an empty-path route was nested under another empty-path route (such as at the root '/' or under '/es' -> '' -> ''), both the parent and child received the same key, causing `seenRoutes` to keep the outer route's metadata and drop the descendant's accumulated `preload` and redirect metadata.
Update `handleRoute` to append `loadChildren` preloads upfront and allow the first matching empty-path child route to override its parent's metadata for the same path, and remove the redundant `addTrailingSlash` keying in `traverseRoutesConfig`.
Closes angular#34320
|
/gemini review |
30fe57f to
ae5c00d
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the Angular SSR routing logic to preserve preload metadata and redirects for nested empty-path routes. It refactors handleRoute to track parent routes using a Map and allows empty-path child routes to override parent metadata, ensuring accumulated preloads are preserved. Additionally, it removes trailing slash additions for empty paths, adds a comprehensive unit test to verify preload preservation, and updates the testing utilities to support entryPointToBrowserMapping in the testing manifest. There are no review comments, so I have no feedback to provide.
There was a problem hiding this comment.
Code Review
This pull request refactors route traversal in the Angular SSR package to correctly preserve preload metadata and redirects for nested empty-path routes. It introduces a mechanism where empty-path child routes can override parent route metadata, ensuring accumulated preloads are preserved. Additionally, it updates testing utilities to support entryPointToBrowserMapping and adds a test case verifying the preservation of preload metadata. There are no review comments, so I have no feedback to provide.
Previously,
handleRouteyielded a parent route's metadata before appendingloadChildrenpreloads or traversing child routes, whiletraverseRoutesConfigappended a trailing slash only to empty-path routes. Under a non-empty parent, the parent ('/pricing') and its empty-path child ('/pricing/') received distinct keys duringgetRoutesFromAngularRouterConfigdeduplication (seenRoutes) and were only merged later byRouteTree.insert. However, when an empty-path route was nested under another empty-path route (such as at the root '/' or under '/es' -> '' -> ''), both the parent and child received the same key, causingseenRoutesto keep the outer route's metadata and drop the descendant's accumulatedpreloadand redirect metadata.Update
handleRouteto appendloadChildrenpreloads upfront and allow the first matching empty-path child route to override its parent's metadata for the same path, and remove the redundantaddTrailingSlashkeying intraverseRoutesConfig.Closes #34320