Skip to content

Conversation

alan-agius4
Copy link
Collaborator

This fix addresses a bug where, in the absence of defined Angular routes, the RenderMode was not correctly applied based on the wildcard setting.

…lar routes are defined

This fix addresses a bug where, in the absence of defined Angular routes, the RenderMode was not correctly applied based on the wildcard setting.
@alan-agius4 alan-agius4 added the target: rc This PR is targeted for the next release-candidate label Oct 25, 2024
@alan-agius4 alan-agius4 requested a review from dgp1130 October 25, 2024 17:36
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 25, 2024
@@ -478,7 +478,12 @@ export async function getRoutesFromAngularRouterConfig(
}
}
} else {
routesResults.push({ route: '', renderMode: RenderMode.Prerender });
const renderMode = serverConfigRouteTree?.match('')?.renderMode ?? RenderMode.Prerender;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dgp1130, I'd prefer if in this case it was a hard error both the old and new API. But this would require us to generate an additional component and add route when doing ng-new.

Is this something that we'll be willing to do?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the case where export const SERVER_ROUTES = [];? You think that should be a hard error?

I can see where you're coming from. This has bugged me in the past because we do the same thing for client-side routes and it means the <router-outlet> is a somewhat confusing no-op in ng new and it's not clear how to add a route, which leads to devs using component instead of loadComponent and deoptimizing their apps.

Could we generate { path: '/**', renderMode: RenderMode.Prerender } by default in SSR? Would that avoid the need for a defined route? Or do we need to add a route in the app router to get this to work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the case where export const SERVER_ROUTES = [];? You think that should be a hard error?

I was referring to Angular Router routes.

We do generate { path: '/**', renderMode: RenderMode.Prerender } already but we do not generate any route in the Angular router.

@@ -478,7 +478,12 @@ export async function getRoutesFromAngularRouterConfig(
}
}
} else {
routesResults.push({ route: '', renderMode: RenderMode.Prerender });
const renderMode = serverConfigRouteTree?.match('')?.renderMode ?? RenderMode.Prerender;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the case where export const SERVER_ROUTES = [];? You think that should be a hard error?

I can see where you're coming from. This has bugged me in the past because we do the same thing for client-side routes and it means the <router-outlet> is a somewhat confusing no-op in ng new and it's not clear how to add a route, which leads to devs using component instead of loadComponent and deoptimizing their apps.

Could we generate { path: '/**', renderMode: RenderMode.Prerender } by default in SSR? Would that avoid the need for a defined route? Or do we need to add a route in the app router to get this to work?

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 28, 2024
@alan-agius4 alan-agius4 merged commit 63722c3 into angular:main Oct 28, 2024
33 of 34 checks passed
@alan-agius4 alan-agius4 deleted the render-mode-default branch October 28, 2024 15:43
@alan-agius4
Copy link
Collaborator Author

The changes were merged into the following branches: main, 19.0.x

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: @angular/ssr target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants