Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

组件库是export default形式导出的编译报错#863

aWhver started this conversation inGeneral
Discussion options

Describe the bug

1、公司有自己的组件库开发团队,但是所有组件都是export default ,没有添加export {}/
2、使用插件处理时,最终编译后是这种import {AButton as __unplugin_components_1} from "/node_modules/.vite/deps/@a-button_lib_index__js.js?v=9f7b1eed";
3、但是文件a-button_lib_index__js.js里面导出的是这种形式export {
lib_default as default
// 如果添加了export { AButton } 这里会多一个下面的导出
lib_default as AButton
};
导致编译的时候直接报错:
SyntaxError: The requested module '/node_modules/.vite/deps/a-button_lib_index__js.js?v=9f7b1eed' does not provide an export named 'AButton
请问如何解决组件没有用export {}而是用export default的形式导出可以正常按需导入

Reproduction

Reproduction

System Info

windows

Used Package Manager

yarn

Validations

  • Follow ourCode of Conduct
  • Read theContributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is aminimal reproducible of the bug.
You must be logged in to vote

Replies: 1 comment

Comment options

(componentName)=>{if(componentName.startsWith('you-ui'))return{from:'@your-ui/button'}//  return '@your-ui/button'},

上面的2种写法自动转换成:

 import button from "@your-ui/button"

太多人问这个问题了,建议官方写在readme上

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
2 participants
@aWhver@shenjunjian
Converted from issue

This discussion was converted from issue #818 on July 18, 2025 00:30.


[8]ページ先頭

©2009-2025 Movatter.jp