nolimits4web / swiper

Most modern mobile touch slider with hardware accelerated transitions
https://swiperjs.com
MIT License
39.95k stars 9.75k forks source link

Swiper issue with Svelte + Snowpack #5230

Closed jeremydierx closed 1 year ago

jeremydierx commented 2 years ago

Check that this is really a bug

Reproduction link

https://github.com/jeremydierx/swiper-svelte-snowpack-issue

Bug description

Hi!

I have follow the tuto to setup Swiper with Svelte and I have an issue when I launch my app through Snowpack:

Failed to init component

TypeError: Cannot read properties of undefined (reading '$$') at init (http://localhost:8080/_snowpack/pkg/swiper.svelte.v7.3.1.js:356:46) at new Swiper$1 (http://localhost:8080/_snowpack/pkg/swiper.svelte.v7.3.1.js:5153:3) at create_fragment (http://localhost:8080/App.svelte.js:287:11) at init (http://localhost:8080/_snowpack/pkg/svelte.internal.v3.44.2.js:1647:35) at new App (http://localhost:8080/App.svelte.js:382:3) at createProxiedComponent (http://localhost:8080/_snowpack/pkg/svelte-hmr.runtime.hot-api-esm.v0.13.5.js:242:9) at new ProxyComponent (http://localhost:8080/_snowpack/pkg/svelte-hmr.runtime.hot-api-esm.v0.13.5.js:482:20) at new Proxy (http://localhost:8080/_snowpack/pkg/svelte-hmr.runtime.hot-api-esm.v0.13.5.js:581:11) at http://localhost:8080/index.js:4:11 My snowpack.config.js: /** @type {import("snowpack").SnowpackUserConfig } */ export default { mount: { /* ... */ }, plugins: [ /* ... */ '@snowpack/plugin-svelte' ], routes: [ /* Enable an SPA Fallback in development: */ // {"match": "routes", "src": ".*", "dest": "/index.html"}, ], optimize: { /* Example: Bundle your final build: */ // "bundle": true, }, packageOptions: { /* ... */ }, devOptions: { /* ... */ }, buildOptions: { /* ... */ }, }; my index.js: /* Add JavaScript code here! */ import App from "./App.svelte"; let app = new App({ target: document.body, }); export default app;` my App.svelte:
Learn Svelte
console.log('slide change')} on:swiper={(e) => console.log(e.detail[0])} > Slide 1 Slide 2 Slide 3 Slide 4 ...
` my Github repo: https://github.com/jeremydierx/swiper-svelte-snowpack-issue Help needed! :) ### Expected Behavior _No response_ ### Actual Behavior _No response_ ### Swiper version 7.3.1 ### Platform/Target and Browser Versions Chrome Version 96.0.4664.45 (Build officiel) (64 bits) ### Validations - [X] Follow our [Code of Conduct](https://github.com/nolimits4web/swiper/blob/master/CODE_OF_CONDUCT.md) - [X] Read the [docs](https://swiperjs.com/swiper-api). - [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate. - [X] Make sure this is a Swiper issue and not a framework-specific issue ### Would you like to open a PR for this bug? - [ ] I'm willing to open a PR
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

nolimits4web commented 1 year ago

New Swiper v9 doesn't have Svelte components anymore, it is recommended to use new Swiper Web Components instead.