How to create a dynamic component in angular 6 when prod mode is on

I had a requirement where i was creating a dynamic componnent using angular5. I had writtena directive which generated a component. It worked fine in dev/prod mode both. But on upgrading the app to angular6 it doesnt work as in prod mode when AOT is "ON", the compiler class is unavailable. how can i re-design my soln so as it works in angular6 ?

export class HtmlOutletDirective implements OnChanges {
@Input() html: string;
constructor(private vcRef: ViewContainerRef, private compiler: Compiler, 
private translate: TranslateService) {

ngOnChanges() {
const html = this.html;
if (!html) { return; }

  selector: 'ccw-dynamic-component',
  template: `
    <div [innerHtml]="innerHtmlTemplate">

class DynamicHtmlComponent {
  private innerHtmlTemplate: any = '';
  constructor(private httpClient: HttpClient, private sanitizer: DomSanitizer) {
    this.httpClient.get(html, { responseType: 'text' }).subscribe((htmlContent) => {
      this.innerHtmlTemplate = sanitizer.bypassSecurityTrustHtml(htmlContent.toString());

  imports: [CommonModule],
  declarations: [DynamicHtmlComponent]

class DynamicHtmlModule { }

  .then(factory => {
    const compFactory = factory.componentFactories.find(x => x.componentType === DynamicHtmlComponent);
    const compRef = this.vcRef.createComponent(compFactory, 0);

I call my directive like this in my component:

   <mat-accordion [multi]="true">
        <mat-expansion-panel *ngFor='let releaseNote of releaseNotes'>
                <dcHtmlOutlet [html]="releaseNote.html"></dcHtmlOutlet>

Below is the error i get:

 Runtime compiler is not loaded Error stack trace: Error: Runtime compiler is not loaded at Le (main.00612d315fe86075b5fb.js:1) at t.compileModuleAndAllComponentsAsync