From 88f373e10a3c927ae92e61ca840cbed6e175cb92 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 4 Oct 2015 12:50:07 -0400 Subject: [PATCH] more fixes --- src/Module.js | 1 + src/finalisers/shared/getExportBlock.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Module.js b/src/Module.js index 876fec0..e5c38a0 100644 --- a/src/Module.js +++ b/src/Module.js @@ -358,6 +358,7 @@ export default class Module { return { strongDependencies, weakDependencies }; } + // TODO this seems superfluous defaultName () { const defaultExport = this.exports.default; diff --git a/src/finalisers/shared/getExportBlock.js b/src/finalisers/shared/getExportBlock.js index 891fb0a..e475a6f 100644 --- a/src/finalisers/shared/getExportBlock.js +++ b/src/finalisers/shared/getExportBlock.js @@ -8,8 +8,13 @@ export default function getExportBlock ( bundle, exportMode, mechanism = 'return const prop = name === 'default' ? `['default']` : `.${name}`; const declaration = bundle.entryModule.traceExport( name ); - if ( declaration.isReassigned ) return null; - return `exports${prop} = ${declaration.render( false )};`; + const lhs = `exports${prop}`; + const rhs = declaration.render( false ); + + // prevent `exports.count = exports.count` + if ( lhs === rhs ) return null; + + return `${lhs} = ${rhs};`; }) .filter( Boolean ) .join( '\n' );