timfish / aurelia-electron-webpack

Aurelia Electron app built with Webpack
29 stars 3 forks source link

Route configuration barfs #8

Open pete-hotchkiss opened 3 years ago

pete-hotchkiss commented 3 years ago

Having some fun and games around getting the app to behave it's self with routing.

If I try to add a basic route into the out-the-box install, webpack compiles with no problems, but Electron doesn't play.

eg

in my-app.html

<import from="./test-component.html"></import>

<div class="message">${message}</div>
<ul>
    <li><a load="test-component">Test Component</a></li>
</ul>

<au-viewport name="main"></au-viewport>

The test-component.html file exists and is in src/renderer.

index.ts has registered the RouterConfiguration

import { Aurelia, RouterConfiguration } from 'aurelia';
import { MyApp } from './my-app';

Aurelia
.register(RouterConfiguration)
.app(MyApp)
.start();

Console output below

route-tree.js:389 
Uncaught (in promise) Error: 'main_window' did not match any configured route or registered component name at 'my-app' - did you forget to add the component 'main_window' to the dependencies of 'my-app' or to register it as a global dependency?
    at createNode (route-tree.js:389)
    at createAndAppendNodes (route-tree.js:339)
    at route-tree.js:283
    at Array.map (<anonymous>)
    at route-tree.js:282
    at onResolve (functions.js:437)
    at updateNode (route-tree.js:278)
    at route-tree.js:263
    at onResolve (functions.js:437)
    at updateRouteTree (route-tree.js:262)
timfish commented 3 years ago

That's a weird one. I have to admit to not playing around with the new router yet, let alone trying it in Electron.

Does the same code work outside of Electron? I'll take a look when I get a chance.

pete-hotchkiss commented 3 years ago

it does - placing the same code in the aurlia cli runs with no issues

pete-hotchkiss commented 3 years ago

interestingly - if I run the make script - to build a full instance rather than a dev build - a similar error is thrown to the console

Uncaught Error: Expected component name at index 192 of '/Users/path/to/folder/aurelia-electron-webpack/out/Aurelia%20Electron-darwin-x64/Aurelia%20Electron.app/Contents/Resources/app/.webpack/renderer/main_window', but got: '.webpack/renderer/main_window' (rest='.webpack/renderer/main_window')
    at rf.expect (route-expression.js:44)
    at Function.parse (route-expression.js:422)
    at Function.parse (route-expression.js:352)
    at Function.parse (route-expression.js:328)
    at Function.parse (route-expression.js:261)
    at Function.parse (route-expression.js:263)
    at Function.parse (route-expression.js:263)
    at Function.parse (route-expression.js:263)
    at Function.parse (route-expression.js:263)
    at Function.parse (route-expression.js:263)

however the app does navigate to the expected route