Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] vant cli 6.0 组件使用script setup进行开发 build指令打包后没有导出组件 #12729

Closed
wangKBweb opened this issue Mar 25, 2024 · 8 comments · Fixed by #12734

Comments

@wangKBweb
Copy link
Contributor

重现链接

https://github.com/wangKBweb/vant-cli-test

Vant 版本

@vant/cli 6.0

描述一下你遇到的问题。

组件开发使用script setup
build指令打包无法正常导出组件

重现步骤

yarn create vant-cli-app
project-name: xxx
vue3
less
yarn下载依赖
yarn build
此时打包发现 es/index.js 中是正常的
image

修改 src/demo-button/index.vue
删除export default
更改为script setup
image

yarn build
此时es/index.js中已经缺失了demo-button的引入与导出
image

设备/浏览器

No response

@wangKBweb
Copy link
Contributor Author

我找到了 #10741 这条issue 但我不确定是不是同样的问题 而且当年的版本应该比较低

@wChenonly
Copy link
Contributor

export function hasDefaultExport(code: string) {
return code.includes('export default') || code.includes('export { default }');
}

是因为这里判断了是不是默认导出
@chenjiahan 我们要不要在这里加上defineOptions定义name名字,因为现在是支持宏的

`<script setup>

defineOptions({ name: 'DemoButton' })
</script>`

@chenjiahan
Copy link
Member

嗯嗯,可以加一下判断

@wangKBweb
Copy link
Contributor Author

辛苦辛苦

@wangKBweb
Copy link
Contributor Author

@chenjiahan 佳涵哥 这个什么时候发版 如果短期不准备发的话 我先fork过去自己发一个用着哦

@wangKBweb
Copy link
Contributor Author

@chenjiahan 佳涵哥 cli什么时候发版呀

@chenjiahan
Copy link
Member

短期没计划,你可以先 fork 哈 ❤️

@wangKBweb
Copy link
Contributor Author

好的 辛苦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants