IE11 的 Swiper v4 转换失败(使用 Webpack 5 + Babel 7)

Transform of Swiper v4 for IE11 failed (with Webpack 5 + Babel 7)

我构建并推送了我想做的事情的简化版本:
https://github.com/vaxul/swiper4-webpack5-babel7

它应该做什么

打开时 index.html in Internet Explorer 11 (IE11), the slideshow with Swiper 正在工作。

发生了什么

IE11 报错:

SCRRIPT1002: Syntax error
vendors.js (3135,1)

这是由 line 3135 中的 class 声明引起的。


我必须使用 Swiper v4,因为它是 IE11 的最后一个兼容版本。

Bootstrap 的 Webpack 5 uses Babel 7 and the Browserlist 当前设置。

babel调试显示:

...

Using targets:
{
  "android": "4.4",
  "chrome": "45",
  "edge": "12",
  "firefox": "38",
  "ie": "10",
  "ios": "9",
  "opera": "30",
  "safari": "9",
  "samsung": "12"
}

...

Using plugins:
...
transform-classes { "android":"4.4", "chrome":"45", "edge":"12", "firefox":"38", "ie":"10", "ios":"9", "opera":"30", "safari":"9" }
...

你可以看到 类 的转换是 运行,当查看 example class 的结果时:
https://github.com/vaxul/swiper4-webpack5-babel7/blob/master/dist/js/source_Slider_mjs.239afbde125d3f32e9af.js#L18

但它没有将 class Dom7node_modules/dom7/dist/dom7.modular.js.

中提及

目前我不知道为什么它不起作用。

从我的角度来看,我希望 babel-loader 将转换所有代码 ,包括 来自 node_modules.

的文件

我真的希望有人给我提示并指出正确的方向。请。


编辑 1

.babelrc重命名为babel.config.json并在babel-loader中添加little configuration后,class Dom7的代码被正确转换。

但是,现在我在每个浏览器中都遇到了错误的问题:

ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: WA63

工作版本: https://github.com/vaxul/swiper4-webpack5-babel7

按键更改: