react-id-swiper: Syntax error in ie11 with nextjs

Syntax error in ie11

-> class Dom7 ....

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 22

Most upvoted comments

So, you wouldn’t believe it but the “Swiper” library author @nolimits4web silently deleted my bug report from his repository: https://github.com/nolimits4web/swiper/issues/3047 Very childish, rude and unprofessional. I guess I’ll have to look for better alternatives to the “Swiper” library.

In the meantime, for everyone having their Internet Explorer broken by the “Swiper” library here’s the workaround I found that stops the “Swiper” library from breaking Internet Explorer:

  • Go to Webpack configuration (webpack.config.js).
  • Find babel-loader there.
  • Modify its exclude from /node_modules/ (the default on the internet) to /node_modules[\/\\](?!(swiper|dom7)[\/\\])/ (I saw the idea in react-id-swiper’s package.json).
  • Now Webpack bundles the website while also actually transpiling dom7 and swiper packages (doing the work the dom7/swiper library author should have done before releasing those untranspiled).

Internet Explorer is still a popular browser in some areas. Breaking it is unacceptable.

@mathishuettl FWIW I added a custom alias for swiper, something like this:

mix.alias({
    'swiper': 'node_modules/swiper/dist/js/swiper.js',
    'swipercss': 'node_modules/swiper/dist/css/swiper.min.css'
});

Not ideal, not the best but does the trick.

Hi guys, i still cannot fix this… According to react-id-swiper document, I have added this into the webpack.config.js. I believe this is to use babel to include dom7 and swiper module and transpile it into es5 code

rules: [
  {
      test: /\.js(x)?$/,
      exclude: [/node_modules\/(?!(swiper|dom7)\/).*/, /\.test\.jsx?$/],
      use: [{ loader: 'babel-loader' }],
  }
]

But after npm run build, I can still find const syntax inside the .js file in dist folder… I can confirm the syntax is came from the swiper module

This cause old browser like safari9 or IE10 display error as below

SyntaxError: Use of const in strict mode.

I m not using nextJS but i hope can find some help in this thread

Just got closed and locked. 😕

Made a new issue here: https://github.com/nolimits4web/swiper/issues/3199 I’d encourage you to join to prevent a deletion again.