Browse Source

ignore changes local to a function when determining global side-effects

better-aggressive
Rich-Harris 9 years ago
parent
commit
1dc3669b52
  1. 4
      src/utils/testForSideEffects.js

4
src/utils/testForSideEffects.js

@ -82,12 +82,14 @@ export default function testForSideEffects ( node, scope, statement, strongDepen
let subject = node[ modifierNodes[ node.type ] ];
while ( subject.type === 'MemberExpression' ) subject = subject.object;
if ( !scope.findDeclaration( subject.name ) ) {
const declaration = statement.module.trace( subject.name );
if ( !declaration || declaration.isExternal || declaration.statement.isIncluded ) {
if ( !declaration || declaration.isExternal || declaration.isUsed ) {
hasSideEffect = true;
}
}
}
},
leave ( node ) {
if ( node._scope ) scope = scope.parent;

Loading…
Cancel
Save