Browse Source

fixes

contingency-plan
Rich-Harris 10 years ago
parent
commit
35661e1f39
  1. 14
      src/Bundle.js
  2. 5
      src/finalisers/shared/getExportBlock.js

14
src/Bundle.js

@ -171,7 +171,6 @@ export default class Bundle {
if ( 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;
}
@ -201,7 +200,16 @@ export default class Bundle {
const otherModule = importDeclaration.module;
if ( otherModule.isExternal ) {
// TODO ES6
if ( es6 ) throw new Error( 'TODO ES6' );
if ( importDeclaration.name === 'default' ) {
return otherModule.needsNamed ?
`${otherModule.name}__default` :
otherModule.name;
}
// TODO namespaces
return `${otherModule.name}.${importDeclaration.name}`;
}
@ -214,7 +222,7 @@ export default class Bundle {
// with getCanonicalName)
function getSafeName ( name ) {
while ( conflicts[ name ] ) {
while ( definers[ name ] || conflicts[ name ] ) { // TODO this seems wonky
name = `_${name}`;
}

5
src/finalisers/shared/getExportBlock.js

@ -1,6 +1,9 @@
export default function getExportBlock ( bundle, exportMode, mechanism = 'return' ) {
if ( exportMode === 'default' ) {
return `${mechanism} ${bundle.entryModule.replacements.default};`;
const defaultExport = bundle.entryModule.exports.default;
let defaultExportName = bundle.entryModule.replacements.default || defaultExport.statement.node.declaration.name;
return `${mechanism} ${defaultExportName};`;
}
return bundle.toExport

Loading…
Cancel
Save