之前在做項目的時候 webpack 中使用swiper會出現 error:Cannot assign to read only property 'exports' of object '#<Object>' 似乎是exports和import不兼容引起的
網上有很多解決辦法,但都不盡如人意。這里介紹一種比較好的兼容辦法
需要引入插件
-
npm install babel-plugin-transform-es2015-modules-commonjs
然后在 babelrc中配置
{ "plugins": ["transform-es2015-modules-commonjs"] }
即可解決