During development, this code runs without any issues. However, when attempting to run it in production using the command:
Working:
ionic cordova run android
Not working:
ionic cordova run android --prod --release
Error Message:
[03:34:41] typescript error
Unexpected module 'TranslateModule in C:/Users/tm_ma/Doc/PROJECT/node_modules/@ngx-translate/core/core.d.ts' declared by the module 'EmentaPageModule in
C:/Users/tm_ma/Doc/PROJECT/src/pages/ementa/ementa.module.ts'. Please add a
@Pipe/@Directive/@Component annotation.
[03:34:41] ionic-app-script task: "build"
[03:34:41] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
Ementa Module:
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { EmentaPage } from './ementa'; import { TranslateModule } from '@ngx-translate/core';
@NgModule({
declarations: [
EmentaPage,
TranslateModule
], imports: [
IonicPageModule.forChild(EmentaPage),
TranslateModule
], }) export class EmentaPageModule {}
App Module:
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [
...
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
})
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
...
],
providers: [
]
})
export class AppModule {}
Dependencies Version:
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^4.0.0",
"angularfire2": "^5.0.0-rc.11",
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",