swiper: Swiper4 seems cannot be compressed by webpack UglifyJs plugin

Error below occurred when I tried to compress swiper4 via Webpack3 build-in UglifyJs plugin).

ERROR in scripts/lion_6a64ded940eb84148718.js from UglifyJs
Unexpected token: name (i) [scripts/lion_6a64ded940eb84148718.js:6536,6]

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

You are probably including ES-next version of swiper. If you use it with imports you need to use something like babel-loader or import correct version: import Swiper from 'swiper/dist/js/swiper.js';

I was using just import Swiper from 'swiper'; and I can confirm that import Swiper from 'swiper/dist/js/swiper.js'; solved the issue for me.

I got the same issue using Swiper 4 and I couldn’t figure out how to fix it. Using babel-loader throws this error:

ERROR in bundle.f5a6f788eede24f03ca9.js from UglifyJs
Unexpected token: operator (*) [./node_modules/swiper/dist/js/swiper.esm.bundle.js:1661,85][bundle.f5a6f788eede24f03ca9.js:2631,140]

3.4.2 version is ok Webpack build uglify