|
|
@ -339,23 +339,31 @@ export default class Bundle { |
|
|
|
// prepend bundle with internal namespaces
|
|
|
|
const indentString = magicString.getIndentString(); |
|
|
|
const namespaceBlock = this.internalNamespaceModules.map( module => { |
|
|
|
const exportKeys = keys( module.exports ); |
|
|
|
const exports = keys( module.exports ).map( key => { |
|
|
|
const exportDeclaration = module.exports[ key ]; |
|
|
|
|
|
|
|
return `var ${module.replacements['*']} = {\n` + |
|
|
|
exportKeys.map( key => { |
|
|
|
let actualModule = module; |
|
|
|
let exportDeclaration = module.exports[ key ]; |
|
|
|
|
|
|
|
// special case - `export { default as foo } from './foo'`
|
|
|
|
while ( exportDeclaration.linkedImport ) { |
|
|
|
actualModule = exportDeclaration.linkedImport.module; |
|
|
|
exportDeclaration = actualModule.exports[ exportDeclaration.linkedImport.name ]; |
|
|
|
} |
|
|
|
let localName = exportDeclaration.localName; |
|
|
|
localName = module.replacements[ localName ] || localName; |
|
|
|
return `${indentString}get ${key} () { return ${localName}; }`; |
|
|
|
}); |
|
|
|
|
|
|
|
let localName = exportDeclaration.localName; |
|
|
|
localName = actualModule.replacements[ localName ] || localName; |
|
|
|
return `${indentString}get ${key} () { return ${localName}; }`; // TODO...
|
|
|
|
}).join( ',\n' ) + |
|
|
|
const reexports = keys( module.reexports ).map( key => { |
|
|
|
let exportingModule = module; |
|
|
|
let actualKey = key; |
|
|
|
let reexport; |
|
|
|
|
|
|
|
while ( exportingModule.reexports[ key ] ) { |
|
|
|
reexport = exportingModule.reexports[ key ]; |
|
|
|
exportingModule = reexport.module; |
|
|
|
key = reexport.importedName; |
|
|
|
} |
|
|
|
|
|
|
|
key = exportingModule.replacements[ key ] || key; |
|
|
|
return `${indentString}get ${actualKey} () { return ${key}; }`; |
|
|
|
}); |
|
|
|
|
|
|
|
return `var ${module.replacements['*']} = {\n` + |
|
|
|
exports.concat( reexports ).join( ',\n' ) + |
|
|
|
`\n};\n\n`; |
|
|
|
}).join( '' ); |
|
|
|
|
|
|
|