-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Class constructor component cannot be invoked without 'new' #7472
Comments
Even more minimalistic: https://jsfiddle.net/tacman1123/917t4mas/2/ <!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<meta name="description" content="MicroCalendar">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<title>MicroCalendar</title>
<script type="importmap">
{
"imports": {
"@fullcalendar/daygrid": "https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@6.1.9/+esm",
"@fullcalendar/interaction": "https://cdn.jsdelivr.net/npm/@fullcalendar/interaction@6.1.9/+esm",
"@fullcalendar/core": "https://cdn.jsdelivr.net/npm/@fullcalendar/core@6.1.9/+esm"
}
}
</script>
<script type="module">
import { Calendar } from '@fullcalendar/core'
import interactionPlugin from '@fullcalendar/interaction'
import dayGridPlugin from '@fullcalendar/daygrid'
// //
const calendarEl = document.getElementById('calendar')
const calendar = new Calendar(calendarEl, {
plugins: [
interactionPlugin,
dayGridPlugin
],
initialView: 'dayGridMonth',
editable: false,
events: [
{ title: 'Meeting', start: new Date() }
]
})
calendar.render()
</script>
</head>
<body id="base">
<div id="calendar">
The calendar will go here.
</div>
</body>
</html> |
Hi @tacman, <!DOCTYPE html>
<html>
<head>
<script type='importmap'>
{
"imports": {
"@fullcalendar/core": "https://cdn.skypack.dev/@fullcalendar/core@6.1.9",
"@fullcalendar/daygrid": "https://cdn.skypack.dev/@fullcalendar/daygrid@6.1.9"
}
}
</script>
<script type='module'>
import { Calendar } from '@fullcalendar/core'
import dayGridPlugin from '@fullcalendar/daygrid'
document.addEventListener('DOMContentLoaded', function() {
const calendarEl = document.getElementById('calendar')
const calendar = new Calendar(calendarEl, {
plugins: [dayGridPlugin],
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
}
})
calendar.render()
})
</script>
</head>
<body>
<div id='calendar'></div>
</body>
</html> |
Yes, the problem seems to be with how jsdeliver is building that version. The instructions in the docs for this seem to be work as expected: |
So the good news is that indeed, fullcalendar works with skypack. The bad news is that skypack appears dead: https://github.com/skypackjs/skypack-cdn/issues https://www.skypack.dev/search?q=fullcalendar&p=1 Search hasn't been working since at least June. So the issue is that someday skypack may go away. I think this issue should stay open until fullcalendar works with jsdelivr, since that seems to be a standard for loading packages/modules. |
Even the calendar-bundle suggests using jsdelivr, although the version is wrong. https://github.com/tattali/CalendarBundle#3-add-styles-and-scripts-in-your-template If the next version of the bundle uses AssetMapper, the installation will happen automatically. I'm working on that now. |
In the tsconfig.json file, replace the value of the "module" key for "es2020": |
@EmersonCoosta I know nothing about how js modules are built, but if this helps get it working on jsdelivr, it'd be a huge help. I don't think it's hard, it's almost certainly a configuration issue. If this might be it, it'd be worth a try republishing! |
Any chance this "new" error will be fixed soon ? What issue should I follow ? |
Just came across this issue too. Here's a hacky way just in case! Install:
Add other plugins as needed. Just make sure the version is 5.11.5. The latest version will not work. Then...
Hope they fix this soon. Updating assets will screw up the version in importmaps. |
Thanks! Great to have a solution, and also the developers can look at what changed between v5 and 6 and maybe fix it. But yeah, needing to re-install these after every update is a bit of a pain. And unlike composer, there's no way to lock to a version or specific commit. |
Seems necessary to map all the files again The following code work with the version <!DOCTYPE html>
<html>
<head>
<script type="importmap">
{
"imports": {
"preact": "https://cdn.jsdelivr.net/npm/preact@10.19.5/dist/preact.mjs",
"preact/compat": "https://cdn.jsdelivr.net/npm/preact@10.19.5/compat/dist/compat.mjs",
"preact/hooks": "https://cdn.jsdelivr.net/npm/preact@10.19.5/hooks/dist/hooks.mjs",
"@fullcalendar/core": "https://cdn.jsdelivr.net/npm/@fullcalendar/core@6.1.10/index.js",
"@fullcalendar/core/index.js": "https://cdn.jsdelivr.net/npm/@fullcalendar/core@6.1.10/index.js",
"@fullcalendar/core/internal.js": "https://cdn.jsdelivr.net/npm/@fullcalendar/core@6.1.10/internal.js",
"@fullcalendar/core/preact.js": "https://cdn.jsdelivr.net/npm/@fullcalendar/core@6.1.10/preact.js",
"@fullcalendar/daygrid": "https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@6.1.10/index.js",
"@fullcalendar/daygrid/internal.js": "https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@6.1.10/internal.js"
}
}
</script>
<script type="module">
import { Calendar } from '@fullcalendar/core'
import dayGridPlugin from '@fullcalendar/daygrid'
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new Calendar(calendarEl, {
plugins: [dayGridPlugin],
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
}
});
calendar.render();
});
</script>
</head>
<body>
<div id="calendar"></div>
</body>
</html> |
I don't think this issue should be closed yet, though maybe the issue is with my code. @pdhuaman , are you able to get this to work in Symfony with AssetMapper using the latest version? |
@tacman |
Can you share any of the controllers? I've been working a generic one that I can include in a Symfony UX Component, but this has been a show-stopper. |
Here's a test controller I created to test this out. Works just fine so are the rest of my controllers on version 5.11.5. //test_controller.js
import { Controller } from "@hotwired/stimulus";
import 'fullcalendar'; //this is needed.
import { Calendar } from "@fullcalendar/core";
import dayGridPlugin from '@fullcalendar/daygrid';
export default class extends Controller {
static targets = ['container']
connect(){
this.initCalendar()
}
initCalendar(){
const cal = new Calendar(this.containerTarget, {
plugins: [dayGridPlugin],
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth'
}
})
cal.render()
}
} view.html.twig <div {{ stimulus_controller('test') }}>
<div id="calendar" data-test-target="container"></div>
</div> //importmaps.php
'fullcalendar' => [ //yes... without the @
'version' => '5.11.5',
],
'@fullcalendar/core' => [// needed
'version' => '5.11.5',
],
'@fullcalendar/common' => [// This is required too!!!
'version' => '5.11.5',
],
'@fullcalendar/daygrid' => [
'version' => '5.11.5',
],
'@fullcalendar/timegrid' => [
'version' => '5.11.5',
],
'@fullcalendar/list' => [
'version' => '5.11.5',
],
'@fullcalendar/interaction' => [
'version' => '5.11.5',
], |
Reduced Test Cases
https://jsfiddle.net/tacman1123/917t4mas/2/
https://tacman.github.io/micro-calendar/fullcalendar/
Open the javascript console to see the error.
Do you understand that if a reduced test case is not provided, we will intentionally delay triaging of your ticket?
Which connector are you using (React/Angular/etc)?
No connector (vanilla JS)
Bug Description
I'm trying to involve fullcalendar using modules and importmap, and am getting an error with a basic example.
In my HTML
And then my app.js is more or less copied from the README.
The render command fails here:
Digging into it, there's a customRenderer set, but that's where it's failing.
I'm new to importmaps, and I suspect that's where my problem is. I'd LOVE to be able to use javascript libraries like this would a build system like NPM. Perhaps I'm missing a component, or not loading them in the right order?
The text was updated successfully, but these errors were encountered: