3lang3 / react-vant

React mobile UI Components base on Vant
https://react-vant.3lang.dev
MIT License
1.33k stars 191 forks source link

🐛 [Bug]: 新版本Swiper组件报错? #626

Closed Garin151 closed 1 year ago

Garin151 commented 1 year ago

Which React Vant packages are impacted?

What version of React Vant are you using?

3.1.16

Reproduce live demo(codesandebox or stackblitz)?

No response

Descripition

使用umi 3.5.37版本搭建项目,安装react-vant依赖。一开始跑项目,报错:./node_modules/@react-spring/shared/dist/index.mjs 881:9-11 Can't import the named export 'raf' from non EcmaScript module (only default export is available)。

百度一下,说是新版webpack的问题。改了一下webpack配置如下: chainWebpack(config) { config.module .rule('mjs') .test(/.mjs$/) .type('javascript/auto') .include.add(/node_modules/) .end(); }, 终于跑了起来。但是,一使用Swiper组件,就会报错:Uncaught TypeError: A is not a function 控制台定位是:./node_modules/@react-spring/shared/dist/index.js:1 感觉react-vant依赖的@react-spring的问题。 希望能排查一下,并修复一下,感谢大佬们

3lang3 commented 1 year ago

更新前使用的哪个版本?

Garin151 commented 1 year ago

之前项目用的是umi 3.5.21;react-vant版本是3.0.2

3lang3 commented 1 year ago

这边没调整过构建,方便给个复现的demo吗

luo3house commented 1 year ago

umi3的配置和锁定的webpack有缺陷。

升级umi到4;或保持umi3,手动降级 react-spring 到 9.6.1

npm i @react-spring/web@9.6.1
Garin151 commented 1 year ago

这边没调整过构建,方便给个复现的demo吗 公司项目,不好给demo

Garin151 commented 1 year ago

umi3的配置和锁定的webpack有缺陷。

升级umi到4;或保持umi3,手动降级 react-spring 到 9.6.1

npm i @react-spring/web@9.6.1

安装后,还是没作用

luo3house commented 1 year ago
npm i @react-spring/web@9.6.1

umi4 demo: https://stackblitz.com/edit/vitejs-vite-u1nv8m

降级 demo: https://stackblitz.com/edit/vitejs-vite-2d5fmu

Garin151 commented 1 year ago
npm i @react-spring/web@9.6.1

umi4 demo: https://stackblitz.com/edit/vitejs-vite-u1nv8m

降级 demo: https://stackblitz.com/edit/vitejs-vite-2d5fmu

感谢,最后选择了用umi4重新搭建项目