ngxd icon indicating copy to clipboard operation
ngxd copied to clipboard

'NgModuleFactoryLoader' is deprecated.

Open aitorllj93 opened this issue 2 years ago • 2 comments

Now that NgModuleFactoryLoader is being deprecated what could be the right syntax for lazy loading our component modules?

aitorllj93 avatar Aug 11 '21 17:08 aitorllj93

Hey 👋 Yes, NgModuleFactoryLoader is now deprecated, so you need to use dynamic imports like here https://github.com/IndigoSoft/ngxd#3-lazy-loading-the-dynamic-component

thekiba avatar Aug 11 '21 17:08 thekiba

Hi, @thekiba thank you for your answer. I'll give it a try, but I'm not sure how to face it, as I want to have my components in different lazy loaded modules, so I only load the specific component needed for each situation. I tried creating lazy loaded modules and adding "fake" lazy loaded routes to the router in order to tell Angular which dependencies my components have. This works fine for components but doesn't load the services included in my component dependencies (angular material component providers). Also, with that approach i'm not able to really lazy load the code, as Angular prepares a single chunk I don't know why. Maybe with your approach I'll be able to get a separated chunk as the dynamic components would be provided in the lazy loaded module that includes the resolver, but still don't know how to generate multiple chunks for each dynamic component using a single resolver

aitorllj93 avatar Aug 11 '21 23:08 aitorllj93