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

fix(cli): 修复easycom注入组件失败的问题 #5091

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

key9527
Copy link

@key9527 key9527 commented Aug 15, 2024

这里相对路径的写法,在自定义[ UNI_INPUT_DIR ] 时,会出现找不到组件,easycom注入失败的问题

这里相对路径的写法,在自定义[ UNI_INPUT_DIR ] 时,会出现找不到组件,easycom注入失败的问题
@key9527 key9527 changed the title Update easycom.ts fix(cli): 修复easycom注入组件失败的问题 Aug 15, 2024
@key9527
Copy link
Author

key9527 commented Aug 15, 2024

BUG场景:使用cli编译项目,自定义UNI_INPUT_DIR,且easycom注入的组件不在uni_modules或components里时

@Otto-J Otto-J self-assigned this Aug 20, 2024
@Otto-J
Copy link
Member

Otto-J commented Aug 21, 2024

感谢你提交 PR,我看到代码在尝试拓展 easycom 的选项,举一个更具体的使用场景吧,也方便测试和验证。

目前 easycom 规范中 https://uniapp.dcloud.net.cn/component/#easycom ,会在 uni_modules/ 和 components 查找,具体如何会查询不到,你放入到哪个目录了?

@key9527
Copy link
Author

key9527 commented Aug 23, 2024

@Otto-J
背景:将一个可视化构建的项目,转为cli方式,使之可以在linux服务器上通过CI/CD自动化部署发布。

场景步骤如下:
①现在有一个hbuildx构建的uniapp项目A(有一个与uni_modules同级目录的third_module组件库);
②通过cli命令,初始化一个uniapp项目B;
③将A里的所有文件(除 unpackage、node_modules )拷贝至 B 工程内根目录(保持扁平目录,这里没有新建src目录放进去)
④执行uni -p mp-weixin编译项目,因不在src目录下,此时需指定cross-env UNI_INPUT_DIR='./',但编译报错,显示easycom注入third_module组件时找不到文件

也就是说,全局变量UNI_INPUT_DIR会影响easycom寻找组件。

解决办法(二选一):
① 指定UNI_INPUT_DIR为绝对路径,比如mac下:cross-env UNI_INPUT_DIR=pwd uni -p mp-weixin
② 更新easycom,即上述提交的PR内容

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

Successfully merging this pull request may close these issues.

2 participants