web-infra-dev / rsbuild

The Rspack-based build tool. It's fast, out-of-the-box and extensible.
https://rsbuild.dev/
MIT License
1.45k stars 115 forks source link

[Bug]: About Vue 3 hot update #3217

Open MinGuoGuo opened 1 month ago

MinGuoGuo commented 1 month ago

Version

mac m1pro
chorme
rsbuild最新版本

Details

我用rsbuild新建的vue3模板,热更新是对当前页面的全量替换,不会保留当前页面的state,我只是在template里面更新了ui,script里面的state都会重新初始,感觉这样体验很不好,这一点的表现和webpack,vite都有所不同。复现仓库链接:https://gitee.com/xiangminya/rsbuild-hmr 该仓库里面分别用rsbuild和vite初始化了一个项目,修改UI热跟新表现不一致

Reproduce link

https://gitee.com/xiangminya/rsbuild-hmr

Reproduce Steps

详细问题可到仓库查看

witsaint commented 1 month ago

@chenjiahan This Issure looks like it came from rspack. I started the service with Rpack and liveReload was still working。

witsaint commented 1 month ago

HMR took effect when I set devtool: false

chenjiahan commented 1 month ago

Maybe related to Vue itslef? https://github.com/vuejs/core/issues/3250

MinGuoGuo commented 1 month ago

@chenjiahan oh my god,看起来他们那个issue已经open长达三年时间了😭

witsaint commented 1 month ago

I have run it with webpack and hmr can work normally, which is not the same as the vue issue

MinGuoGuo commented 1 month ago

@witsaint Yes, HMR can run normally in both webpack and Vite, so I don't know why it doesn't work properly in RSBuild

SoonIter commented 1 month ago

Related to the template caching feature in vite-plugin-vue https://github.com/vitejs/vite-plugin-vue/pull/386?open_in_browser=true

But the template caching is not available in vue-loader

witsaint commented 3 weeks ago

@chenjiahan Over the weekend, I probably found out the reason: the module returned in hot.xx.js does not match the moduleid of hot.accept in the code inserted by vue-loader. There are too many modules returned, and due content will be overwritten in runtime, so the callback of hot.accept is not executed

witsaint commented 3 weeks ago

Key code in hmr

MinGuoGuo commented 3 weeks ago

@chenjiahan dalao,will this be fixed as a bug in future versions

chenjiahan commented 3 weeks ago

Yes it should be fixed if it is a bug of Rspack. PR welcome~

MinGuoGuo commented 2 weeks ago

@witsaint 大佬提个pr给修复下呗,菜鸡膜拜

wanghao1993 commented 4 days ago

@chenjiahan dalao,will this be fixed as a bug in future versions

笑死了哥,dalao 这翻译666

MinGuoGuo commented 4 days ago

@chenjiahan dalao,will this be fixed as a bug in future versions

笑死了哥,dalao 这翻译666

你就说能不能看懂吧