diff --git a/package.json b/package.json index 98a1e798..9410bd84 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "debug": "umi-tools test", "lint": "eslint --ext .js src", "coveralls": "cat ./coverage/lcov.info | coveralls", - "prepack": "npm run build" + "prepack": "npm run build" }, "pre-commit": [ "lint" diff --git a/src/Plugin.js b/src/Plugin.js index edef59e8..4fda416c 100644 --- a/src/Plugin.js +++ b/src/Plugin.js @@ -111,7 +111,7 @@ export default class Plugin { if (pluginState.specified[node[prop].name] && path.scope.hasBinding(node[prop].name) && path.scope.getBinding(node[prop].name).path.type === 'ImportSpecifier') { - node[prop] = this.importMethod(node[prop].name, file, pluginState); // eslint-disable-line + node[prop] = this.importMethod(pluginState.specified[node[prop].name], file, pluginState); // eslint-disable-line } } diff --git a/test/fixtures/variable-declarator-renamed-import/actual.js b/test/fixtures/variable-declarator-renamed-import/actual.js new file mode 100644 index 00000000..e840343a --- /dev/null +++ b/test/fixtures/variable-declarator-renamed-import/actual.js @@ -0,0 +1,5 @@ +import { Button as AntButton } from 'antd'; + +const Button = 'Another Button'; + +const a = AntButton; diff --git a/test/fixtures/variable-declarator-renamed-import/expected.js b/test/fixtures/variable-declarator-renamed-import/expected.js new file mode 100644 index 00000000..e384657f --- /dev/null +++ b/test/fixtures/variable-declarator-renamed-import/expected.js @@ -0,0 +1,8 @@ +"use strict"; + +var _button = _interopRequireDefault(require("antd/lib/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Button = 'Another Button'; +var a = _button.default;