vuejs / jsx-vue2

monorepo for Babel / Vue JSX related packages
https://jsx-vue2-playground.netlify.app/
1.47k stars 96 forks source link

在 Rspack 中无法正常工作 #311

Closed Y80 closed 1 month ago

Y80 commented 7 months ago

问题描述

.vue 组件在 setup() {} 中返回了 JSX 组件,例如:

defineComponet({
  setup() {
    return () => <div>ok</div>
  }
})

经过插件编译之后,始终 const h = this.$createElement

image

Rspack 配置

image

期望

如果检测到是在 setup() 中,使用 getCurrentInstance()?.proxy 替换 this。或者使用 import { h } from 'vue'

其他

我猜应该是插件 @vue/babel-sugar-composition-api-render-instance 在 Rspack 中失效了。(Rspack 没有兼容其中某些 API?) 使用 Vite 时可以正常运行,h 是从 vue 依赖中导入的。

yejinjian commented 1 month ago

解决了吗?

Y80 commented 1 month ago

解决了吗?

好像解决了。应该是 Rspack 后来更新无意间修复了这个 BUG。

不过使用 .tsx / .jsx 的话是铁定没这个问题的。

image