Registering routes dynamically doesn't work in V24 as V22

We register our routes dinamically using the RouteConfiguration like this:
RouteConfiguration.forSessionScope()
.setRoute(
“home”, //path
HomeView.class, //navigation target
MainLayout.class //one or more parents
);

The MainLayout.class view extends AppLayout.class.
When we use Vaadin 22 everything works fine, but we have upgraded v24 and now all components that are not used in MainLayout.class are not displayed.
For example in HomeView.class we have a combo-box component but in MainLayout.class there is no combo-box. Then the combo-box is not displayed.
We have noticed that adding @Uses annotations to MainLayout.class with all components the application displays all components properly.

Is this behaviour normal? Is there a better solution?

Thanks in advance.

You should create an issue in the flow repo, that sounds like something to be investigated.

I guess it’s because of this: Production Build | Deploying to Production | Vaadin Docs

optimizeBundle=false could also be used as workaround I guess

Your route is not annotated with the annotation so it’s probably a specific case. You can use LoadDependenciesOnStartup but you can create a ticket to check if it’s a bug ( or something that should be documented)

We have changed our application to use your recommendations. With the option optimizeBundle=false the components are displayed properly without using @Uses but with @LoadDendenciesOnStartup the components are not displayed.
Is a good solution using the option optimizeBundle=false? Should I open a ticket? I am not sure if this is the expected behaviour or is a bug. In any case, I think this should be explained in Vaadin documention, at least in “Registering Routes Dynamically” and the “Upgrading Guide”

Creating a ticket sounds still like a good idea

I think this is result of the new lazy loading frontend per routing feature in Vaadin 24.1. I would recommend to open ticket at GitHub - vaadin/flow: Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+. so that it will be investigated.

Thanks for your help. I have opened a ticket at github.com/vaadin/flowhttps://github.com/vaadin/flow/issues/17219