lmeijdam/angular-umd-dynamic-example

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

Closed this issue · 4 comments

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.

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!

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!

still looking for a way to use buildOptimizer

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