Repository navigation
Conversation
ea288cf to
01f483e
Compare
|
You can preview ea288cf at https://pr29730-ea288cf.ngbuilds.io/. |
|
note: still discussing in slack #tools-fix-lazy-routes whether we want to have the migration built-in |
| # Updating Angular Lazy Routes | ||
|
|
||
| When we first introduced lazy routes, there wasn't browser support for dynamically loading additional JavaScript. | ||
| Angular created our own scheme using the syntax `loadChildren: './lazy/lazy.module#LazyModule'` and built complex tooling to support it. |
There was a problem hiding this comment.
Can we pull out the old syntax into a code snippet? Otherwise it's hard to find what pattern is necessary to change.
| 1. Why isn't this migration run automatically by `ng update`? | ||
|
|
||
| This migration is optional in Angular 8. | ||
| Since we expect the majority of users will not opt-into Ivy, we don't want to introduce the risk of breaking your application in case your code or a library you use depends on the current string-based syntax in some way. |
There was a problem hiding this comment.
| Since we expect the majority of users will not opt-into Ivy, we don't want to introduce the risk of breaking your application in case your code or a library you use depends on the current string-based syntax in some way. | |
| Since we expect the majority of users will not opt into Ivy, we don't want to introduce the risk of breaking your application in case your code or a library you use depends on the current string-based syntax in some way. |
gkalpak
left a comment
There was a problem hiding this comment.
More work is needed if you want to add a new migration sub-path (e.g. you need more changes to show the SideNav, show a ToC, etc.). But, we should first discuss whether we want to introduce a new sub-path.
|
@gkalpak - @alexeagle and I discussed the navigation but for now he just wanted to have a URL available. |
|
|
||
| When we first introduced lazy routes, there wasn't browser support for dynamically loading additional JavaScript. | ||
| Angular created our own scheme using the syntax `loadChildren: './lazy/lazy.module#LazyModule'` and built complex tooling to support it. | ||
| Now that EcmaScript dynamic import is a standard and is supported in many browsers, it's time for Angular applications to use this new syntax. |
There was a problem hiding this comment.
EcmaScript -> ECMAScript for consistency?
|
|
||
| When we first introduced lazy routes, there wasn't browser support for dynamically loading additional JavaScript. | ||
| Angular created our own scheme using the syntax `loadChildren: './lazy/lazy.module#LazyModule'` and built complex tooling to support it. | ||
| Now that EcmaScript dynamic import is a standard and is supported in many browsers, it's time for Angular applications to use this new syntax. |
There was a problem hiding this comment.
dynamic import is a standard
It is NOT a standard, which got stuck in stage 3 due to security issue. (Need to land Realms first)
| 1. Install the migrator: | ||
|
|
||
| ```sh | ||
| $ npm install @phenomnomnominal/angular-lazy-routes-fix -D |
There was a problem hiding this comment.
Would it better to use full-form of CLI options? People may forget about what it stands for.
| Angular created our own scheme using the syntax `loadChildren: './lazy/lazy.module#LazyModule'` and built complex tooling to support it. | ||
| Now that EcmaScript dynamic import is a standard and is supported in many browsers, it's time for Angular applications to use this new syntax. | ||
|
|
||
| > Updating your lazy routes to dynamic import is *required* in order to use Angular Ivy. |
There was a problem hiding this comment.
At the moment it is not required anymore, just highly recommended.
There was a problem hiding this comment.
This would be where to put the new text from #29955:
The string syntax for the loadChildren route specification is deprecated in Angular version 8, in favor of new syntax that uses an import statement.
As part of updating an application to Angular version 8, it is recommended that you update to the new import syntax.
You can use angular-lazy-routes-fix to perform the transformation automatically.
For example:
const routes: Routes = [{
path: 'lazy',
// The string syntax for loadChildren is deprecated:
// loadChildren: './lazy/lazy.module#LazyModule'
// This has been transformed to use the new import syntax.
loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)
}];
Ivy supports both the deprecated string syntax and the recommended import syntax.
If you have updated your lazy routes to use the import() statement but are not using Ivy,
make sure your default build options in angular.json include the flag "experimentalImportFactories": true.
|
|
||
| 1. Why isn't this migration run automatically by `ng update`? | ||
|
|
||
| This migration is optional in Angular 8. |
There was a problem hiding this comment.
angular/angular-cli#14181 doesn't seem to be optional currently.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.