-
Notifications
You must be signed in to change notification settings - Fork 405
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: import order #459
base: master
Are you sure you want to change the base?
fix: import order #459
Conversation
@sorrycc 看看这个。 |
} | ||
} | ||
|
||
Property(path, state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些为啥删了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
统一都在 ImportDeclaration
处理掉了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那就是按 import 来算,而不是按使用来算,那和之前的逻辑不一样了吧,比如 import * as antd from antd, <antd.Button /> 这种逻辑还能覆盖吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种 import 在 ImportDeclaration
确实处理不到, 但是属于 MemberExpression
,所以 MemberExpression
保留了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有 MemberExpression
不够,之前加的东西都是有场景用上的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得解这个问题的思路应该是记录删除的 import 的位置,然后再在相应的位置加回去。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以前的思路是找到使用的地方然后 remove -> unshift,现在 babel
提供了 replace refactor 的工具函数 replaceWithMultiple
,改掉 import
那么作用域的内的都会替换
只有 MemberExpression 不够,之前加的东西都是有场景用上的。
跑完测试感觉是没什么大问题的,可能以前的一些修改没加测试用例就不好说
Resolve #423