diff --git a/src/Plugin.js b/src/Plugin.js index a49247f..ad07268 100644 --- a/src/Plugin.js +++ b/src/Plugin.js @@ -267,6 +267,16 @@ export default class Plugin { this.buildExpressionHandler(node, ['declaration'], path, state); } + ExportNamedDeclaration(path, state) { + const { node } = path; + // export { Button } => export { _Button } + if (node.source === null && node.declaration === null) { + node.specifiers.forEach(spec => { + this.buildExpressionHandler(spec, ['local'], path, state); + }); + } + } + BinaryExpression(path, state) { const { node } = path; this.buildExpressionHandler(node, ['left', 'right'], path, state); diff --git a/src/index.js b/src/index.js index f6de1a5..91f16c0 100644 --- a/src/index.js +++ b/src/index.js @@ -96,6 +96,7 @@ export default function ({ types }) { 'ExpressionStatement', 'ReturnStatement', 'ExportDefaultDeclaration', + 'ExportNamedDeclaration', 'BinaryExpression', 'NewExpression', 'ClassDeclaration', diff --git a/test/fixtures/export-name/actual.js b/test/fixtures/export-name/actual.js new file mode 100644 index 0000000..f059ad6 --- /dev/null +++ b/test/fixtures/export-name/actual.js @@ -0,0 +1,4 @@ +import { DatePicker } from 'antd'; +export { DatePicker }; + +// export { DatePicker as DatePicker1 }; \ No newline at end of file diff --git a/test/fixtures/export-name/expected.js b/test/fixtures/export-name/expected.js new file mode 100644 index 0000000..6f23ce8 --- /dev/null +++ b/test/fixtures/export-name/expected.js @@ -0,0 +1,15 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "DatePicker", { + enumerable: true, + get: function get() { + return _datePicker.default; + } +}); + +var _datePicker = _interopRequireDefault(require("antd/lib/date-picker")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file