Universal: Angular 9 Prerendering - Bug in generating static routes

Created on 30 Jan 2020  路  6Comments  路  Source: angular/universal

馃悶 Bug report

What modules are related to this issue?

  • [ ] aspnetcore-engine
  • [x] builders
  • [ ] common
  • [ ] express-engine
  • [ ] hapi-engine
  • [ ] module-map-ngfactory-loader

Is this a regression?


Don't know.

Description


Fails to detect routes from lazy-loaded modules and doesn't generate static routes when routes in routeFile is in specific order.

馃敩 Minimal Reproduction

My main routes are like this:


[
{ path: 'xyz1', loadChildren: import(module1-file).then(m => m.module1) },
{ path: 'xyz2', loadChildren: import(module2-file).then(m => m.module2) },
{ matcher: ... , loadChildren: import(module3-file).then(m => m.module3) },
{ matcher: ... , loadChildren: import(module4-file).then(m => m.module4) },
{ path: '', loadChildren: import(module5-file).then(m => m.module5) }
]

All paths lazily load modules first (with proper import syntax). There are also static routes inside all of the modules like { path: 'xyz', component: ...}. Catch all path ** is inside module5.

First Bug
ng run project-name:prerender fails to detect even one route. I don't expect it to detect from matcher, but it should be able to detect static paths from other modules.

Second Bug
When I provide it routeFile with following routes:


/module5-path1
/module1-path1
/module2-path1
/module5-path2
/module5-path3
...

Only first 3 routes are generated. No error is thrown.
When I change the sequence of routes as follows:


/module5-path1
/module5-path2
/module5-path3
/module1-path1
/module2-path1
...

All routes are generated successfully.
As order shouldn't matter, this is definitely a bug.

馃敟 Exception or Error




Unable to extract routes from application.
An unhandled exception occurred: No routes found.

No error message for the second bug.

馃實 Your Environment




Angular CLI: 9.0.0-rc.7
Node: 12.6.0
OS: win32 x64

Angular: 9.0.0-rc.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.900.0-rc.7
@angular-devkit/build-angular      0.900.0-rc.7
@angular-devkit/build-ng-packagr   0.803.14
@angular-devkit/build-optimizer    0.900.0-rc.7
@angular-devkit/build-webpack      0.900.0-rc.7
@angular-devkit/core               9.0.0-rc.7
@angular-devkit/schematics         9.0.0-rc.7
@angular/cdk                       9.0.0-rc.6
@angular/fire                      5.2.3
@angular/flex-layout               8.0.0-beta.27
@angular/material                  9.0.0-rc.6
@angular/platform-server           9.0.0-rc.8
@angular/service-worker            8.2.12
@ngtools/webpack                   9.0.0-rc.7
@nguniversal/builders              9.0.0-rc.0
@nguniversal/common                9.0.0-rc.0
@nguniversal/express-engine        9.0.0-rc.0
@schematics/angular                9.0.0-rc.7
@schematics/update                 0.900.0-rc.7
rxjs                               6.5.4
typescript                         3.6.4
webpack                            4.41.2
builders bufix

All 6 comments

Hi, would you be able to provide a minimal reproduction? I will go a long way for us to fix this bug faster.

@alan-agius4 Here, you go: https://github.com/SachinShekhar/angular-ssr-prerendering-bug
Check commit messages for more details. For the first bug, matcher is screwing things up. I am unable to reproduce the second bug. I am working on it.

Unable to extract routes from application. is coming from utils.ts which means guess-parser's parseAngularRoutes is throwing.

So not specifying routes or routesFile will result in no routes being found - hence the error Could not find any routes to prerender.

@SachinShekhar I am also unable to reproduce the second bug.

//cc @mgechev

We can close this issue and move the discussion to guess-js/guess.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings