-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular 9 Sample Project not working with latest angular #306
Comments
We have the same issue, it worked fine with 5.0.0-beta.2 |
Any ideas or workarounds for this? I am having the same issue. Edit: I got mine working, but I'm not sure what else I'll run into. I used the code from this example, which had different imports: https://codesandbox.io/s/github/fullcalendar/fullcalendar-example-projects/tree/v5/angular?file=/src/app/app.component.html:295-445 |
and now? |
For context, I'm running this via FullCalendar was working until I installed the following packages (used in the example above): No errors (either in browser console, ng serve, or in vscode), no calendar. Just the presence of these plugins seems to bork it. |
This was occurring for me as well, when using the A workaround would be to include the Calendar object in your component:
Then in your constructor actually "use" it so webpack treeshaking doesn't remove it:
This forces loading/initializing of the core component and the VDom reference before the plugin needs it. Note: I believe this works in the embedded online sandbox because of the way the sandbox loads modules via service workers |
Same problem for me. The workaround of efess works! |
@efess that worked for me too. Grazi! |
I wasn't able to consistenly reproduce this. However, I've added a Could someone please try out the new release candidate and see if the problem persists? |
The problem isn't fixed with the RC (Angular 9.1.11):
|
No change here as well, running Angular 9.1.3
|
I don't have any reproducible projects from you all to be able to test the failure case, but I have a hunch about what's happening. If you would please look at the angular sample project while I pose a theory... It's true that you must require the import { CalendarOptions, DateSelectArg, EventClickArg, EventApi } from '@fullcalendar/angular'; However, that only imports types. That statement will get removed for runtime because it doesn't import any real classes/functions/etc. On a related note, there is another import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FullCalendarModule } from '@fullcalendar/angular'; // <-- here!!!
import { AppComponent } from './app.component'; If the imports happen in the order depicted in that snippet, everything will turn out fine. However, if you switch the order, things will break: import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component'; // order switched!!!
import { FullCalendarModule } from '@fullcalendar/angular'; // order switched!!! Things will break because the FC plugins are loaded after QUESTION FOR YOU: Does the snippet above reflect how any of your apps are set up? Are you importing your own app's component before the fullcalendar module? Regardless, it's untenable to expect people to follow such arbitrary ordering for seemingly irrelevant import statements. Assuming my theory is correct, I'll probably recommend that people add this line right above where they import their plugins: around here... https://github.com/fullcalendar/fullcalendar-example-projects/blob/v5/angular/src/app/app.component.ts#L3 add... import { Component } from '@angular/core';
import { CalendarOptions, DateSelectArg, EventClickArg, EventApi } from '@fullcalendar/angular';
+ import '@fullcalendar/angular';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGridPlugin from '@fullcalendar/timegrid';
import listPlugin from '@fullcalendar/list';
import interactionPlugin from '@fullcalendar/interaction';
import { INITIAL_EVENTS, createEventId } from './event-utils'; Can you all try that out and see if it works? It's very similar to @efess's workaround. |
works!!!! note: import order is tricky, because some people (me included) order imports alphabetically. My current import list, auto-formatted: import { CalendarOptions, DateSelectArg, EventApi, EventClickArg } from '@fullcalendar/angular'; |
Yep this works for me. I had the Thank you! |
Just want to chime in and say this issue is also present with React. I was able to fix it with the same fix listed above, except importing react instead of angular. |
This is really annoying. Imports order should not have side effects. |
@qdelettre I'd need a reduced test case to understand what's going on. Please open up a new ticket. I officially released v5, and with the release of v5 I am now recommending a new technique in order to make this import-ordering problem less likely to happen. Please see the updated Angular docs: https://fullcalendar.io/docs/angular I'm encouraging people to use register their plugins in the same place they import them. This makes the ordering of the plugin imports relative to the order of the @adenta, I have plans to emphasize how important the ordering is for react/vue/vanilla-js. I'll update the docs soon. |
Clone example angular app from main git repo, npm install, ng update, ng serve.
Noticed missing dependency as well in package.json:
"@fullcalendar/angular": "5.0.0-beta.3",
Calendar fails to load and shows:
vdom.js:3 Uncaught Error: Please import the top-level fullcalendar lib before attempting to import a plugin.
at Module../node_modules/@fullcalendar/common/vdom.js (vdom.js:3)
at webpack_require (bootstrap:79)
at Module../node_modules/@fullcalendar/common/main.js (main.js:1)
at webpack_require (bootstrap:79)
at Module../node_modules/@fullcalendar/daygrid/main.js (main.js:1)
at webpack_require (bootstrap:79)
at Module../src/app/app.component.ts (app.component.ts:1)
at webpack_require (bootstrap:79)
at Module../src/app/app.module.ts (app.module.ts:1)
at webpack_require (bootstrap:79)
The text was updated successfully, but these errors were encountered: