I have some Aurelia 1 Web sites that I would like to start transitioning to Aurelia 2. Those sites use dotnet for the back end and Webpack for bundling. I decided to try using Vite for bundling this time because I have spent so much time dealing with Webpack issues during upgrades. So far I can get a shell application working with dotnet 9 and vite 6. It seems functional in a debug and a deployed state with a few minor rough edges.
The next step was to bring in more of the pieces used for style and navigation. The style part went ok, but navigation isn’t working that well. I don’t know if it was the correct decision, but I went with the router-lite. It seems to work as shown in the documentation to create a simple menu, but when I do things like add a routable link to a page, I am getting errors. I also ran into some limitations. The first limitation is that it won’t let me create a route that doesn’t have a component, which I used with Aurelia 1 to setup headings for drop-down menus.
So first question is can I configure a route similar to this from Aurelia 1?
{
route: "config",
name: "config",
settings: {
dropdown: "config",
auth: ["Admin", "Setup Admin", "Back Office"],
icon: "fas fa-gears"
},
moduleId: "#",
nav: true,
title: "Configuration"
}, {
auth: "true",
moduleId: PLATFORM.moduleName("../material/MaterialList"),
name: "materiallist",
nav: true,
route: "material-list",
settings: {
dropdown: "config",
icon: "fas fa-coins",
auth: ["Admin", "Setup Admin", "Back Office"]
},
title: "material-list",
}
With Aurelia 1, I would use that to construct a drop down menu with a top-level of Configuration. With router-lite, it says a component is required.
The next question is with links embedded in a page. In the nav menu, links seem to work fine, but in a page they don’t seem to work. Am I doing something wrong here?
The navigation writes out this:
<li class="nav-item">
<a href="register" class="active">
<i class="fas fa-address-card">Register</i>
</a>
</li>
In a page it writes out this:
<div class="mb-1">
<a href="register">Register as a new user?</a>
</div>
Clicking on the nav link works fine with no error, but clicking on the link in a page throws an error unless I say open in a new tab, which also seems to work fine. It seems like it is looking for an “agent” and not finding it.
This is the error that is thrown:
route-context.ts:370 Uncaught (in promise) Error: AUR3174: Failed to resolve VR(viewport:'default',component:'not-found') at:
RC(path:'app',viewports:[VPA(state:currIsActive|nextIsScheduled,plan:'none',n:RN(ctx:'app/login',c:'Login',path:'login'),c:RN(ctx:'app/login',c:'Login',path:'login'),viewport:VP(ctx:'app',name:'default',default:'home',fallback:'not-found'))])
RC(path:'app/login',viewports:[])
at _RouteContext._resolveViewportAgent (route-context.ts:370:33)
at route-tree.ts:542:27
at onResolve (functions.ts:433:10)
at route-tree.ts:538:14
at onResolve (functions.ts:433:10)
at createConfiguredNode (route-tree.ts:530:10)
at createAndAppendNodes (route-tree.ts:458:88)
at router.ts:792:46
at Array.map (<anonymous>)
at updateNode (router.ts:792:36)
From here:
public _resolveViewportAgent(req: ViewportRequest): ViewportAgent {
if (__DEV__) trace(this._logger, Events.rcResolveVpa, req);
const agent = this._childViewportAgents.find(x => { return x._handles(req); });
if (agent === void 0) throw new Error(getMessage(Events.rcNoAvailableVpa, req, this._printTree()));
return agent;
}