From 5e1c7e9bd4d13ec053321fce279f4795437c7cb0 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 4 Oct 2015 14:03:31 -0400 Subject: [PATCH] fix --- src/Module.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Module.js b/src/Module.js index 18670b2..b540c22 100644 --- a/src/Module.js +++ b/src/Module.js @@ -539,12 +539,14 @@ export default class Module { const { start, end } = reference; const name = declaration.render( es6 ); - if ( reference.name !== name ) { - if ( reference.isShorthandProperty ) { - magicString.insert( end, `: ${name}` ); - } else { - magicString.overwrite( start, end, name, true ); - } + // the second part of this check is necessary because of + // namespace optimisation – name of `foo.bar` could be `bar` + if ( reference.name === name && name.length === reference.end - reference.start ) return; + + if ( reference.isShorthandProperty ) { + magicString.insert( end, `: ${name}` ); + } else { + magicString.overwrite( start, end, name, true ); } } });