I'm try to compile a test SPA with ng build --prod --build-optimizer
I'm experiencing this error:
expressions are not supported in decorators in 'ɵ0' angular loadchild
I found this https://github.com/angular/angular/issues/10789
where is suggested to change form this:
import {MainModule} from './../../main/main.module';
const sidenavRoutes: Routes = [
{
path: '',
component: SidenavComponent,
canActivateChild: [AuthGuard],
children: [
{ path: '', loadChildren: () =>MainModule}
]
},
];
to
import {MainModule} from './../../main/main.module';
export function loadMainModule() {
return require('es6-promise!./../../main/main.module')('MainModule');
}
const sidenavRoutes: Routes = [
{
path: '',
component: SidenavComponent,
canActivateChild: [AuthGuard],
children: [
{ path: '', loadChildren: loadMainModule}
]
},
];
but I get this error:
MyPATH\node_modules\loader-runner\lib\loadLoader.js:35 throw new Error("Module '" + loader.path + "' is not a loader (must have normal or pitch function)"); ^
Error: Module 'MyPATH\node_modules\es6-promise\dist\es6-promise.js' is not a loader (must have normal or pitch function)
do you have any suggestions?