Creation of a dynamic NgModule error

I am trying to implement dynamic components by instantiating an NgModule using a template component as follows:

createAndCompileComponent(template: string, componentClass: any, extraImports: any[] = []): Promise<ComponentFactory<any>> {
        // Create the component using the template and the class.
        const component = Component({
            template: template

        const imports = this.IMPORTS.concat(extraImports);

        // Now create the module containing the component.
        const module = NgModule({imports: imports, declarations: [component]})(class {});

        try {
            // Compile the module and the component.
            return this.compiler.compileModuleAndAllComponentsAsync(module).then((factories) => {
                // Do some stuff
        } catch (ex) {
            let message = 'Template has some errors and cannot be displayed.';
            return Promise.reject({message: message, debuginfo: ex});

An exception gets caught pointing out the following:

Unexpected value 'IonicModule' imported by the module 'some module'. Please add a @NgModule annotation.

How can I possibly add the annotation in such case ?