jsx-vue2 icon indicating copy to clipboard operation
jsx-vue2 copied to clipboard

在 Rspack 中无法正常工作

Open Y80 opened this issue 2 years ago • 0 comments

问题描述

.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 依赖中导入的。

Y80 avatar Nov 21 '23 08:11 Y80