-
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
Open
shaodahong
wants to merge
4
commits into
umijs:master
Choose a base branch
from
shaodahong:order
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: import order #459
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ coverage | |
lib | ||
*.log | ||
*.log.* | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
"use strict"; | ||
|
||
var _react = _interopRequireDefault(require("react")); | ||
|
||
var _reactDom = _interopRequireDefault(require("react-dom")); | ||
|
||
var _animation = _interopRequireDefault(require("antd/lib/animation")); | ||
|
||
require("antd/lib/button/style/2x"); | ||
|
||
var _button = _interopRequireDefault(require("antd/lib/button")); | ||
|
||
var _react = _interopRequireDefault(require("react")); | ||
|
||
var _reactDom = _interopRequireDefault(require("react-dom")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
ReactDOM.render(_react.default.createElement(_animation.default, null, _react.default.createElement(_button.default, null, "xxxx")), document.getElementById("react-container")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
"use strict"; | ||
|
||
require("antd/lib/button/style/2x"); | ||
|
||
var _button = _interopRequireDefault(require("antd/lib/button")); | ||
|
||
var _react = _interopRequireDefault(require("react")); | ||
|
||
var _reactDom = _interopRequireDefault(require("react-dom")); | ||
|
||
require("antd/lib/button/style/2x"); | ||
|
||
var _button = _interopRequireDefault(require("antd/lib/button")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
ReactDOM.render(_react.default.createElement("div", null, _react.default.createElement(_button.default, null, "xxxx")), document.getElementById('react-container')); | ||
ReactDOM.render(_react.default.createElement("div", null, _react.default.createElement(_button.default, null, "xxxx")), document.getElementById('react-container')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
"use strict"; | ||
|
||
var _message2 = _interopRequireDefault(require("antd/lib/message")); | ||
var _message = _interopRequireDefault(require("antd/lib/message")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
(0, _message2.default)('xxx'); | ||
(0, _message.default)('xxx'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
"use strict"; | ||
|
||
var _message2 = _interopRequireDefault(require("antd/lib/message")); | ||
var _message = _interopRequireDefault(require("antd/lib/message")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
_message2.default.success('xxx'); | ||
_message.default.success('xxx'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import 'polyfill'; | ||
import { Button } from 'antd'; | ||
|
||
console.log(Button); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
require("polyfill"); | ||
|
||
var _button = _interopRequireDefault(require("antd/lib/button")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
console.log(_button.default); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
"use strict"; | ||
|
||
var _end2 = require("stream/lib/end"); | ||
var start = _interopRequireWildcard(require("stream/lib/start")); | ||
|
||
var _start2 = require("stream/lib/start"); | ||
var end = _interopRequireWildcard(require("stream/lib/end")); | ||
|
||
(0, _start2.start)(); | ||
(0, _end2.end)(); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
|
||
start(); | ||
end(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
"use strict"; | ||
|
||
var _Toolbar2 = _interopRequireDefault(require("material-ui/Toolbar")); | ||
var _Toolbar = _interopRequireDefault(require("material-ui/Toolbar")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
(0, _Toolbar2.default)('xxx'); | ||
(0, _Toolbar.default)('xxx'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
"use strict"; | ||
|
||
require("antd/lib/button/style"); | ||
|
||
var _button = _interopRequireDefault(require("antd/lib/button")); | ||
|
||
var _react = _interopRequireDefault(require("react")); | ||
|
||
var _reactDom = _interopRequireDefault(require("react-dom")); | ||
|
||
require("antd/lib/button/style"); | ||
|
||
var _button = _interopRequireDefault(require("antd/lib/button")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
ReactDOM.render(_react.default.createElement("div", null, _react.default.createElement(_button.default, null, "xxxx")), document.getElementById('react-container')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
"use strict"; | ||
|
||
var _select = _interopRequireDefault(require("antd/lib/select")); | ||
|
||
var _abc = _interopRequireDefault(require("hilojs/abc")); | ||
|
||
var _class = _interopRequireDefault(require("hilojs/core/class")); | ||
|
||
var _select = _interopRequireDefault(require("antd/lib/select")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
if (_select.default) {} | ||
|
||
if (_class.default && _abc.default) {} | ||
if (_class.default && _abc.default) {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
那么作用域的内的都会替换跑完测试感觉是没什么大问题的,可能以前的一些修改没加测试用例就不好说