diff --git a/src/Bundle.js b/src/Bundle.js index fa60b88..86e5a77 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -167,15 +167,17 @@ export default class Bundle { module.replacements[ '*' ] = namespaceName; } - const defaultExport = module.exports.default; + if ( module.needsDefault || module.needsAll && module.exports.default ) { + const defaultExport = module.exports.default; - // only create a new name if either - // a) it's an expression (`export default 42`) or - // b) it's a name that is reassigned to (`export var a = 1; a = 2`) - if ( defaultExport.declaredName && !defaultExport.isModified ) return; // TODO encapsulate check for whether we need synthetic default name + // only create a new name if either + // a) it's an expression (`export default 42`) or + // b) it's a name that is reassigned to (`export var a = 1; a = 2`) + if ( defaultExport && defaultExport.declaredName && !defaultExport.isModified ) return; // TODO encapsulate check for whether we need synthetic default name - const defaultName = getSafeName( module.suggestedNames.default ); - module.replacements.default = defaultName; + const defaultName = getSafeName( module.suggestedNames.default ); + module.replacements.default = defaultName; + } }); this.orderedModules.forEach( module => { diff --git a/src/Module.js b/src/Module.js index d231e56..bbaa219 100644 --- a/src/Module.js +++ b/src/Module.js @@ -277,6 +277,7 @@ export default class Module { const module = importDeclaration.module; if ( module.isExternal ) return null; + if ( importDeclaration.name === '*' ) return null; const exportDeclaration = module.exports[ importDeclaration.name ]; return module.findDeclaration( exportDeclaration.localName );