diff --git a/src/Plugin.js b/src/Plugin.js index 61cb7d81..c8650418 100644 --- a/src/Plugin.js +++ b/src/Plugin.js @@ -101,13 +101,24 @@ export default class Plugin { const file = (path && path.hub && path.hub.file) || (state && state.file); const { types } = this; const pluginState = this.getPluginState(state); + const checkScope = targetNode => + pluginState.specified[targetNode.name] && // eslint-disable-line + path.scope.hasBinding(targetNode.name) && // eslint-disable-line + types.isImportSpecifier(path.scope.getBinding(targetNode.name).path); // eslint-disable-line + props.forEach(prop => { - if (!types.isIdentifier(node[prop])) return; - if ( - pluginState.specified[node[prop].name] && - types.isImportSpecifier(path.scope.getBinding(node[prop].name).path) - ) { + if (types.isIdentifier(node[prop]) && checkScope(node[prop])) { node[prop] = this.importMethod(pluginState.specified[node[prop].name], file, pluginState); // eslint-disable-line + } else if (types.isSequenceExpression(node[prop])) { + node[prop].expressions.forEach((expressionNode, index) => { + if (types.isIdentifier(expressionNode) && checkScope(expressionNode)) { + node[prop].expressions[index] = this.importMethod( + pluginState.specified[expressionNode.name], + file, + pluginState, + ); // eslint-disable-line + } + }); } }); }