dynamicweb / swiffy-slider

Super fast carousel and slider with touch for optimized websites running in modern browsers.
MIT License
238 stars 29 forks source link

How to import extensions as module? #84

Closed klickreflex closed 9 months ago

klickreflex commented 9 months ago

I'm trying Swiffy Slider for the first time, and I add it to my bundle using Vite. As I'd like to add mouse dragging, I need swiffy-slider-extensions, but I cannot find a way to import them – is this intended or am I missing something?

nicped commented 9 months ago

Hi - well I can see there is no export for it in the package, https://github.com/dynamicweb/swiffy-slider/blob/main/package.json, so that has never been included. I will make a PR to add that so it can be included like the below:

import { swiffysliderextensions} from 'swiffy-slider/extensions';
window.swiffyslider.extensions = swiffysliderextensions;

But I do think you can just import it like ESM 6:

import {swiffysliderextensions} from 'swiffy-slider/dist/js/swiffy-slider-extensions.js'; 
window.swiffyslider.extensions = swiffysliderextensions;

BR Nicolai

klickreflex commented 9 months ago

Thank you, that's very nice.

Meanwhile I went back to SplideJS because I didn't manage to bundle it properly, but for the next project I'll be back. Swiffy's bunble size is really compelling :)

nicped commented 9 months ago

12kb Gzipped as SplideJS... It is almost 10 times as much :-)

dngraphisme commented 8 months ago

Hello @nicped thanks for your work. Where is your PR for add extensions ?

Because webpack tells me this: ./dist/js/swiffy-slider-extensions.min.js is not exported from package

Thanks, Nicolas