I am using webpack with babel to transpile modules and after adding swiper npm package to the build, IE11 browser stopped working because dom7 dependency is not transpiled properly. This is pointed out on the swiper's get started page, however it is not clear what has to be done to fix the problem.
swiperjs es module build doesn't work in IE11 browser
1.8k Views Asked by Mr T At
2
There are 2 best solutions below
0
On
Update in 2022:
Previous answer was correct, but swiper 7 adds a new esm dependency named ssr-window. So it needs to be added as below:
webpack.config.js (relevant section only):
test: /\.js$/,
exclude: /node_modules\/(?!(swiper|dom7|ssr-window)\/).*/,
rules: [
{
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
rootMode: 'upward'
}
}]
}
]
After couple days of research and multiple attempts, I've finally got it working.
Important thing to note is that you must use
babel.config.jsinstead of.babelrcso thatnode_modulescould be included into build.The final configuration:
babel.config.js(relevant section only):webpack.config.js(relevant section only):Here is the article which got me to the right direction (see comment from RyanGosden) - https://www.bountysource.com/issues/79144083-not-working-in-ie11
Hope that helps other people to save some time!