简体   繁体   中英

compiler-cli throws error as dynamic declarations are encountered

So I got here some pretty big project which was developed with idea that at some point as Angular advances to full 2.0 version it shall have AoT compilation enabled and finally I get all API from Angular up and ready to do it, or so it seems ...

First of all project is working really nice in JiT mode with Angular 2 and Typescript 2.0.2 but not so in AoT.

After massive research I've found out that problem lies in a fact that list of my declarations/providers/entryComponents is aggregated dynamically - that is what happens when application is split in many sub modules each of whom can add something to those lists, as it requires. And soon as I try to do something like: @NgModule({ declarations:[ configuration.declarations ] }) I receive Error encountered resolving symbol values statically.

If I output aggregated value in JiT mode and insert here a static list of all those entries from configuration.declarations manually, it suddenly starts t work.

So the big questions is - what a hell?! why doesn't it work and how to overcome this?

Just as making big application with all sub component requirements listed in single file manually breaks good code design big time and I better not believe that Angular team that has proven to be a really good at making sane coding layouts would imply that as an only alternative.

Try using multiple NgModule s and import them into the modules that require them. You are trying to duplicate what the compiler does for you using import and export .

For more information look here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM