NathanWalker / angular-seed-advanced

Advanced Angular seed project with support for ngrx/store, ngrx/effects, ngx-translate, angulartics2, lodash, NativeScript (*native* mobile), Electron (Mac, Windows and Linux desktop) and more.
MIT License
2.26k stars 445 forks source link

Lazy Loading and Preloading for NgModules #420

Open VladimirMakaev opened 7 years ago

VladimirMakaev commented 7 years ago

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see use [gitter](https://gitter.im/mgechev/angular2-seed) or [stackoverflow](https://stackoverflow.com/questions/tagged/angular2)

Current behavior

When using loadChildred for routes with path#ModuleName syntax I'd expect the module to be lazily loaded and it does work for DEV build. (see https://github.com/VladimirMakaev/angular-seed-advanced/commit/3dba3925e66e1d1ed124f3732527008eea52996c)

However neither the normal prod nor aot variation work.

Expected behavior

I'd expect the lazy loading to work in the solution based on the seed project

Minimal reproduction of the problem with instructions

  1. Clone https://github.com/VladimirMakaev/angular-seed-advanced/tree/lazy-loading
  2. npm run serve.prod/npm run serve.prod.aot/npm run serve.prod.rollup.aot

What is the motivation / use case for changing the behavior?

It's about maximum optimizations you can get from the framework. Specifically optimize the frontpage load and then preload other modules.

@NathanWalker I'm happy to contribute if you can point me to the right direction how this could be fixed. Atm it looks to me like this feature requires webpack

NathanWalker commented 7 years ago

Definitely want to get this in. There's likely some adjustments to service providers that may be needed for AoT and lazy loading. I'd need to dive in to point you in right direction, thanks for offer. I'll let ya know when I know more.

negberts commented 7 years ago

You guys have any progress on this subject?

renestalder commented 6 years ago

Anyone found a solution to that? I currently have a larger project and I wanted to split the modules, but only very late noticed that the seed isn't taking care of that. Maybe this should be noted in the README additionally.

Now I tried to dig into the seed code for a couple of hours to find a solution.

Issues I see:

I would really appreciate if some with a bit deeper understanding of the seed can give some hints on how to approach this. I found many sources with help for getting it running with Webpack, but the amount of gulp tasks in the seed are a bit overwhelming for me to apply it easily to that.

VladimirMakaev commented 6 years ago

We’re migrating to nrwl at this stage. I suggest you do the same (or angular cli at least) as you’ll have to do it anyway long term the earlier you do it the better

renestalder commented 6 years ago

@VladimirMakaev I was in hope I can workaround this for the moment but I'm aware that the mechanics of the seed no longer work and should be replaced by webpack.

It's somehow good to hear that this doesn't workout for others too.