Skip to content

fix(@angular/ssr): preserve preload metadata for nested empty-path routes - #34325

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-34320
Open

alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-34320

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

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 #34320

…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
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

/gemini review

@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Oct 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 13, 2026
@alan-agius4
alan-agius4 requested a review from dgp1130 October 13, 2026 07:24
@alan-agius4
alan-agius4 marked this pull request as ready for review October 13, 2026 07:24

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/ssr target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@angular/ssr: page under nested empty-path routes is prerendered without the modulepreload hints of its lazy chunks (regression since 19.1.6)

1 participant