recently our team have received one ticket from customer who complains exactly the same issue.
Let's say you plan to lazy load one CMS component named CustomProductSummaryComponent in whose html implementation, async pipe is utilized. This pipe is implemented in CommonModule.
The feature module which declares this component to be lazy loaded:
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
...
],
providers: [
provideDefaultConfig(<CmsConfig>{
cmsComponents: {
ProductImagesComponent: {
component: () => import('./custom-product-images.component').then(m => m.CustomProductImagesComponent)
},
},
}),
]
})
export class CustomProductImagesModule {}
Although CommonModule is imported in feature module, when the CMS component is lazy loaded, Angular framework fails to grab the required CommonModule automatically, which is considered a limitation.
And the solution is, to manually add the module definition of CustomProductImagesModule again in CustomProductSummaryComponent's implementation file, to ensure that when this component is lazy loaded, the necessary CommonModule has chance to be loaded as well in its own context.
The source code of custom-product-images.component.ts:
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-product-images',
templateUrl: './custom-product-images.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomProductImagesComponent {
...
}
@NgModule({
imports: [
CommonModule,
RouterModule,
MediaModule,
OutletModule,
CarouselModule
],
declarations:[CustomProductImagesComponent]
})
export class CustomProductImagesModule {}
We have tested and this solution can fix the issue.
Best regards,
Jerry