preboot / angular-webpack

A complete, yet simple, starter for Angular v2+ using webpack
MIT License
1.29k stars 557 forks source link

how to chunk appart an angular dynamicaly injected component #345

Open phil123456 opened 7 years ago

phil123456 commented 7 years ago

Hi,

the seed, apparently, automates the separation of components that are lazy loaded ... just amazing

but how do I force a particular angular component to be chunked separately ? I add that component dynamicaly, by injecting it in a template

let componentFactory = this.componentFactoryResolver.resolveComponentFactory(adItem.component);
let viewContainerRef = this.adHost.viewContainerRef;
let componentRef = viewContainerRef.createComponent(componentFactory);

[I came here since nobody replies in stack overflow]

thanks

Foxandxss commented 7 years ago

No SO nor the issue you opened in the angular repo for the DCL guide :P

I am not sure if I follow you problem nor if if you can fix it with webpack.

phil123456 commented 7 years ago

"No SO nor the issue you opened in the angular repo for the DCL guide :P"

I have no idea what this phrase means :-) SO ?DCL ? the issue I opened ???

if you do lazy loading, webpack creates a separate chunk...js , right ? and it is fetched when you navigate

so as I inject a component in a template dynamicaly, I want it to be in a separate chuk too and fetched when I insert the component too.... angular is so static ...

dynamic content can be loaded so easily with regular php/js application

Foxandxss commented 7 years ago

I have no idea in how to do that, sorry.

And with the issue I mean https://github.com/angular/angular/issues/17158