title: Unexpected pipe 'EscapeHtmlPipe in escape-html.pipe.ts Please add a @NgModule annotation
body: <p>Running <code>ng build --prod</code> gives me the following error. </p>
  
  <p>ERROR in : Unexpected pipe 'EscapeHtmlPipe in escape-html.pipe.ts' imported by the module 'AppModule in app.module.ts'. Please add a @NgModule annotation.</p>
  
  <p>Works fine on <code>ng serve</code>. Problem with <code>ng build --prod</code> only</p>
  
  <p>The code in file is given below </p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { CommonModule } from '@angular/common';
  import{ EscapeHtmlPipe } from '../../Shared/pipes/escape-html.pipe';
  
  @NgModule({
    imports: [CommonModule],
    declarations: [EscapeHtmlPipe],
    exports: [EscapeHtmlPipe]
  })
  export class EscapeHtmlModule { }
  </code></pre>
  
  <p>The code file for pipe is given below </p>
  
  <pre><code>import { Pipe, PipeTransform } from '@angular/core';
  import { SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
  
  @Pipe({
    name: 'escapeHtml'
  })
  export class EscapeHtmlPipe implements PipeTransform {
  
    constructor(protected sanitizer: DomSanitizer) { }
  
    transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
      switch (type) {
        case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
        case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
        case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
        case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
        case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
        default: throw new Error(`Invalid safe type specified: ${type}`);
      }
    }
  
  }
  </code></pre>
  
  <p>in AppModule I have  done this </p>
  
  <pre><code>import { EscapeHtmlModule } from './Module/escape-html/escape-html.module';
  </code></pre>
  
  <p>the NgModule part is given below</p>
  
  <pre><code>NgModule({
    declarations: [
      AppComponent,
      // EscapeHtmlPipe,
      NavMenuComponent,
      OpportunityComponent,
      HomeComponent,
      FileUploadComponent,
      TinymceComponent,
      SummaryComponent,
      OpportunityListComponent
    ],
    imports: [
      BrowserModule,
      MaterialModule,
      FormsModule,
      ReactiveFormsModule,
      AppRoutingModule,
      BrowserAnimationsModule,
      HttpClientModule,
      DragDropModule,
      ScrollDispatchModule,
      EditorModule,
      // EscapeHtmlPipe,
  
      DragulaModule.forRoot(), 
      ContextMenuModule.forRoot(), EscapeHtmlModule
    ],
    providers: [
      RFPDocumentService,
      ColorChangeService,
      CategoryService,
      InsertCategoryAttributeService
    ],
    bootstrap: [AppComponent],
    entryComponents:[TinymceComponent,OpportunityListComponent]
  })
  </code></pre>
  
  <p>But the problem was even exist before I added EscapeHtmlModule in the middle ware as earlier I was adding the pipe directly in AppModule and that was generating the error.
  Any help would be appreciated
  Thanks  </p>