Skip to content

Commit fb921f2

Browse files
committed
refactor: migration to lazy-loaded routes
1 parent ed399e0 commit fb921f2

39 files changed

+399
-320
lines changed

src/app/about/about-routing.module.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import {Routes} from '@angular/router';
22

3-
import {AboutComponent} from './about.component';
4-
5-
export const routes: Routes = [{component: AboutComponent, path: '', pathMatch: 'full', title: $localize`About us`}];
3+
export const routes: Routes = [
4+
{
5+
loadComponent: () => import('./about.component').then((m) => m.AboutComponent),
6+
path: '',
7+
pathMatch: 'full',
8+
title: $localize`About us`,
9+
},
10+
];

src/app/account/account-routing.module.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,38 @@
11
import {Routes} from '@angular/router';
22

33
import {authGuard} from '../auth.guard';
4-
import {AccountAccessComponent} from './access/access.component';
5-
import {AccountComponent} from './account.component';
6-
import {AccountAccountsComponent} from './accounts/accounts.component';
7-
import {AccountContactsComponent} from './contacts/contacts.component';
8-
import {AccountDeleteComponent} from './delete/delete.component';
9-
import {AccountDeletedComponent} from './delete/deleted/deleted.component';
10-
import {AccountEmailComponent} from './email/email.component';
11-
import {AccountInboxPicturesComponent} from './inbox-pictures/inbox-pictures.component';
12-
import {AccountMessagesComponent} from './messages/messages.component';
13-
import {AccountProfileComponent} from './profile/profile.component';
14-
import {AccountSpecsConflictsComponent} from './specs-conflicts/specs-conflicts.component';
154

165
export const routes: Routes = [
176
{
187
children: [
198
{
209
canActivate: [authGuard],
21-
component: AccountAccessComponent,
10+
loadComponent: () => import('./access/access.component').then((m) => m.AccountAccessComponent),
2211
path: 'access',
2312
title: $localize`Access Control`,
2413
},
2514
{
2615
canActivate: [authGuard],
27-
component: AccountAccountsComponent,
16+
loadComponent: () => import('./accounts/accounts.component').then((m) => m.AccountAccountsComponent),
2817
path: 'accounts',
2918
title: $localize`My accounts`,
3019
},
3120
{
3221
canActivate: [authGuard],
33-
component: AccountContactsComponent,
22+
loadComponent: () => import('./contacts/contacts.component').then((m) => m.AccountContactsComponent),
3423
path: 'contacts',
3524
title: $localize`Contacts`,
3625
},
3726
{
3827
children: [
39-
{component: AccountDeletedComponent, path: 'deleted', title: $localize`Account deleted`},
28+
{
29+
loadComponent: () => import('./delete/deleted/deleted.component').then((m) => m.AccountDeletedComponent),
30+
path: 'deleted',
31+
title: $localize`Account deleted`,
32+
},
4033
{
4134
canActivate: [authGuard],
42-
component: AccountDeleteComponent,
35+
loadComponent: () => import('./delete/delete.component').then((m) => m.AccountDeleteComponent),
4336
path: '',
4437
},
4538
],
@@ -48,35 +41,37 @@ export const routes: Routes = [
4841
},
4942
{
5043
canActivate: [authGuard],
51-
component: AccountEmailComponent,
44+
loadComponent: () => import('./email/email.component').then((m) => m.AccountEmailComponent),
5245
path: 'email',
5346
title: $localize`My e-mail`,
5447
},
5548
{
5649
canActivate: [authGuard],
57-
component: AccountInboxPicturesComponent,
50+
loadComponent: () =>
51+
import('./inbox-pictures/inbox-pictures.component').then((m) => m.AccountInboxPicturesComponent),
5852
path: 'inbox-pictures',
5953
title: $localize`Unmoderated`,
6054
},
6155
{
6256
canActivate: [authGuard],
63-
component: AccountMessagesComponent,
57+
loadComponent: () => import('./messages/messages.component').then((m) => m.AccountMessagesComponent),
6458
path: 'messages',
6559
},
6660
{
6761
canActivate: [authGuard],
68-
component: AccountProfileComponent,
62+
loadComponent: () => import('./profile/profile.component').then((m) => m.AccountProfileComponent),
6963
path: 'profile',
7064
title: $localize`Profile`,
7165
},
7266
{
7367
canActivate: [authGuard],
74-
component: AccountSpecsConflictsComponent,
68+
loadComponent: () =>
69+
import('./specs-conflicts/specs-conflicts.component').then((m) => m.AccountSpecsConflictsComponent),
7570
path: 'specs-conflicts',
7671
title: $localize`Conflicts`,
7772
},
7873
],
79-
component: AccountComponent,
74+
loadComponent: () => import('./account.component').then((m) => m.AccountComponent),
8075
path: '',
8176
title: $localize`Account`,
8277
},

src/app/app-routing.module.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import {Routes} from '@angular/router';
22

3-
import {LoginComponent} from './login/login.component';
4-
import {PageNotFoundComponent} from './not-found.component';
5-
63
export const appRoutes: Routes = [
74
{loadChildren: () => import('./about/about-routing.module').then((m) => m.routes), path: 'about'},
85
{
@@ -95,8 +92,8 @@ export const appRoutes: Routes = [
9592
},
9693
{loadChildren: () => import('./voting/voting-routing.module').then((m) => m.routes), path: 'voting'},
9794
{loadChildren: () => import('./index/index-routing.module').then((m) => m.routes), path: ''},
98-
{component: PageNotFoundComponent, path: 'error-404'},
99-
{component: LoginComponent, path: 'login'},
95+
{loadComponent: () => import('./not-found.component').then((m) => m.PageNotFoundComponent), path: 'error-404'},
96+
{loadComponent: () => import('./login/login.component').then((m) => m.LoginComponent), path: 'login'},
10097
{
10198
loadChildren: () => import('./catalogue/catalogue-routing.module').then((m) => m.routes),
10299
// matcher: cataloguePathMatcher,
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import {Routes} from '@angular/router';
22

3-
import {ArticlesArticleComponent} from './article/article.component';
4-
import {ListComponent} from './list/list.component';
5-
63
export const routes: Routes = [
7-
{component: ArticlesArticleComponent, path: ':catname'},
8-
{component: ListComponent, path: '', pathMatch: 'full', title: $localize`Articles`},
4+
{
5+
loadComponent: () => import('./article/article.component').then((m) => m.ArticlesArticleComponent),
6+
path: ':catname',
7+
},
8+
{
9+
loadComponent: () => import('./list/list.component').then((m) => m.ListComponent),
10+
path: '',
11+
pathMatch: 'full',
12+
title: $localize`Articles`,
13+
},
914
];
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import {Routes} from '@angular/router';
22

3-
import {BrandsComponent} from './brands.component';
4-
5-
export const routes: Routes = [{component: BrandsComponent, path: '', pathMatch: 'full', title: $localize`All brands`}];
3+
export const routes: Routes = [
4+
{
5+
loadComponent: () => import('./brands.component').then((m) => m.BrandsComponent),
6+
path: '',
7+
pathMatch: 'full',
8+
title: $localize`All brands`,
9+
},
10+
];

src/app/cars/cars-routing.module.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
import {Routes} from '@angular/router';
22

3-
import {CarsAttrsChangeLogComponent} from './attrs-change-log/attrs-change-log.component';
4-
import {CarsDatelessComponent} from './dateless/dateless.component';
5-
import {CarsEngineSelectComponent} from './specifications-editor/engine/select/select.component';
6-
import {CarsSpecificationsEditorComponent} from './specifications-editor/specifications-editor.component';
7-
import {CarsSpecsAdminComponent} from './specs-admin/specs-admin.component';
8-
93
export const routes: Routes = [
104
{
11-
component: CarsAttrsChangeLogComponent,
5+
loadComponent: () =>
6+
import('./attrs-change-log/attrs-change-log.component').then((m) => m.CarsAttrsChangeLogComponent),
127
path: 'attrs-change-log',
138
title: $localize`History`,
149
},
1510
{
16-
component: CarsDatelessComponent,
11+
loadComponent: () => import('./dateless/dateless.component').then((m) => m.CarsDatelessComponent),
1712
path: 'dateless',
1813
title: $localize`Dateless`,
1914
},
2015
{
21-
component: CarsEngineSelectComponent,
16+
loadComponent: () =>
17+
import('./specifications-editor/engine/select/select.component').then((m) => m.CarsEngineSelectComponent),
2218
path: 'select-engine',
2319
},
2420
{
25-
component: CarsSpecificationsEditorComponent,
21+
loadComponent: () =>
22+
import('./specifications-editor/specifications-editor.component').then(
23+
(m) => m.CarsSpecificationsEditorComponent,
24+
),
2625
path: 'specifications-editor',
2726
},
2827
{
29-
component: CarsSpecsAdminComponent,
28+
loadComponent: () => import('./specs-admin/specs-admin.component').then((m) => m.CarsSpecsAdminComponent),
3029
path: 'specs-admin',
3130
title: $localize`Specifications Admin`,
3231
},

0 commit comments

Comments
 (0)