Open yangwen2 opened 3 years ago
@yangwen2 I am facing the same issue getting runtime errors of undefined window.ng
. How are you externalizing angular compiler ?
We are currently externalizing the entire angular compiler umd bundle.
Seems like a half-baked pattern - To externalize some set of the ng library, at the cost of needing to externalize the compiler, which directly impacts time to the LCP.
Any comments on this, please, @manfredsteyer ?
Author's blog post promotes a strategy of externalizing angular libraries so that each individual Angular Elements bundle can be as small as possible (via exclusion of necessary Angular libraries). https://www.angulararchitects.io/aktuelles/your-options-for-building-angular-elements/
My observation from practicing this approach is when we externalize any of the Angular libraries, we also need to externalize @angular/compiler. Otherwise, we'll get runtime errors of undefined window.ng. There appears to be some references that are broken when @angular/compiler is not externalized to the global scope.
The need to externalize the compiler represents a major drawback of this strategy, since AOT build eliminates the need for the compiler at runtime. The UMD bundle for this is library is of non-trivial size.
Has anyone dealt with this concern?