Problem with modal after migrating to Ionic5

I have a modal form called “Repair” that is loaded from a normal page called “Repairs”. This code worked perfectly in Ionic4, but after migrating the project to Ionic5 I am getting this warning during ionic build:

WARNING in /Users/victorespina/Work/Fuentes/TMI/DEV/PTA/app/pta_appt_ionic/src/app/priv/repair/repair.module.ts is part of the TypeScript compilation but it's unused.

Add only entry points to the 'files' or 'include' properties in your tsconfig.

The project compiled anyway and I was able to deploy it to my iPhone. But then, when I try to load the “Repair” modal page, all I get is a unresponsive blank page. I then tried this code using ionic serve and it works as expected, so I most conclude that the failure in iOS must have some relation with the warning.

Any ideas about this?

Can you describe how you “migrated” specifically? What I’m particularly interested in is the Angular upgrade process. Did you follow the steps in the Angular 9 release notes? If not, then maybe next time try that and see if things are less painful.

In any event, the contents of any file whose name starts with tsconfig. might be useful for folks trying to help you fix this across this particular project.

Following the official migration guide. Regarding tsconfig file I’ve never made any manual changes to those files. The main point here is that my app worked perfectly in both iOS and Android before migrating to Ionic5, with no warnings whatsoever, and now is not and the only change was the migration to Ionic5.

BTW, the official migration guide says nothing about manually updating Angular version, as far as I know.

In case I wasn’t clear, I was suggesting “post the contents of those files so people can see if changing them could help your situation”. I wasn’t accusing you of having modified anything you shouldn’t have.

I saw your other thread threatening to rage quit using Ionic entirely. If all you’re really after here is to vent about how awful you have found this upgrade, then that’s cool and I’ll just leave you to it.

I guess you are right. I am little too frustrated about this. In my defense, I am under a lot of pressure to release this app and this bug is not helping a bit. Here are my tsconfig files and the files involved in the problem. In the mean time, I will try to find a workaround.

Ionic is a great product and It had helped me a lot to deliver great solutions to my customers. It just frustrate me the level of disregard about backward compatibility that reigns these days, not just with Ionic, but almost every framework out there; I am not used to that.

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "src/test.ts",
    "src/**/*.spec.ts"
  ]
}

repairs.module.ts
Here is where I call the modal that is failing.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { RepairsPage } from './repairs.page';
import { RepairPage } from '../repair/repair.page';
import { ComponentsModule } from '../../components/components.module';

const routes: Routes = [
  {
    path: '',
    component: RepairsPage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    ComponentsModule,
    RouterModule.forChild(routes)
  ],
  declarations: [
    RepairsPage,
    RepairPage
  ],
  entryComponents: [
    RepairsPage,
    RepairPage
  ]
})
export class RepairsPageModule {}

repairs.page.ts
Here is the code that invokes the modal:

import { Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular';
import { ModalController } from '@ionic/angular';
import { AppService } from '../../services/app.service';
import { UIService } from '../../services/ui.service';
import { RepairPage } from '../repair/repair.page';

@Component({
  selector: 'app-repair',
  templateUrl: './repairs.page.html',
  styleUrls: ['./repairs.page.scss'],
})
export class RepairsPage implements OnInit {
   ...
   /**
   * @method Add
   * Incluir una nueva reparacion
   */
  async Add() {
    const modal = await this.modal.create({
      component: RepairPage,
      componentProps: {
        tipo: "(seleccione)",
        notas: "",
        nuevo: true
      }
    });

    const handleModal = (res:any, $this:any) => {
      if (res && res.data && !res.data.cancelado) {
        $this.reparaciones.push(res.data.repair);
      }
    }

    modal.onWillDismiss()
         .then(res => handleModal(res, this));
         
    await modal.present();
  } // Add
}

repair.module.ts
This is the modal page that is failing

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { RepairPage } from './repair.page';

const routes: Routes = [
  {
    path: '',
    component: RepairPage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes)
  ],
  declarations: []
})
export class RepairPageModule {}

repair.page.ts

import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { UIService } from '../../services/ui.service';

@Component({
  selector: 'app-repair',
  templateUrl: './repair.page.html',
  styleUrls: ['./repair.page.scss'],
}) 
export class RepairPage implements OnInit {

  tipo:string;
  @Input() notas:string;
  nuevo:boolean;


  @ViewChild("edtNotas", {static: true}) edtNotas;

  constructor(
  	private modal: ModalController,
  	private ui: UIService
  ) { 
  	this.tipo = "(seleccione)";
  	this.notas = "";
    this.nuevo = true;
  }

  ngOnInit() {
  }


  ionViewDidEnter() {
    if (!this.nuevo) this.focusNotas();
  }


  close() {
    let data = {
      repair: null,
      eliminar: false,
      cancelado: true
    }    
  	this.modal.dismiss(data);
  }


  async repairTypePicker() {
  	//let options = ["Motor", "Caja", "Tren Delantero", "Latonería", "Pintura", "Otros", "No sabe"];
    let options = ["Motor", "Transmision", "Direccion", "Aire Acondicionado", "Pintura", "Otros", "No sabe"]; // Cambio solicitado por Orlando Torres, Ene 8, 2020
    let repairType:any = await this.ui.presentPickerDialog(options);
    if (!repairType) return;
    this.tipo = repairType;
    this.focusNotas();
  } // repairTypePicker


  save() {
  	let data = {
      repair: {
    		tipo: this.tipo.toUpperCase(),
    		notas: this.notas
      },
      eliminar: false,
      cancelado: false
  	}
  	if (this.tipo == "(seleccione)") {
  		this.ui.presentToast("Debe seleccionar el tipo de reparacion");
  		return;
  	}
  	if (this.notas == "") {
  		this.ui.presentToast("Debe indicar la descripcion del trabajo requerido");
  		return;  		
  	}
  	this.modal.dismiss(data);
  } // save


  async remove() {
    let confirmed = await this.ui.presentConfirmDialog("Descartar esta reparación?");
    if (!confirmed) return;

    let data = {
      repair: null,
      eliminar: true,
      cancelado: false
    }
    this.modal.dismiss(data);
  } // remove



  private focusNotas() {
    setTimeout(() => {
      this.edtNotas.setFocus();
    }, 500);
  }

}

When you open the Modal on iOS Device and it is just blank, do you have any error logs in console?

I’ve not tried that on iOS. I tried using ionic serve and there is no error logged to console and the modal works as expected. Also, I have a global error handler that records any unhandled error occurred while the app is running, and there is nothing logged there neither.

Also, the problem occurs only on iOS. I just tried on Android and its working as expected ( although there is a markup problem on another page, that is not happening on iOS).

Forgive me when i’m understanding something wrong, as english isn’t my native language, but i understand this Problem only happens on iOS?

The project compiled anyway and I was able to deploy it to my iPhone. But then, when I try to load the “Repair” modal page, all I get is a unresponsive blank page

Hoe can you say then:

I’ve not tried that on iOS

I’ve not tried to run the app on iOS while debugging on Safari so I can see the Javascript console to verify there is no errors being logged there. That’s what I mean. And don’t worry; English is not my native language either, so some times I wrote things that dond’t make too much sense. :slight_smile:

Okay, can you try this? Maybe the console gives some usefull information

I think we may have found the culprit here. Try replacing those two sections with these:

 "files": [ "src/main.ts", "src/polyfills.ts" ],
 "include": [ "src/**/*.d.ts" ]

Thanks, that solved the problema when building the app. I just had to add src/zone-flag.ts to the files array. Unfortunately, the problem on iOS continues after this change. :frowning:

FWIW, I’m in total agreement with @EinfachHans about the most fruitful-looking line of inquiry on the unresponsive modal. White screens and unresponsive UI is most frequently a result of an uncaught exception somewhere.

1 Like

I spoke too quickly. Although the app worked on iOS (despite the problem with the modal page), ionic serve doesn’t work after applying your changes to the tsconfig file, complaining about page’s module file not found, so I had to go back to my original tsconfig.app.ison file and now ionic serve is working again but the build error is back.

I still have to run the app on iOS with the remote javascript console opened, just to discard an unhandled error causing the problem, but honestly is unlikely. The modal page that is failing is a very simple page, with no native plugins involved, and as I said, not only it was working ok before the upgrade, it works ok now on Android and using ionic serve.

Nevertheless, I will check the console under iOS just to be sure.

Well, I solved my problem by removing the modal page and integrating it on the parent page, using ngIf and a control property to switch between 2 views on the same page (list view and edit view).

Thanks all for your help.

1 Like

Hi,

i get this message, when i build my app. It looks like somebody already was having trouble with this. Is there some more information about this problem available in the betweentime?

WARNING in /home/ubuntu/ionic/myApp/src/environments/environment.prod.ts is part of the TypeScript compilation but it’s unused.
Add only entry points to the ‘files’ or ‘include’ properties in your tsconfig.

Brg Dietmar