Ngx-translate error on --prod build after migration to ionic 4


I had been using ngx-translate with my ionic3 app without problem. Now I have migrated the whole app to ionic 4, and it seemed to be working just fine, until I noticed that when running the build with --prod flag, it throws out the following error:

ionic cordova build android --prod

ERROR in Illegal State: referring to a type without a variable {"filePath":"[...]/node_modules/@ngx-translate/core/ngx-translate-core.d.ts","name":"TranslatePipe","members":[]}
[ERROR] An error occurred while running subprocess ng.


Ionic CLI : 5.2.7
Ionic Framework : @ionic/angular 4.9.0
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0


Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : not available


cordova-res : 0.8.0
native-run : 0.2.8


Android SDK Tools : 26.1.1
NodeJS : v10.15.3
npm : 6.11.3
OS : Windows 10

I’m not sure what it means, so I don’t know where to start looking or what part of the code to copy here.
Any ideas? (Besides skipping the --prod flag, because I would really like to be able to use it.)

Did you find a solution?
I am having the same problem with ionic build --prod

Not quite, but I found this answer on another forum and it has helped me to debug a bit more easily. You can try it.
Temporarily disable tsconfig.json -> fullTemplateTypeCheck and re run ionic cordova build android --prod

Original post:

Found this error can be caused by components being registered in multiple modules, for example in app.module and my_feature_module.module .

Temporarily disabling tsconfig.json -> fullTemplateTypeCheck and re-running ng build --prod might show the related component registration errors.