Search code examples
angularionic-frameworkionic3ionic-native

Ionic 3 Angular 4 App throws error on prod release build


I have a Ionic 3 Application which works with Angular 4. It works well and it's nearing to release. When I ran the command, ionic cordova build ios --prod --release, it throws an error.

Type CompanyPortal in /Users/ustuser/Documents/Proj/src/pages/company-portal/company-portal.ts is part of the declarations of 2 modules: AppModule
            in /Users/ustuser/Documents/Proj/src/app/app.module.ts and CompanyPortalPageModule in
            /Users/ustuser/Documents/Proj/src/pages/company-portal/company-portal.module.ts! Please
            consider moving CompanyPortal in /Users/ustuser/Documents/Proj/pages/company-portal/company-portal.ts to a higher module that imports AppModule in
            /Users/ustuser/Documents/Proj/src/app/app.module.ts and CompanyPortalPageModule in
            /Users/ustuser/Documents/Proj/src/pages/company-portal/company-portal.module.ts. You can
            also create a new NgModule that exports and includes CompanyPortal in /Users/ustuser/Documents/Proj/src/pages/company-portal/company-portal.ts then import that NgModule in AppModule in
            /Users/ustuser/Documents/Proj/src/app/app.module.ts and CompanyPortalPageModule in
            /Users/ustuser/Documents/Proj/src/pages/company-portal/company-portal.module.ts.

Read through the forums and with the error log, removed the module specification from the page module.

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { CompanyPortal } from './company-portal';

@NgModule({
  declarations: [
    //CompanyPortal,
  ],
  imports: [
    //IonicPageModule.forChild(CompanyPortal),
  ],
})
export class CompanyPortalPageModule {

}

After doing all such, another type of error occurs like

Can't bind to 'popUpListData' since it isn't a known property of 'cheader'. ("<ion-header class="top-bar">
            <cheader [ERROR ->][popUpListData]="changeDivisonData" [uName]="userName"
            [cheaderValue]="global.headerSelectedValue" (")

popUpListData is defined in one of my component class 'cheader'. The data is dynamic and it is mentioned here like @Input() popUpListData = [];

These all works when using normal command ionic cordova build ios but fails on running for production.

Kindly suggest me the ideas to overcome from this.


Solution

  • Considering the issue with "ionic cordova build ios --prod --release" command, please use below command:

    ionic cordova build ios --minifycss --optimizejs --minifyjs --release
    

    [note:- "ionic cordova build ios --prod --release" command have email pattern matching issue in a form, always give invalid email error hence not used that command]

    Use below link for more details:
    https://ionicframework.com/docs/cli/cordova/build/