swiper icon indicating copy to clipboard operation
swiper copied to clipboard

Swiper cause next.js can't revalidate.

Open hoangvu12 opened this issue 3 years ago • 11 comments

Check that this is really a bug

  • [X] I confirm

Reproduction link

I don't know if it possible to reproduce the bug in codesandbox...

Bug description

So in Swiper v7, it uses ESM Module. Next.js v12 also support it, everything is okay. But when it try to regenerate pages. It cause this error.

image

Expected Behavior

Next.js should regenerate pages.

Actual Behavior

Next.js can't regenerate pages --> It return the cached pages instead.

Swiper version

7.0.0

Platform/Target and Browser Versions

Chrome

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the docs.
  • [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

hoangvu12 avatar Nov 25 '21 05:11 hoangvu12

Ive been experiencing this as well.

moshfrid avatar Dec 09 '21 05:12 moshfrid

Ive been experiencing this as well.

Have the exakt same issue

I fixed this issue by downgrade Swiper to v6. Here is it's docs: https://swiper6.vercel.app/swiper-api#events

Note: v6's API is kinda different from v7, so be sure to check that out.

hoangvu12 avatar Jan 21 '22 14:01 hoangvu12

@hoangvu12 Do you have problem with revalidation using Swiper 6.7.5 aswell? Or did you fix this by "the old ordinary" way and using

const swiper = new Swiper('.swiper-container', {
  // ...
});

I use 6.75 and get this error: Error: Cannot find module '../../core'

emilpriverrc avatar Jan 21 '22 15:01 emilpriverrc

@hoangvu12 Do you have problem with revalidation using Swiper 6.7.5 aswell? Or did you fix this by "the old ordinary" way and using

const swiper = new Swiper('.swiper-container', {
  // ...
});

I use 6.75 and get this error: Error: Cannot find module '../../core'

No I used React component and it worked fine.

hoangvu12 avatar Jan 21 '22 16:01 hoangvu12

Hi @hoangvu12 How do you host your setup? Vercel? What Next version do you have? :D

emilpriverrc avatar Jan 24 '22 09:01 emilpriverrc

Hi @hoangvu12 How do you host your setup? Vercel? What Next version do you have? :D

I'm hosting on Vercel, Next v12.

hoangvu12 avatar Jan 24 '22 09:01 hoangvu12

What Node version? Sorry if I ask a lot haha.

emilpriverrc avatar Jan 24 '22 09:01 emilpriverrc

What Node version? Sorry if I ask a lot haha.

It's v16.13

hoangvu12 avatar Jan 24 '22 13:01 hoangvu12

Ok, So I added a .node-version with 14.17.0 in it which looked like it fixed it. I now have next 12.0.2 and Swiper 7.4.1

emilpriverrc avatar Jan 24 '22 13:01 emilpriverrc

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.

stale[bot] avatar Jul 31 '22 21:07 stale[bot]

Bump

moshfrid avatar Aug 01 '22 00:08 moshfrid