{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/10789","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/10789/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/10789/comments","events_url":"https://api.github.com/repos/angular/angular/issues/10789/events","html_url":"https://github.com/angular/angular/issues/10789","id":171042026,"number":10789,"title":"Router: AoT compilation fails when using a function with loadChildren","user":{"login":"brandonroberts","id":42211,"avatar_url":"https://avatars.githubusercontent.com/u/42211?v=3","gravatar_id":"","url":"https://api.github.com/users/brandonroberts","html_url":"https://github.com/brandonroberts","followers_url":"https://api.github.com/users/brandonroberts/followers","following_url":"https://api.github.com/users/brandonroberts/following{/other_user}","gists_url":"https://api.github.com/users/brandonroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/brandonroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandonroberts/subscriptions","organizations_url":"https://api.github.com/users/brandonroberts/orgs","repos_url":"https://api.github.com/users/brandonroberts/repos","events_url":"https://api.github.com/users/brandonroberts/events{/privacy}","received_events_url":"https://api.github.com/users/brandonroberts/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-14T04:40:20Z","updated_at":"2016-08-18T00:28:21Z","closed_at":null,"body":"**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[x] bug report => search github for a similar issue or PR before submitting\r\n[ ] feature request\r\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n```\r\n\r\n**Current behavior**\r\n\r\nIn order to enable lazy loading with Webpack 1, a custom `NgModuleFactoryLoader` must be implemented to lazy load routes with `loadChildren`. I've implemented an example loader here.\r\n\r\nhttps://github.com/brandonroberts/router-cli-aot/blob/master/src/app/shared/async-ng-module-loader.ts\r\n\r\nThe custom `load` function is being used here: https://github.com/brandonroberts/router-cli-aot/blob/master/src/app/app.routing.ts#L12-L25\r\n\r\nWhen running `ngc` over the provided repo, an error occurs:\r\n\r\n`\r\nError: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 23:24 in the original .ts file), resolving symbol crisisCenterRoutes in /router-cli-aot/src/app/app.routing.ts, resolving symbol appRoutes in /router-cli-aot/src/app/app.routing.ts, resolving symbol routing in /router-cli-aot/src/app/app.routing.ts, resolving symbol AppModule in /router-cli-aot/src/app/app.module.ts, resolving symbol AppModule in /router-cli-aot/src/app/app.module.ts\r\n`\r\n\r\nI can comment out the `loadChildren` line and `ngc` completes successfully. If I uncomment the line after running `ngc` and bundle with webpack, the app works as desired with lazy loading.\r\n\r\nWhile https://github.com/angular/angular/pull/10705 adds support for using a callback function with `loadChildren` such as `loadChildren: () => System.import('lazy.module#LazyModule')`, this will cause AoT compilation to fail also with the same error.\r\n\r\n**Expected/desired behavior**\r\n\r\nProviding a callback function to `loadChildren` does not cause AoT compilation to fail when used \r\nwith vanilla webpack or some other bundling tool.\r\n\r\n**Reproduction of the problem**\r\nIf the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\r\n\r\n\r\n\r\n**What is the expected behavior?**\r\n\r\n\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n\r\nWebpack 1/2 use a callback function to provide lazy loading through returning a promise.\r\n\r\n**Please tell us about your environment:**\r\n\r\n* **Angular version:** 2.0.0-rc.5\r\n \r\n* **Browser:** [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] \r\n \r\n* **Language:** [all | TypeScript X.X | ES6/7 | ES5] \r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/240590064","html_url":"https://github.com/angular/angular/issues/10789#issuecomment-240590064","issue_url":"https://api.github.com/repos/angular/angular/issues/10789","id":240590064,"user":{"login":"Richard87","id":5749715,"avatar_url":"https://avatars.githubusercontent.com/u/5749715?v=3","gravatar_id":"","url":"https://api.github.com/users/Richard87","html_url":"https://github.com/Richard87","followers_url":"https://api.github.com/users/Richard87/followers","following_url":"https://api.github.com/users/Richard87/following{/other_user}","gists_url":"https://api.github.com/users/Richard87/gists{/gist_id}","starred_url":"https://api.github.com/users/Richard87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Richard87/subscriptions","organizations_url":"https://api.github.com/users/Richard87/orgs","repos_url":"https://api.github.com/users/Richard87/repos","events_url":"https://api.github.com/users/Richard87/events{/privacy}","received_events_url":"https://api.github.com/users/Richard87/received_events","type":"User","site_admin":false},"created_at":"2016-08-18T00:28:21Z","updated_at":"2016-08-18T00:28:21Z","body":"Hi guys, I'm not sure if it's related, but it's I get the same error message:\r\n\r\n\tC:\\Users\\richa\\Prosjekt\\phono-frontend>node_modules\\.bin\\ngc -p .\r\n\tError: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 37:24 in the original .ts file), resolving symbol AppModule in C:/Users/richa/Prosjekt/phono-frontend/src/app/app.module.ts\r\n\t\tat simplifyInContext (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\static_reflector.js:463:23)\r\n\t\tat StaticReflector.simplify (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\static_reflector.js:466:22)\r\n\t\tat StaticReflector.annotations (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\static_reflector.js:52:36)\r\n\t\tat _loop_1 (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\codegen.js:50:54)\r\n\t\tat CodeGenerator.readFileMetadata (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\codegen.js:63:13)\r\n\t\tat C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\codegen.js:91:74\r\n\t\tat Array.map (native)\r\n\t\tat CodeGenerator.codegen (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\codegen.js:91:35)\r\n\t\tat codegen (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\compiler-cli\\src\\main.js:7:69)\r\n\t\tat Object.main (C:\\Users\\richa\\Prosjekt\\phono-frontend\\node_modules\\@angular\\tsc-wrapped\\src\\main.js:25:16)\r\n\tCompilation failed\r\n\r\nIt complains about my AuthConfig factory in my AppModule:\r\n\r\n    import { NgModule }       from '@angular/core';\r\n    import { BrowserModule  } from '@angular/platform-browser';\r\n    import { AppComponent }   from './app.component';\r\n    import {appRoutes} from \"./app.routes\";\r\n    import {LoggedInGuard} from \"./Security/logged-in.guard\";\r\n    import {AUTH_PROVIDERS, AuthHttp, AuthConfig, JwtHelper} from \"angular2-jwt/angular2-jwt\";\r\n    import {HttpModule} from \"@angular/http\";\r\n    import { FormsModule} from \"@angular/forms\";\r\n    import {NgbModule} from '@ng-bootstrap/ng-bootstrap';\r\n    import {DashboardModule} from \"./dashboard/dashboard.module\";\r\n    import {LandingpageComponent} from \"./landingpage/landingpage.component\";\r\n    import {Routes, RouterModule} from \"@angular/router\";\r\n    import {AuthService} from \"./Security/auth.service\";\r\n    import {NgFor, NgIf} from \"@angular/common\";\r\n    \r\n    export const routes: Routes = [\r\n        { path: '', component: LandingpageComponent}\r\n    ];\r\n    \r\n    @NgModule({\r\n        declarations: [AppComponent],\r\n        imports:      [\r\n            BrowserModule,\r\n            HttpModule,\r\n            NgbModule,\r\n            FormsModule,\r\n            DashboardModule,\r\n            RouterModule.forRoot(routes)\r\n        ],\r\n        bootstrap:    [AppComponent],\r\n        providers:    [\r\n            LoggedInGuard,\r\n            AUTH_PROVIDERS,\r\n            JwtHelper,\r\n            {\r\n                provide: AuthConfig,\r\n                useFactory: () => {\r\n                    return new AuthConfig({\r\n                        tokenName: \"auth_token\",\r\n                        headerName: 'Authorization',\r\n                        headerPrefix: 'Bearer',\r\n                        globalHeaders: [{'Content-Type':'application/json'}],\r\n                        noJwtError: true,\r\n                        noTokenScheme: true\r\n                    })\r\n                }\r\n            },\r\n            AuthHttp,\r\n            AuthService,\r\n        ],\r\n        directives: [NgFor, NgIf]\r\n    })\r\n    export class AppModule {}"}}
{"actor":{"display_login":"Richard87"}}