Router: Optional Viewports not working as expected

I am trying to implement routing with optional viewports, but am running into trouble: Viewports for which no instruction is present in the initial route are never rendered (by subsequent routes).

What I really want is optional viewports “as advertised”. I have prepared a gist here.

I suspect I am missing the blindingly obvious …

Thanks for your support,

If you change your first route to this…

{ route: ['','a'],  viewPorts: { viewporta: {moduleId: './a'},  viewportb: {moduleId: null }}},

… it works as expected. I assume something in the router setup means that the default route needs to have all the viewports defined?

Defining all viewports in the default route is exactly what I am trying to avoid: I am dynamically composing elements which have viewports, so at the time of configuring the router I do not know which viewports I will have.

I was hoping that I could create a dynamic route that uses a dynamically generated named viewport. If I need to know all viewports in advance, that approach will not work …

I found dynamic routes/viewports needed to be defined before starting up the application. I think all routes need the same viewports to be assigned (otherwise TypeScript errors occur invoking unassigned) though some could be defined to empty or null values. They can, of course, be re-assigned dynamically at any time to values that already exist (but not new values that are created to brand new data at run time)

When setting up config.useViewPortDefaults for a viewport, it looks like it is still required that at least the 1st route in the application needs to set in the route the viewport by name and null, then the defaulting logic kicks in.

Is this by design?

The behavior I was expecting was that I simply exclude the mention of the viewport from any route that is configured in defaults, rely on the default config, and if a route puts in null for the viewport that is essentially me saying that the null route is deciding not to render the intended viewport.

(if not specified in route => default, if null => do nothing on the viewport)