Title: [router] Recommend Dynamic Import Expressions instead of string for loadChildren · Issue #7147 · angular/angular-cli · GitHub
Open Graph Title: [router] Recommend Dynamic Import Expressions instead of string for loadChildren · Issue #7147 · angular/angular-cli
X Title: [router] Recommend Dynamic Import Expressions instead of string for loadChildren · Issue #7147 · angular/angular-cli
Description: Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [ ] feature request - [x] suggestion/idea Desired functionality. Currently, it's recommended to use loadChildren with the module ...
Open Graph Description: Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [ ] feature request - [x] suggestion/idea Desired functionality. Currently, it's recommen...
X Description: Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [ ] feature request - [x] suggestion/idea Desired functionality. Currently, it's r...
Opengraph URL: https://github.com/angular/angular-cli/issues/7147
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[router] Recommend Dynamic Import Expressions instead of string for loadChildren","articleBody":"\u003c!--\r\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION YOUR ISSUE MIGHT BE CLOSED WITHOUT INVESTIGATING\r\n-->\r\n### Bug Report or Feature Request (mark with an `x`)\r\n```\r\n- [ ] bug report -> please search issues before submitting\r\n- [ ] feature request\r\n- [x] suggestion/idea\r\n```\r\n### Desired functionality.\r\nCurrently, it's recommended to use `loadChildren` with the module location as a string and the class name after a `#` like following:\r\n``` typescript\r\nconst appRoutes: Routes = [\r\n {\r\n path: 'crisis-center',\r\n loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule'\r\n }\r\n];\r\n```\r\nSince Typescript 2.4 we can use the feature \"Dynamic Import Expressions\", which allows to dynamically import modules without using external module loaders like SystemJS.\r\n\r\nI would suggest to deprecate the string loading functionality and switch to something like the following, not only because this is a nifty feature Typescript now supports, but we can get rid of additional logic to ensure webpack builds the lazy loaded chunks (`/packages/@ngtools/webpack/src/lazy_routes.ts`):\r\n\r\n``` typescript\r\nexport function loadCrisisCenterModule() {\r\n return import('app/crisis-center/crisis-center.module').then(mod => mod.CrisisCenterModule);\r\n}\r\n\r\nconst appRoutes: Routes = [\r\n {\r\n path: 'crisis-center',\r\n loadChildren: loadCrisisCenterModule\r\n }\r\n];\r\n```\r\nI've tried the code after switching modules in tsconfig from `es2015` to `commonjs` and with `@angular/cli@1.2.4`\r\n\r\nHere is a [plunkr example](https://plnkr.co/edit/hTY3sj3nT1G5ppQjxqI3?p=preview)","author":{"url":"https://github.com/sclausen","@type":"Person","name":"sclausen"},"datePublished":"2017-07-26T08:47:58Z","url":"https://github.com/angular/angular-cli/issues/7147"}
| 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:b0bc511c-372b-52ea-38ce-de956c14b311 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98E6:2270F4:12570F4:1862695:6B011F5E |
| html-safe-nonce | 57cc645840ca36e8bebbc197c4300115354f5e57e21192e571c689058e58aba5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEU2OjIyNzBGNDoxMjU3MEY0OjE4NjI2OTU6NkIwMTFGNUUiLCJ2aXNpdG9yX2lkIjoiMTIxNzY0NzQ0OTUzMTgxNzgyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e2e559b0972b8095e268c9f9e918cead3c89c64bdaab359d0815eb53154bd857 |
| hovercard-subject-tag | issue:245649352 |
| 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/7147/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e0a461ea7470eeda7ebb0f0ab8114148c35533b70f89b2e2e1206f0b7a40656e/angular/angular-cli/issues/7147 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e0a461ea7470eeda7ebb0f0ab8114148c35533b70f89b2e2e1206f0b7a40656e/angular/angular-cli/issues/7147 |
| og:image:alt | Bug Report or Feature Request (mark with an x) - [ ] bug report -> please search issues before submitting - [ ] feature request - [x] suggestion/idea Desired functionality. Currently, it's recommen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sclausen |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width