diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index fa8665ffde50..54d86689fd3f 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -46,6 +46,9 @@ childKeys.EachBlock = childKeys.IfBlock = ['children', 'else']; childKeys.Attribute = ['value']; childKeys.ExportNamedDeclaration = ['declaration', 'specifiers']; +// There is no datatype that describes only the compound operators so we create this list here +const compoundAssignmentOperators = ["+=" , "-=" ,"*=", "/=" ,"%=" ,"**=", "<<=" ,">>=", ">>>=", "|=" ,"^=" ,"&="]; + function remove_node( code: MagicString, start: number, @@ -1265,10 +1268,18 @@ export default class Component { } if (node.type === 'AssignmentExpression') { - extract_identifiers(get_object(node.left)).forEach(node => { + const left = get_object(node.left); + + extract_identifiers(left).forEach(node => { assignee_nodes.add(node); assignees.add(node.name); }); + + + + if (compoundAssignmentOperators.findIndex(op => op === node.operator) !== -1) { + dependencies.add(left.name); + } } else if (node.type === 'UpdateExpression') { const identifier = get_object(node.argument); assignees.add(identifier.name);