react-id-swiper: Unexpected token import with nextjs
Got this error when using with nextjs.
/sandbox/node_modules/swiper/dist/js/swiper.esm.js:13
import { $, addClass, removeClass, hasClass, toggleClass, attr, removeAttr, data, transform, transition as transition$1, on, off, trigger, transitionEnd as transitionEnd$1, outerWidth, outerHeight, offset, css, each, html, text, is, index, eq, append, prepend, next, nextAll, prev, prevAll, parent, parents, closest, find, children, remove, add, styles } from 'dom7/dist/dom7.modular';
^^^^^^
SyntaxError: Unexpected token import
Here’s the sandbox: https://codesandbox.io/s/k29xjy98j3?fontsize=14
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 20 (4 by maintainers)
@all, I released
2.1.1which support full version. You can import full version byreact-id-swiper/lib/ReactIdSwiper.full@kidjp85 I’m trying to use next-transpile-modules but this is the error now…
my next.config.js looks like this
@rohmanhm , here you are
The issue here is related to es module transpile issue from Next. It’s still not fixed yet. https://github.com/zeit/next.js/issues/706. For now there are 2 temporary solutions here:
Same the problem with @rossenv
Syntax error in ie11
I give up and will downgrade to 1.6.9 😦
If you have Problems with your Jest Tests e.g.
My Solution was to let Jest transform the swiper dependencies. In Jest Config add:
I tried to test
2.1.1and decided downgrade to1.6.9😭Full transpiler version of Swiper is not a problem for me.
I’m still getting the error too when using it with typescript project.