wonderful-panda/vue-tsx-support

使用 rollup 打包出现问题

wjkang opened this issue · 2 comments

import { VNode } from 'vue'
import { Component, Prop,Vue } from 'vue-property-decorator'
import * as tsx from 'vue-tsx-support'

type MyComponentProps = {
  text: string
  important?: boolean
}

@Component
export default class MyComponent extends tsx.Component<MyComponentProps> {
  @Prop({ type: String, required: true })
  text!: string
  @Prop(Boolean)
  important?: boolean

  get className() {
    return this.important ? 'label-important' : 'label-normal'
  }
  onClick(event: MouseEvent) {
    this.$emit('ok', event)
  }
  render(): VNode {
    return (
      <span class={this.className} onClick={this.onClick}>
        {this.text}
      </span>
    )
  }
}

显示如下

Component is not exported by node_modules\vue-tsx-support\lib\index.js
 9: 
10: @Component
11: export default class MyComponent extends tsx.Component<MyComponentProps> {
                                                 ^
12:   @Prop({ type: String, required: true })
13:   text!: string
src\components\Test\Test.tsx

已经用了rollup-plugin-commonjs

已解决

commonjs({
        namedExports: {
          'node_modules/vue-tsx-support/lib/index.js': ['Component'],
        },
      })