Open defghy opened 8 months ago
I use this solution to temp resolve this problem
renderNode(node: any) {
const h = this.$createElement // to replace vite's h
let compName = 'CNodeCommon'
if (isArray) {
compName = 'CNodeArray'
}
return <compName class="contraint-node" info={info} />
},
It's @vue/babel-sugar-inject-h
which work in webpack; for ObjectMethod|ClassMethod
'ObjectMethod|ClassMethod'(path) {
if (firstParamIsH(t, path) || !hasJSX(t, path) || isInsideJSXExpression(t, path)) {
return
}
const isRender = path.node.key.name === 'render'
path
.get('body')
.unshiftContainer(
'body',
t.variableDeclaration('const', [
t.variableDeclarator(
t.identifier('h'),
isRender
? t.memberExpression(t.identifier('arguments'), t.numericLiteral(0), true)
: t.memberExpression(t.thisExpression(), t.identifier('$createElement')),
),
]),
)
},
But in vite I use injectH: true
option, not work
use render function to create customElement;
webpack use vm.$createElement,context is this
vite use h function, context is the ui-lib's component
vite will show this error; Tried
jsx in setup
ormethods
both has same problemIn my case, webpack is more reasonable, because I cannot controll ui lib's component vue-tree lib: https://github.com/wsfe/vue-tree