'Ng Azure Maps throwing error Function calls are not supported in decorators but 'AzureMapsModule' was called. while creating package using ng-packagr

I am using ng-azure-maps in the Angular application. My requirement is to use Azure Maps in application X which will be used as a library in Application Y. Azure maps is working fine with ng build --aot but at the time of library creation, it throws the below error.

ERROR: Error during template compile of 'MapsModuleModule'
  Function calls are not supported in decorators but 'AzureMapsModule' was called.
Unexpected value 'undefined' imported by the module 'MapsModuleModule in D:/demo/azureMapTest/src/app/maps-module/maps-module.module.ts'
Error during template compile of 'MapsModuleModule'
  Function calls are not supported in decorators but 'AzureMapsModule' was called.

Map module

import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DcxMapComponent } from './dcx-map/dcx-map.component';
import { AzureMapsModule } from 'ng-azure-maps';
import { environment } from '../../environments/environment';


@NgModule({
  declarations: [DcxMapComponent],
  imports: [
    CommonModule,
    AzureMapsModule.forChild({
      authOptions: environment.authOptions
    })
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  exports: [DcxMapComponent]
})
export class MapsModuleModule { }

I tried using the factory approach also still issue persists. In the case of the factory, it throws the below error.

Unexpected value '[object Object]' imported by the module. Please add a @NgModule annotation.

Also, If I include it in App.module.ts using the forRoot method, the map shows a white screen only.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source