lbertenasco / ap-ng2-fullcalendar

Angular2 fullcalendar component
MIT License
35 stars 18 forks source link

ng build --prod Error #14

Closed thiagovito closed 7 years ago

thiagovito commented 7 years ago

Hi,

I am facing the following issue when trying to build it to prod.

ERROR in Type CalendarComponent in /MyProject/node_modules/ap-angular2-fullcalendar/src/calendar/calendar.d.ts is part of the declarations of 2 modules: CalendarModule in /MyProject/node_modules/ap-angular2-fullcalendar/angular2-fullcalendar.d.ts and MyModule in /MyProject/src/app/mymodule/mymodule.module.ts! Please consider moving CalendarComponent in /MyProject/node_modules/ap-angular2-fullcalendar/src/calendar/calendar.d.ts to a higher module that imports CalendarModule

I was able to build only using the following command: ng build --prod --aot=false

Versions "ap-angular2-fullcalendar": "^1.2.8" "angular/cli": "1.1.0" "angular": "4.1.0" node: 7.10.0

Any idea what that could be? Thanks

lbertenasco commented 7 years ago

Hi @thiagovito ! "ap-angular2-fullcalendar": "1.3.0" New v1.3.0 released. Please try with that and let me know if it's fixed :) (also you should upgrade your angular to 4.1.3 if the issue persists)

thiagovito commented 7 years ago

Hi @lbertenasco,

Thanks for quick reply. I have updated as you mentioned and still getting same issue. aot false works fine.

lbertenasco commented 7 years ago

aha! is part of the declarations of 2 modules Where are you using CalendarComponent ?

thiagovito commented 7 years ago

So I have it declared in only 1 Module of my Application.

import { CalendarComponent } from 'ap-angular2-fullcalendar';

declarations: [
CalendarComponent
]

and I have a component that calls: <angular2-fullcalendar [options]="calendarOptions"></angular2-fullcalendar>

private events: Object[];
  calendarOptions:Object = {
        header: {
          left: 'prev,next today',
          center: 'title',
          right: 'month,agendaWeek,agendaDay,listMonth,',
        },
        buttonText: {
          today:    'Hoje',
          month:    'Mês',
          week:     'Semana',
          day:      'Dia',
          listMonth:  'Lista mês'
        },
        defaultDate: new Date(),
        editable: false,
        ignoreTimezone: false,
        timezone: 'America/Sao_Paulo',
        locale: 'pt-br',
        defaultTimedEventDuration:'01:00:00',
        events: []
      };
thiagovito commented 7 years ago

It is giving these two options in the error

Please consider moving CalendarComponent to a higher module that imports CalendarModule

You can also create a new NgModule that exports and includes CalendarComponent in
myProject/node_modules/ap-angular2-fullcalendar/src/calendar/calendar.d.ts then import that NgModule in CalendarModule in myProject//node_modules/ap-angular2-fullcalendar/angular2-fullcalendar.d.ts
lbertenasco commented 7 years ago

Could you try to import CalendarModulein your @NgModule imports ? And remove the declaration of the CalendarComponent since it's already declared and exported by the CalendarModule

thiagovito commented 7 years ago

@lbertenasco Awesome! That worked fine!

So I left CalendarModule.forRoot() in the Imports and removed the Component in the declarations. Once again thanks. I appreciate your help and attention!