diff --git a/src/resolver/findExportedComponentDefinition.js b/src/resolver/findExportedComponentDefinition.js index de1ff91cd09..3cf5c3ebc96 100644 --- a/src/resolver/findExportedComponentDefinition.js +++ b/src/resolver/findExportedComponentDefinition.js @@ -18,9 +18,6 @@ import resolveExportDeclaration from '../utils/resolveExportDeclaration'; import resolveToValue from '../utils/resolveToValue'; import resolveHOC from '../utils/resolveHOC'; -var ERROR_MULTIPLE_DEFINITIONS = - 'Multiple exported component definitions found.'; - function ignore() { return false; } @@ -84,11 +81,11 @@ export default function findExportedComponentDefinition( if (definitions.length === 0) { return false; } - if (definitions.length > 1 || definition) { - // If a file exports multiple components, ... complain! - throw new Error(ERROR_MULTIPLE_DEFINITIONS); + + definition = definitions.map(def => resolveDefinition(def, types)); + if (definition.length === 1) { + definition = definition.pop(); } - definition = resolveDefinition(definitions[0], types); return false; } @@ -125,10 +122,6 @@ export default function findExportedComponentDefinition( return false; } } - if (definition) { - // If a file exports multiple components, ... complain! - throw new Error(ERROR_MULTIPLE_DEFINITIONS); - } definition = resolveDefinition(path, types); return false; },