i've installed swiper js with importmap:require swiper in symfony. it download a umd version of the package in the vendor/
Note: i use it in a stimulus controller
We cannot import Swiper from "swiper" because importmap install the umd version.
I've tried using it with const Swiper = window.Swiper; but it is undefined
import { Controller } from "@hotwired/stimulus";
import "swiper";
export default class extends Controller {
connect() {
const Swiper = window.Swiper;
this.swiper = new Swiper('.swiper', {
pagination: {
el: '.swiper-pagination',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
}
});
}
}