diff --git a/src/utils/testForSideEffects.js b/src/utils/testForSideEffects.js index 9df2ef4..93d8cb8 100644 --- a/src/utils/testForSideEffects.js +++ b/src/utils/testForSideEffects.js @@ -82,10 +82,12 @@ export default function testForSideEffects ( node, scope, statement, strongDepen let subject = node[ modifierNodes[ node.type ] ]; while ( subject.type === 'MemberExpression' ) subject = subject.object; - const declaration = statement.module.trace( subject.name ); + if ( !scope.findDeclaration( subject.name ) ) { + const declaration = statement.module.trace( subject.name ); - if ( !declaration || declaration.isExternal || declaration.statement.isIncluded ) { - hasSideEffect = true; + if ( !declaration || declaration.isExternal || declaration.isUsed ) { + hasSideEffect = true; + } } } },