Angular dynamic imports

Viewed 32

I'm updating an angular application from version 8 to 9. Following the Update Guide, I need to use dynamic imports in my modules for lazy loaded routes. It says ng update should take of this automatically. Executing ng-update seems to only list packages to be updated. Is this supposed to be updating my routes or do I need to perform those updates manually?

enter image description here

1 Answers

The command ng update is supposed to do that for your, translating

loadChildren: './lazy/lazy.module#LazyModule',

to

loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)

As stated in the official documentation [Read more here]:

Version 8 update: When you update to version 8, the ng update command performs the transformation automatically. Prior to version 7, the import() syntax only works in JIT mode (with view engine).

Related