Ionic 4 questions on app.modules setup


Hi, i feel confuse about the declarations, app.modules.ts. Here is my situation.

I have a page, a headerComponent and a, the Modal will be called in the headerComponent.

First, i have import the page in the app.modules like below.

  declarations: [
    filterModal // need to remove if build in --prod
  entryComponents: [filterModal],

Second i have set the page in the headerComponent and use the modalCtrl to call it out.

import {filterModal} from '....';

async show(){
    this.modal = await this.modalCtrl.create({
      component: filterModal
    return await this.modal.present();

Third just import the headerComponent in the Home page

So here is the problem, In above setup, i can run it on local browser for testing without error. But if i build it in --prod flag, it will get me a error like is part of the declarations of 2 modules:.
And i need to remove the declarations in app.modules.ts but after it removed, i cant view on local browser with this error Component FilterPage is not part of any NgModule or the module has not been imported into your module.

I am not sure which one is correct, the filterModal will only used on the HomePage.