使用Typescript构建纯Vue组件的最佳方法是什么

abr*_*das 5 publish typescript vue.js lib

我正在使用Typescript,Vue,webpack和lerna构建新项目来管理相关软件包。我的项目结构为:

/packages
    /lib-vue-components
    /lib-ts-components
   /app
Run Code Online (Sandbox Code Playgroud)

lib-vue-components 旨在成为可重用的组件,这些组件将在我的应用程序中的任何其他Vue组件中使用:即

import {MyComponent} from "lib-vue-components"

@Component({components: MyComponent})
class AppComponent extends Vue {
        ....
        })
Run Code Online (Sandbox Code Playgroud)

我认为有两种方法:

  1. 不要将lib-vue-components构建为单独的构建,只能直接使用源代码,并与App项目一起构建所有内容。这是最简单的方法,但不允许将lib-vue-comonenets公开到npm。

2)分别构建lib-vue-components,然后在App projec中将其用作外部libt。这对我来说似乎是最好的方式,但是我不确定如何构建纯vue + typescript组件库,因为webpack总是向输出包中添加很多代码(即它本身添加了Vue)。

您是否有任何收据/想法,在这种情况下哪种方法最好?