Ami*_*ani 6 javascript rollup vue.js
我想尝试汇总一个 vue 组件库。但我在类型检查时遇到错误。我尝试更新打字稿,正如这里提到的,但它不起作用。这是我的代码和package.json
我的组件代码,已导出为Button
<template>
button
>{{ children }}</button>
</template>
<script lang="tsx">
declare type IconMode =
| {
iconMode?: "without-icon";
}
| {
iconMode: "with-icon" | "icon-only";
iconName: string;
};
...
</script>
Run Code Online (Sandbox Code Playgroud)
rollup.config.js 是:
import commonjs from "@rollup/plugin-commonjs";
import vue from "rollup-plugin-vue";
import buble from "@rollup/plugin-buble";
import typescript from "@rollup/plugin-typescript";
export default {
input: "src/index.ts",
output: {
name: "Button",
exports: "named"
},
plugins: [
typescript(),
vue({
css: true,
compileTemplate: true
}),
commonjs()
]
};
Run Code Online (Sandbox Code Playgroud)
但我在终端上收到此错误:
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/Components/Button.vue?vue&type=script&lang.tsx (18:8)
18 declare type IconMode =
^
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
Run Code Online (Sandbox Code Playgroud)
如果你能帮助我,我将不胜感激。
| 归档时间: |
|
| 查看次数: |
13732 次 |
| 最近记录: |