angularjs - @angular/cli build issue with default class -
i playing around @angular/cli tool projects , building , having issue 1 of classes.
i trying add component lazyloaded on access of route:
app route:
const routes: routes = [ { path: '', redirectto: '/dashboard', pathmatch: 'full' }, { path: 'dashboard', loadchildren: 'app/dashboard/dashboard.module' } ];
and module loads components , routes (currently simple component says "dashboard"):
import { ngmodule, modulewithproviders } '@angular/core'; import { routes, routermodule } '@angular/router'; import { dashboardcomponent, dashboardroutingmodule } './index'; @ngmodule({ imports: [dashboardroutingmodule], declarations: [dashboardcomponent] }) export default class dashboardmodule { }
when run ng serve
web page starts expected , can develop / see working on.
when run ng build
project builds ok without issues.
when run ng build --prod --aot
returns errors , warnings:
warning in ./src/$$_gendir/app/dashboard/dashboard.module.ngfactory.ts 31:38-61 "export 'dashboardmodule' (imported 'import1') not found in '../../../app/dashboard/dashboard.module' warning in ./src/$$_gendir/app/dashboard/dashboard.module.ngfactory.ts 46:23-46 "export 'dashboardmodule' (imported 'import1') not found in '../../../app/dashboard/dashboard.module' warning in ./src/$$_gendir/app/dashboard/dashboard.module.ngfactory.ts 58:91-114 "export 'dashboardmodule' (imported 'import1') not found in '../../../app/dashboard/dashboard.module' error in c:/wamp/www/api/data-portal/src/$$_gendir/app/dashboard/dashboard.module.ngfactory.ts (1,1): namespace '"c:/wamp/www/api/data-portal/src/app/dashboard/ dashboard.module"' has no exported member 'dashboardmodule'.c:/wamp/www/api/data-portal/src/$$_gendir/app/dashboard/dashboard.module.ngfactory.ts (1,1): namespace '"c:/wamp/www/api/data-portal/src/app/dashboard/dashboard.module"' has no exported member 'dashboardmodule'. c:/wamp/www/api/data-portal/src/$$_gendir/app/dashboard/dashboard.module.ngfactory.ts (1,1): namespace '"c:/wamp/www/api/data-portal/src/app/dashboard/dashboard.module"' has no exported member 'dashboardmodule'.
if remove keyword default
export of dashboard module, builds without issues app doesn't work can't find default
, if add in default again breaks production build.
any ideas/thoughts doing wrong? confused ng serve
works , ng build
works default
keyword, ng build --prod --aot
not
i managed fix changing way doing routing.
instead of:
{ path: 'dashboard', loadchildren: 'app/dashboard/dashboard.module' }
i used:
{ path: 'dashboard', loadchildren: 'app/dashboard/dashboard.module#dashboardmodule' }
removing need default in dashboard module - works in case has same issue me.
Comments
Post a Comment