From f843f64360c5c5b0fd47d3106f907127bc85c660 Mon Sep 17 00:00:00 2001 From: David Konsumer Date: Wed, 30 Aug 2017 02:41:16 -0700 Subject: [PATCH 1/2] no error on multiple definitions (#213) --- src/resolver/findExportedComponentDefinition.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/resolver/findExportedComponentDefinition.js b/src/resolver/findExportedComponentDefinition.js index de1ff91cd09..321fbf62e3a 100644 --- a/src/resolver/findExportedComponentDefinition.js +++ b/src/resolver/findExportedComponentDefinition.js @@ -84,11 +84,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 +125,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; }, From e6d69cfa1f6581278fd64444a743134423158abc Mon Sep 17 00:00:00 2001 From: David Konsumer Date: Wed, 30 Aug 2017 05:12:56 -0700 Subject: [PATCH 2/2] appease linter on undefined error --- src/resolver/findExportedComponentDefinition.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/resolver/findExportedComponentDefinition.js b/src/resolver/findExportedComponentDefinition.js index 321fbf62e3a..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; }