Ng-packagr: "Function calls are not supported in decorators but 'RoutingService' was called" - while ng build --prod

Created on 22 Oct 2019  路  4Comments  路  Source: ng-packagr/ng-packagr

When I am trying to build using 'ng build' it works properly. When I do 'ng build --prod', I end up with below error :

ERROR in Error during template compile of 'MainRoutingModule'
Function calls are not supported in decorators but 'RoutingService' was called.

RoutingService is a service used to get path based on Id and getById is a static method.

main-routing.module.ts
_import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { MainComponent } from './main.component';
import { AuthService } from './authorization/auth.service';
import { RoutingService } from '../shared/routing/routing.service';
import { DashboardComponent } from '../dashboard/dashboard.component';

const routes: Routes = [
{
path: RoutingService.getById('main', 'path'),
component: MainComponent,
children: [
{
path: '',
redirectTo: RoutingService.getById('home', 'path'),
pathMatch: 'full',
data: {
breadcrumbItem: {
ignore: true
}
}
},
{
path: RoutingService.getById('home', 'path'),
component: DashboardComponent,
data: {
breadcrumbItem: {
label: 'home'
}
}
},
{
path: RoutingService.getById('dashboard', 'path'),
redirectTo: RoutingService.getById('home', 'path'),
pathMatch: 'full',
data: {
breadcrumbItem: {
ignore: true
}
}
},
{
path: RoutingService.getById('projects', 'path'),
canActivate: [AuthService],
loadChildren: '../project/project.module#ProjectModule'
},
{
path: RoutingService.getById('campaigns', 'path'),
canActivate: [AuthService],
loadChildren: '../campaign/campaign.module#CampaignModule'
},
{
path: RoutingService.getById('vehicles', 'path'),
canActivate: [AuthService],
loadChildren: '../vehicle/vehicle.module#VehicleModule'
}
]
}
];

@NgModule({
imports: [RouterModule.forRoot(routes, {
// => should load page even if URL has not changed (solves problem that earlier filled input fields stay filled on reload)
onSameUrlNavigation: 'reload'
})],
exports: [RouterModule]
})
export class MainRoutingModule { }_

All 4 comments

Duplicate of #1428

@alan-agius4 This is #1428....

Since all of the issues around this, including this issue itself, are being marked as a duplicate of this dead-end issue, I am going to leave traces here.

The fix -> https://github.com/angular/angular/issues/23609#issuecomment-386876693

The explanation -> https://github.com/ng-packagr/ng-packagr/pull/860

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings