Title: Cannot read property 'loadChildren' of undefined · Issue #4686 · angular/angular-cli · GitHub
Open Graph Title: Cannot read property 'loadChildren' of undefined · Issue #4686 · angular/angular-cli
X Title: Cannot read property 'loadChildren' of undefined · Issue #4686 · angular/angular-cli
Description: Please provide us with the following information: OS? Windows 10 Versions. @angular/cli: 1.0.0-beta.30 node: 6.9.1 os: win32 x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7 @angular/forms: 2.4.7 @angular/http: 2....
Open Graph Description: Please provide us with the following information: OS? Windows 10 Versions. @angular/cli: 1.0.0-beta.30 node: 6.9.1 os: win32 x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7...
X Description: Please provide us with the following information: OS? Windows 10 Versions. @angular/cli: 1.0.0-beta.30 node: 6.9.1 os: win32 x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7...
Opengraph URL: https://github.com/angular/angular-cli/issues/4686
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot read property 'loadChildren' of undefined","articleBody":"> Please provide us with the following information:\r\n> ---------------------------------------------------------------\r\n\r\n### OS?\r\nWindows 10\r\n\r\n### Versions.\r\n@angular/cli: 1.0.0-beta.30\r\nnode: 6.9.1\r\nos: win32 x64\r\n@angular/common: 2.4.7\r\n@angular/compiler: 2.4.7\r\n@angular/core: 2.4.7\r\n@angular/forms: 2.4.7\r\n@angular/http: 2.4.7\r\n@angular/platform-browser: 2.4.7\r\n@angular/platform-browser-dynamic: 2.4.7\r\n@angular/router: 3.4.7\r\n@angular/cli: 1.0.0-beta.30\r\n@angular/compiler-cli: 2.4.7\r\n\r\n### Repro steps.\r\n**feature.module.ts**\r\nUsing @nglibs/i18n-router to provide route translations for feature modules (lazy loaded).\r\n\r\n```\r\nimport { I18NRouterModule } from '@nglibs/i18n-router';\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n // RouterModule.forChild(routes)\r\n I18NRouterModule.forChild(routes, 'about')\r\n ],\r\n declarations: [\r\n AboutComponent,\r\n AboutUsComponent,\r\n AboutBananaComponent,\r\n AboutApplePearComponent\r\n ]\r\n})\r\n```\r\n\r\nThe whole solution is located on github: angular-cli branch of [@nglibs/example-app](https://github.com/nglibs/example-app/tree/angular-cli).\r\n\r\n### The log given by the failure.\r\nCan't talk about a stack trace, but hope it will be helpful:\r\n\r\n```\r\n$ ng serve\r\n** NG Live Development Server is running on http://localhost:4200. **\r\nHash: ddefd75abb9ca8b82bd4 Time: 18958ms\r\nchunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial] [rendered]\r\nchunk {1} main.bundle.js, main.bundle.map (main) 8.61 kB {3} [initial] [rendered]\r\nchunk {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial] [rendered]\r\nchunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 3.49 MB [initial] [rendered]\r\nchunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]\r\n\r\nERROR in Cannot read property 'loadChildren' of undefined\r\nwebpack: Failed to compile.\r\n```\r\n\r\n### Mention any other details that might be useful.\r\n\r\n**`@nglibs/i18n-router`** does not work with **`@angular-cli`** (*yet*), and giving the following error during [AoT compilation]:\r\n\r\n> `ERROR in Cannot read property 'loadChildren' of undefined`\r\n\r\nI suppose **`@angular-cli`** uses **`@ngtools/webpack`** for [AoT compilation], expecting `RouterModule.forChild(...)` to resolve lazy-loaded modules (*with `loadChildren`*), which is replaced by `I18NRouterModule.forChild(...)` - providing routes for **feature modules** instead.\r\n\r\nHere's the piece of code from [i18n-router module line 72](https://github.com/nglibs/i18n-router/blob/master/index.ts#L72), which provides child routes.\r\n```\r\n {\r\n provide: ROUTES,\r\n useFactory: (provideChildRoutes),\r\n deps: [I18NRouterService, RAW_ROUTES, MODULE_KEY],\r\n multi: true\r\n },\r\n {\r\n provide: ANALYZE_FOR_ENTRY_COMPONENTS,\r\n useValue: routes,\r\n multi: true\r\n }\r\n```\r\n\r\nIt provides `ROUTES` and `ANALYZE_FOR_ENTRY_COMPONENTS` to Angular the same way that the router module does (see below):\r\n- https://github.com/angular/angular/blob/master/modules/%40angular/router/src/router_module.ts#L170\r\n- https://github.com/angular/angular/blob/master/modules/%40angular/router/src/router_module.ts#L204\r\n\r\nHowever, angular-cli seems insisting ignoring the provided child routes and firing errors.\r\n\r\nTo resolve this issue temporarily, I switched using [ng-router-loader]. Hence **`@angular-cli`** doesn't allow **modifying** the **webpack configuration**, I need to **manually** configure **build tools** (*dev/prod sever, task runners, webpack, etc*).\r\n\r\nI think `loadChildren` should be able to recognize routes provided with `ROUTES` and `ANALYZE_FOR_ENTRY_COMPONENTS`.\r\n","author":{"url":"https://github.com/fulls1z3","@type":"Person","name":"fulls1z3"},"datePublished":"2017-02-14T11:21:38Z","url":"https://github.com/angular/angular-cli/issues/4686"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a910935b-debd-1205-11b9-e56f9d53d3e5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9940:EDA7A:C29F3D:F84ADA:6B00FDC4 |
| html-safe-nonce | ab21c5b7da18e2a4db6446e0411c5be501cf07060a41f83bce6c7118f4ef5101 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTQwOkVEQTdBOkMyOUYzRDpGODRBREE6NkIwMEZEQzQiLCJ2aXNpdG9yX2lkIjoiMjAyMTUyODU1ODQwNDQzNTM5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e39cb8b8a357b1a40bf700dbec4e9b138af3fdef9560a3d7a2f552e809704593 |
| hovercard-subject-tag | issue:207488278 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/4686/issue_layout |
| twitter:image | https://opengraph.githubassets.com/15720b90698d557cf934e08e3a0427228ad5fec00c84e18071d5e1ff9e831a94/angular/angular-cli/issues/4686 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/15720b90698d557cf934e08e3a0427228ad5fec00c84e18071d5e1ff9e831a94/angular/angular-cli/issues/4686 |
| og:image:alt | Please provide us with the following information: OS? Windows 10 Versions. @angular/cli: 1.0.0-beta.30 node: 6.9.1 os: win32 x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fulls1z3 |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width