Closed
Description
🚀 Feature request
I would like to the option to turn on/off the 'dedupe-duplicate-modules' function at build time.
Because, I'm using both the DateAdapter module of '@angular/material/core' and the DateAdapter module of 'angular-calendar'.
Therefore, either of them will not work after build that due to the 'dedupe-duplicate-modules' function.
Sample code
a.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatNativeDateModule } from '@angular/material/core';
import { NgxMaterialTimepickerModule } from 'ngx-material-timepicker';
@NgModule({
imports: [
CommonModule,
FormsModule,
RouterModule.forChild(routes),
ReactiveFormsModule,
MatFormFieldModule,
MatInputModule,
MatDatepickerModule,
MatNativeDateModule,
NgxMaterialTimepickerModule,
],
a.component.ts
import { MatDatepickerInputEvent, MatDatepicker } from '@angular/material/datepicker';
import { MAT_MOMENT_DATE_FORMATS, MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
import { NgxMaterialTimepickerComponent, NgxMaterialTimepickerTheme } from 'ngx-material-timepicker';
@Component({
providers: [
{ provide: MAT_DATE_LOCALE, useValue: 'en-US' },
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS] },
{ provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS }
]
})
b.module.ts
import { NgModule } from '@angular/core';
import { CommonModule, registerLocaleData } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { CalendarModule, DateAdapter } from 'angular-calendar';
import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';
@NgModule({
imports: [
CommonModule,
FormsModule,
CalendarModule.forRoot({provide: DateAdapter, useFactory: adapterFactory}),
RouterModule.forChild(routes),
b.component.ts
import { CalendarEvent, CalendarView, DAYS_OF_WEEK, CalendarMonthViewDay, CalendarDateFormatter, CalendarEventTitleFormatter } from 'angular-calendar';
import { isSameMonth, isSameDay } from 'date-fns';
import { CustomDateFormatter } from './custom-date-formatter.provider';
import { CustomEventTitleFormatter } from './custom-title-formatter.provider';
@Component({
providers: [
{
provide: CalendarDateFormatter,
useClass: CustomDateFormatter
},
{
provide: CalendarEventTitleFormatter,
useClass: CustomEventTitleFormatter
}
]
})
It works fine until @angular-devkit/build-angular@0.1000.0-next.6
But, An error occurs from @angular-devkit/build-angular@0.1000.0-rc.0 or later.
error log
core.js:4073 ERROR Error: Cannot instantiate cyclic dependency! DateAdapter
at throwCyclicDependencyError (core.js:5357)
at R3Injector.hydrate (core.js:11262)
at R3Injector.get (core.js:11088)
at NgModuleRef$1.get (core.js:23982)
at Object.get (core.js:22238)
at getOrCreateInjectable (core.js:3799)
at ɵɵdirectiveInject (core.js:13770)
at ɵɵinject (core.js:804)
at NodeInjectorFactory.CustomDateFormatter_Factory [as factory] (ɵfac.js? [sm]:1)
at getNodeInjectable (core.js:3907)
Therefore, it seems to be affected by the 'dedupe-duplicate-modules' function.