Skip to content

Commit

Permalink
fix: Fixes #256, generate import with path transformed from imported (#…
Browse files Browse the repository at this point in the history
…345)

name instead of renamed local name
  • Loading branch information
chengjianhua authored and sorrycc committed Aug 27, 2019
1 parent 35982e2 commit 0bec7e9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/variable-declarator-renamed-import/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Button as AntButton } from 'antd';

const Button = 'Another Button';

const a = AntButton;
8 changes: 8 additions & 0 deletions test/fixtures/variable-declarator-renamed-import/expected.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 0bec7e9

Please sign in to comment.