-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Swiper Svelte doesn't support SSR under Sapper JS #3961
Comments
Would it be possible to include the source *.svelte components in the build? This would enable the *.svelte components to be built using the current project's svelte compiler, ensuring the correct version & configuration is used during the build. |
@igolkotek @btakita can you confirm that it's fixed ? |
Same problem here. When I import the *.svelte components directly, Rollup fails to import some helper files like |
I've managed to fix it in a fork just enough so we can keep using Swiper in our project, however I'm not sure what a proper fix would be because I'm not familiar with the build process (which seems fairly complex). It seems like the main issue is that when you import something in a Svelte project, it expects to compile the component along with all of its dependencies, through each projects' build process. Here are the changes I made in order to get it to work: zakkor@0984204 I fixed the import paths so they point to the correct files, and included some of the needed pre-built JS files in the |
For anyone wondering: this works now, but you need to load the Swiper module dynamically in the |
@silllli any chance you can provide a working code snippet? I managed to get the imports working using |
Maybe you forgot to import and tell Swiper about the navigation and pagination modules? I didn’t test it, but something like this should work:
You also need to import the needed Swiper stylesheets. I do it in the style tag via SASS, whereas the Swiper docs import them in the I hope it helps! |
Thanks for the the comprehensive response @silllli . I had most of that in place but I modified to match exactly and no change as yet. I'll keep trying. |
I looked at it again since this bugged me. 🤓 Some adjustments were needed—I experienced a similar scenario that you describe (being stuck on the first slide) after running my code. I then added the Here is my actually working code:
I also found this in the docs:
So we actually don’t need to use the slots (and my first code was wrong—there can always only be one element assigned per slot). |
Thanks @silllli . Still no joy for me. Not sure what's wrong with it. I copied and pasted the carousel from https://github.com/beyonk-adventures/svelte-carousel/blob/master/src/Carousel.svelte into my own Carousel component and that worked. |
@nolimits4web thanks for this but still having trouble. I'm using SvelteKit (beta), the replacement for Sapper. After updating swiper dependencies and imports as per new docs, the production build runs but the the carousel doesn't work (all slides are displayed at once). |
Did you try this yet? https://swiperjs.com/svelte#using-with-sapper-and-svelte-kit |
@thebells1111 yes that error I posted above is after following the instructions in that link. |
any news on this? having the same issue with sveltekit, navigation won't work |
There is a workaround for SvelteKit (should work for Sapper too) Slider.svelte
This is going work, we import Slider.svelte component this way:
So I basically suggest not to import all the Swiper instances within |
@RomanistHere excuse my ignorance, but how does this work for Sapper applications? |
This is a (multiple allowed):
[] bug
enhancement
feature-discussion (RFC)
Swiper Version: 6.3.5.
Platform/Target and Browser Versions: Ubuntu 20.04, Firefox 83.
What you did
Sapper bundle compilation in dev mode fails both whether Swiper is added according to Swiper site example or with Mount according to Sapper recommendations.
The text was updated successfully, but these errors were encountered: