Cannot open modal from another module in prod build


Im implemented a module which provides an modal. Then I created an Ionic app which wants to open the modal from this module. This works in debug build, but not in prod build. There I get the error:

Error: Uncaught (in promise): Error: No component factory found for t. Did you add it to @NgModule.entryComponents?

After disabling minification, the error message was a little bit more helpful:

Error: Uncaught (in promise): Error: No component factory found for ModalCmp. Did you add it to @NgModule.entryComponents?

I stripped the error down to tree-shaking. If I disable it in package.json:

"config": {
  "ionic_manual_treeshaking": false

everything works fine. I assume, I have to add something somewhere to prevent the removing of ModalCmp by tree-shaking.

But what? Any help would be appreciated.


First thing I would try is exporting the modal component out of the module that declares it.


I did as you suggested, but the result is the same.
I also updated the repositories on GitHub.

Do you have any other ideas/suggestions?


I haven’t done it before, but try googling around for steps needed to make modules AoT-compatible. You might be missing some metadata that ngc needs.


The problem was introduced with @ionic/app-scripts@1.3.6 (which activated tree shaking by default). In the next version, it will be fixed.