|
|
@ -162,7 +162,11 @@ export default class Bundle { |
|
|
|
this.orderedModules.forEach( module => { |
|
|
|
if ( !module.needsDefault && !module.needsAll ) return; |
|
|
|
|
|
|
|
if ( module.needsDefault ) { |
|
|
|
if ( module.needsAll ) { |
|
|
|
const namespaceName = getSafeName( module.suggestedNames[ '*' ] ); |
|
|
|
module.replacements[ '*' ] = namespaceName; |
|
|
|
} |
|
|
|
|
|
|
|
const defaultExport = module.exports.default; |
|
|
|
|
|
|
|
// only create a new name if either
|
|
|
@ -172,9 +176,6 @@ export default class Bundle { |
|
|
|
|
|
|
|
const defaultName = getSafeName( module.suggestedNames.default ); |
|
|
|
module.replacements.default = defaultName; |
|
|
|
} |
|
|
|
|
|
|
|
// TODO namespace
|
|
|
|
}); |
|
|
|
|
|
|
|
this.orderedModules.forEach( module => { |
|
|
@ -208,19 +209,21 @@ export default class Bundle { |
|
|
|
otherModule.name; |
|
|
|
} |
|
|
|
|
|
|
|
// TODO namespaces
|
|
|
|
if ( importDeclaration.name === '*' ) { |
|
|
|
return otherModule.name; |
|
|
|
} |
|
|
|
|
|
|
|
return `${otherModule.name}.${importDeclaration.name}`; |
|
|
|
} |
|
|
|
|
|
|
|
if ( importDeclaration.name === '*' ) { |
|
|
|
return otherModule.replacements[ '*' ]; |
|
|
|
} |
|
|
|
|
|
|
|
const exportDeclaration = otherModule.exports[ importDeclaration.name ]; |
|
|
|
return trace( otherModule, exportDeclaration.localName ); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO assign names to default/namespace exports, based on suggestions
|
|
|
|
// TODO trace bindings and rename within modules here (rather than later
|
|
|
|
// with getCanonicalName)
|
|
|
|
|
|
|
|
function getSafeName ( name ) { |
|
|
|
while ( definers[ name ] || conflicts[ name ] ) { // TODO this seems wonky
|
|
|
|
name = `_${name}`; |
|
|
@ -387,9 +390,10 @@ export default class Bundle { |
|
|
|
const namespaceBlock = this.internalNamespaceModules.map( module => { |
|
|
|
const exportKeys = keys( module.exports ); |
|
|
|
|
|
|
|
return `var ${module.namespaceName} = {\n` + |
|
|
|
return `var ${module.replacements['*']} = {\n` + |
|
|
|
exportKeys.map( key => { |
|
|
|
const localName = module.exports[ key ].localName; |
|
|
|
let localName = module.exports[ key ].localName; |
|
|
|
localName = module.replacements[ localName ] || localName; |
|
|
|
return `${indentString}get ${key} () { return ${localName}; }`; // TODO...
|
|
|
|
}).join( ',\n' ) + |
|
|
|
`\n};\n\n`; |
|
|
|