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

【非常严重】setup 脚本引入未使用的组件,编译不生成对应的组件js脚本,导致无法真机调试 #3721

Open
yxw007 opened this issue Jul 20, 2022 · 5 comments

Comments

@yxw007
Copy link

yxw007 commented Jul 20, 2022

问题描述
setup 脚本引入未使用的组件,编译不生成对应的组件js脚本,导致无法真机调试

复现步骤

  1. git clone https://github.com/yxw007/uniapp_issue.git
  2. git checkout ComponentDisplayIssus
  3. cd uniapp_issue
  4. yarn & yarn dev

预期结果
只要引入了对应组件就生成对应组件js脚本

实际结果
1

导致问题
2

系统信息:

  • 发行平台: 微信小程序
  • uni-app版本:3.0.0-alpha-3050120220706002(最新版也一样)

补充信息

@fxy060608
Copy link
Collaborator

没使用的组件就应该删除掉吧,为何还要保留着呢,
即使优化此问题,也应该是不生成json,wxml,wxss吧,而不是没使用,也把整个组件给生成了

@yxw007
Copy link
Author

yxw007 commented Jul 20, 2022

没使用的组件就应该删除掉吧,为何还要保留着呢, 即使优化此问题,也应该是不生成json,wxml,wxss吧,而不是没使用,也把整个组件给生成了

假如:按着你的设个思路走,既然都不生成组件js代码,那么为什么不把引入组件(不使用)的代码也给treeshaking掉呢?导致需要上层开发者要去手动删除呢?

场景:项目正在开发中,快速调整代码注释代码是很正常的吧,如果需要一个一个去删会不会让人觉得挺烦人的?
建议:开发模式可以保留,生产模式就直接把未使用的组件不生成,相关引入代码也tree shaking掉,这样就完美啦

@yxw007
Copy link
Author

yxw007 commented Jul 20, 2022

简单点说就是:要么就都生成,要么就都不生成(连引入代码都删除掉)

@yxw007
Copy link
Author

yxw007 commented Jul 20, 2022

还有一个问题,就是开发模式注释掉引入的组件,代码没有动态编译删除掉,需要重新遍历才可以

@Miboweixin
Copy link

如果写了平台编译的注释#ifndef MP-WEIXIN 这种注释,我是多个平台需要处理不同业务,也会出现上面的问题,这是一个bug

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

No branches or pull requests

3 participants