lmeijdam / angular-umd-dynamic-example

Angular UMD example of loading new modules dynamically
174 stars 55 forks source link

Unexpected value 'zt' imported by the module umd module when running Angular application with '--prod' flag #19

Closed avserban closed 5 years ago

avserban commented 5 years ago

Hi,

First of all, I really like your angular dynamic umd load example. It has helped a lot with structuring my code and environments. Really, really awesome work!

All works as expected until I want to compile/run my Angular application with the '--prod' flag. When I do run the application with this flag and open the browser to look at my application, for each of the modules I am trying to lazy load I am seeing the following error in the console: "Error: Unexpected value 'zt' imported by the module 'E'. Please add a @NgModule annotation." On closer inspection when diving into the compiler code, I can see that it isn't able to find the CommonModule (which is used by each of my dynamic modules) although I do import @angular/common in my module.service.ts.

Screen Shot 2019-07-07 at 13 30 11

I was wondering if anybody has faced a similar issue or if anybody has any recommendations with regards to the above.

Please let me know if you want me to provide any additional information or if anything is unclear.

Thank you in advance for your help on this.

avserban commented 5 years ago

Found the problem... what I have basically done is turn off build-optimizer for production. This can be done by setting the value of the buildOptimizer variable to false in the angular.json file.

Not ideal, but if anybody has another solution to the above please let me know.

Closing the issue!

lmeijdam commented 5 years ago

Good you've found it out. I got the question a lot of times in the beginning! I've yet to find a way to let it work with the build-optimizer, no luck there yet!

Thanks for using it!

jaichandra commented 5 years ago

still looking for a way to use buildOptimizer

albertobricio commented 3 years ago

Hello all, do you have any news about how to do it using buildOptimizer? Thanks in advance