rsbuild: [Bug]: About Vue 3 hot update

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

详细问题可到仓库查看

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 31 (9 by maintainers)

Most upvoted comments

@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

It seems that there is a problem with rspack’s updatedModules calculation when sourcemap is included.

There is no change in the content or sourcemap (sourcemap is a new object, but the actual content has not changed) of App.vue.js?vue&type=script, but it is still added to updatedModules.

Addition:

  • When I only return content in vue-loader without sourcemap, it is normal.
  • It’s also normal when I add additional js loaders to just return the content.

20240926-163708

20240926-163912

Reproduce demo(can compare webpack / test loader): https://github.com/9aoy/rspack-issue-reproduce/tree/main/rspack-vue

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

笑死了哥,dalao 这翻译666

你就说能不能看懂吧

Unfortunately, I am not familiar with the HMR API of Webpack/Rspack. Since unplugin-vue is an open-source project, I believe that others can contribute to it as well.

See https://github.com/unplugin/unplugin-vue/issues/162#issuecomment-2254275628

Great!

The thing is, vue-loader seems like it’s in a low priority maintenance mode and there aren’t any signals or activity from core maintainers on long standing issues. Everything seems focused on Vite support and it’s a shame that crucial element for Vue usage in Rspack/Rsbuild is left to unmaintained dependancy and still relying on Webpack as main dependancy.

If this component can be switched to unplugin-vue, I think Rspack/Rsbuild could benefit from that, and this will also affect other parts such as Nuxt, greater adoption rate, etc.

I’m open to switching to unplugin-vue since it’s better maintained than vue-loader.

HMR is still a blocking point, it would be great if anyone would add Rspack HMR support to unplugin-vue.

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