|
@ -77,7 +77,13 @@ export default class Module { |
|
|
|
|
|
|
|
|
else { |
|
|
else { |
|
|
node.specifiers.forEach( specifier => { |
|
|
node.specifiers.forEach( specifier => { |
|
|
this.reexports[ specifier.exported.name ] = { |
|
|
const name = specifier.exported.name; |
|
|
|
|
|
|
|
|
|
|
|
if ( this.exports[ name ] || this.reexports[ name ] ) { |
|
|
|
|
|
throw new Error( `A module cannot have multiple exports with the same name ('${name}')` ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.reexports[ name ] = { |
|
|
start: specifier.start, |
|
|
start: specifier.start, |
|
|
source, |
|
|
source, |
|
|
localName: specifier.local.name, |
|
|
localName: specifier.local.name, |
|
@ -93,6 +99,11 @@ export default class Module { |
|
|
else if ( node.type === 'ExportDefaultDeclaration' ) { |
|
|
else if ( node.type === 'ExportDefaultDeclaration' ) { |
|
|
const identifier = ( node.declaration.id && node.declaration.id.name ) || node.declaration.name; |
|
|
const identifier = ( node.declaration.id && node.declaration.id.name ) || node.declaration.name; |
|
|
|
|
|
|
|
|
|
|
|
if ( this.exports.default ) { |
|
|
|
|
|
// TODO indicate location
|
|
|
|
|
|
throw new Error( 'A module can only have one default export' ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.exports.default = { |
|
|
this.exports.default = { |
|
|
localName: 'default', |
|
|
localName: 'default', |
|
|
identifier |
|
|
identifier |
|
@ -129,6 +140,10 @@ export default class Module { |
|
|
const localName = specifier.local.name; |
|
|
const localName = specifier.local.name; |
|
|
const exportedName = specifier.exported.name; |
|
|
const exportedName = specifier.exported.name; |
|
|
|
|
|
|
|
|
|
|
|
if ( this.exports[ exportedName ] || this.reexports[ exportedName ] ) { |
|
|
|
|
|
throw new Error( `A module cannot have multiple exports with the same name ('${exportedName}')` ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.exports[ exportedName ] = { localName }; |
|
|
this.exports[ exportedName ] = { localName }; |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|