Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) rollup vue package
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) rollup vue package
我想尝试汇总一个 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>
和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()
]
};
但是我在终端上收到这个错误:
[!] 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)
如果你能帮助我,我将不胜感激。
问题出在 @rollup/plugin-typescript
卸载@rollup/plugin-typescript 并改为安装rollup-plugin-typescript2
。
我想尝试汇总一个 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>
和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()
]
};
但是我在终端上收到这个错误:
[!] 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)
如果你能帮助我,我将不胜感激。
问题出在 @rollup/plugin-typescript
卸载@rollup/plugin-typescript 并改为安装rollup-plugin-typescript2
。