Can't find routes that are spread into the Route config
See original GitHub issueI have a fresh Angular application, with a routes.ts
file and the following content:
export const routes: Routes = [
{
path: '',
component: SiteFrameComponent,
children: [
{
path: 'a',
loadChildren: () => ...
},
{
path: 'b',
loadChildren: () => ...
},
{
path: '404',
component: NotFoundComponent,
},
],
},
{ path: '**', redirectTo: '/404' },
];
This is then imported in the AppModule into RouterModule.forRoot(routes)
This is pretty straightforward and common, and it works perfectly.
However, as soon as I want to move out some routes to a separate variable, and then spread it back into the config, scully can’t follow:
export const mainPages: Routes = [
{
path: 'a',
loadChildren: () => ...,
},
{
path: 'b',
loadChildren: () => ...,
},
];
export const routes: Routes = [
{
path: '',
component: SiteFrameComponent,
children: [
...mainPages,
{
path: '404',
component: NotFoundComponent,
},
],
},
{ path: '**', redirectTo: '/404' },
];
I separated some routes because I imported it elsewhere to render out links to these routes with an ngFor. So I would get new links by just adding a new route.
I get the following error from guess:
Finding all routes in application.
traversing app for routes
⠸ Loading guess-parser TypeError: Cannot read property 'values' of undefined
at getObjectProp (<project-folder>/node_modules/guess-parser/dist/guess-parser/index.js:444:32)
at Object.exports.readLoadChildren (<project-folder>/node_modules/guess-parser/dist/guess-parser/index.js:471:16)
at Object.exports.getLazyEntryPoints (<project-folder>/node_modules/guess-parser/dist/guess-parser/index.js:400:26)
at collectEntryPoints (<project-folder>/node_modules/guess-parser/dist/guess-parser/index.js:921:30)
at Array.forEach (<anonymous>)
at collectEntryPoints (<project-folder>/node_modules/guess-parser/dist/guess-parser/index.js:925:31)
at visitTopLevelRoutes (<project-folder>/node_modules/guess-parser/dist/guess-parser/index.js:909:13)
at visitNodes (<project-folder>/node_modules/typescript/lib/typescript.js:27858:30)
at Object.forEachChild (<project-folder>/node_modules/typescript/lib/typescript.js:28032:24)
at NodeObject.forEachChild (<project-folder>/node_modules/typescript/lib/typescript.js:146142:23)
Versions:
"@angular/core": "11.2.12",
"@scullyio/ng-lib": "^1.1.1",
"@scullyio/scully": "^1.1.1",
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
All Routes in One File, not spread out across Modules. Is it ...
The mapping of a URL to a particular action is done using routes that are defined in the module's module.config.php file. Open your...
Read more >Route configuration | OpenShift Container Platform 4.11
Path-based routes; Route-specific annotations; Configuring the route admission policy; Creating a route through an Ingress object; Creating a route using ...
Read more >The Hitchhiker's Guide to React Router v4: the hidden value of ...
Welcome to the Hitchhiker's Guide to React Router v4, Part IV! ... This routes are coming from the route config array — got...
Read more >Re-routing & Rearranging Existing Routes on a PCB in Altium ...
This page looks at modifying existing routing, either by rerouting or re-arranging. The former allows you to interactively place a fresh ...
Read more >React Router v6 Preview
You don't need to use an exact prop on <Route path="/"> anymore. This is because all <Route> paths match exactly by default. If...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mgechev The question of @AlexAegis was: Why does this work:
while this doesn’'t:
Both of them seem to be statically analyzable?
given the answer from @mgechev