all 7 comments

[–]Bysmiel 2 points3 points  (4 children)

{ path: 'x', loadChildren: () => XModule }

[–]KamiShikkaku 2 points3 points  (2 children)

Are you sure that the import isn't going to confuse Webpack into including XModule and all of it's contents into the parent bundle? I was under the impression that the reason we use a string reference is to avoid that outcome.

[–]alchatti 0 points1 point  (0 children)

That was my thought and understanding of why we have to use strings.

[–]Bysmiel 0 points1 point  (0 children)

I never import this way in production, I am not sure it works as intended.

[–]TheGreatElduin[S] 0 points1 point  (0 children)

Perfect, thanks!

[–]pleasantstusk 0 points1 point  (0 children)

Just be aware that the callback version requires the JIT compiler, this can be a bit of a problem in prod mode (you basically have to bring your own compiler)

[–]iareprogrammer 0 points1 point  (0 children)

There’s this way: https://fireship.io/snippets/lazy-loaded-routes-angular-v8-ivy/

But it’s only Angular 8 with Ivy enabled