scullyio / scully

The Static Site Generator for Angular apps
https://scully.io/
MIT License
2.55k stars 256 forks source link

[Bug] scully.routes.json not updated correctly #336

Closed geromegrignon closed 4 years ago

geromegrignon commented 4 years ago

🐞 Bug report

Description

Since the last version on npm, there is a regression on the generation of the scully.routes.json. Once created, the file isn't updated anymore with npm run scully if new routes are added. It's still correctly updated with new blog posts if the blog module was created before launching npm run scully for the first time.

🔬 Minimal Reproduction

The about module isn't included in the scully.routes.json file and there is no log about the generation of a rendered file for about.

Another example :

Logs on npm run scully :

Route "/" rendered into file: "C:\Workspace\Scully\scully-routing\dist\static\index.html"
Route "/home" rendered into file: "C:\Workspace\Scully\scully-routing\dist\static\home\index.html"
Route "/about" rendered into file: "C:\Workspace\Scully\scully-routing\dist\static\about\index.html"

scully-routes.json file :

[{"route":"/home"},{"route":"/about"},{"route":"/"}]

AppRoutingModule :

const routes: Routes = [
  { path: 'home', loadChildren: () => import('./home/home.module').then(m => m.HomeModule) },
  { path: 'about', loadChildren: () => import('./about/about.module').then(m => m.AboutModule) },
  { path: 'blog', loadChildren: () => import('./blog/blog.module').then(m => m.BlogModule) },
  { path: 'dashboard', loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule) }];

The blog and dashboard module added after the first npm run scully iteration aren't added on consecutive npm run scully;

💻Your Environment

Angular Version:


Angular CLI: 9.0.1
Node: 12.3.1
OS: win32 x64

Angular:
...
Ivy Workspace:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.900.1
@angular-devkit/core         9.0.1
@angular-devkit/schematics   9.0.1
@schematics/angular          9.0.1
@schematics/update           0.900.1
rxjs                         6.5.3


Scully Version:


"@angular/animations": "~9.0.0",
    "@angular/common": "~9.0.0",
    "@angular/compiler": "~9.0.0",
    "@angular/core": "~9.0.0",
    "@angular/forms": "~9.0.0",
    "@angular/platform-browser": "~9.0.0",
    "@angular/platform-browser-dynamic": "~9.0.0",
    "@angular/router": "~9.0.0",
    "@scullyio/init": "0.0.23",
    "@scullyio/ng-lib": "latest",
    "@scullyio/scully": "0.0.78",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
SanderElias commented 4 years ago

@geromegrignon this is not a bug, but more of an undocumented feature. From now on, Scully only scans the angular app once and saves the result. When you add routes in the angular app, you need to rescan it, by adding the --scanRoutes or --sr option. This is done because the route discover takes a relatively long time, especially in larger apps. Adding routes is not something that happens often, so it makes sense to make the scan opt-oin

I will update the docs, and the messages in Scully to make this more apparent.

geromegrignon commented 4 years ago

Thanks for the feedback.