Browse Source

stop false missing export errors

contingency-plan
Rich-Harris 9 years ago
parent
commit
19c71ff051
  1. 37
      src/Module.js

37
src/Module.js

@ -444,13 +444,14 @@ export default class Module {
markExport ( name, suggestedName, importer ) { markExport ( name, suggestedName, importer ) {
const reexport = this.reexports[ name ]; const reexport = this.reexports[ name ];
const exportDeclaration = this.exports[ name ];
if ( reexport ) { if ( reexport ) {
reexport.isUsed = true; reexport.isUsed = true;
reexport.module.markExport( reexport.localName, suggestedName, this ); reexport.module.markExport( reexport.localName, suggestedName, this );
} }
const exportDeclaration = this.exports[ name ]; else if ( exportDeclaration ) {
if ( exportDeclaration ) {
exportDeclaration.isUsed = true; exportDeclaration.isUsed = true;
if ( name === 'default' ) { if ( name === 'default' ) {
this.needsDefault = true; this.needsDefault = true;
@ -458,28 +459,30 @@ export default class Module {
return exportDeclaration.statement.mark(); return exportDeclaration.statement.mark();
} }
return this.mark( exportDeclaration.localName ); this.mark( exportDeclaration.localName );
} }
// See if there exists an export delegate that defines `name`. else {
let i; // See if there exists an export delegate that defines `name`.
for ( i = 0; i < this.exportAlls.length; i += 1 ) { let i;
const declaration = this.exportAlls[i]; for ( i = 0; i < this.exportAlls.length; i += 1 ) {
const declaration = this.exportAlls[i];
if ( declaration.module.exports[ name ] ) { if ( declaration.module.exports[ name ] ) {
// It's found! This module exports `name` through declaration. // It's found! This module exports `name` through declaration.
// It is however not imported into this scope. // It is however not imported into this scope.
this.exportDelegates[ name ] = declaration; this.exportDelegates[ name ] = declaration;
declaration.module.markExport( name ); declaration.module.markExport( name );
declaration.statement.dependsOn[ name ] = declaration.statement.dependsOn[ name ] =
declaration.statement.stronglyDependsOn[ name ] = true; declaration.statement.stronglyDependsOn[ name ] = true;
return; return;
}
} }
}
throw new Error( `Module ${this.id} does not export ${name} (imported by ${importer.id})` ); throw new Error( `Module ${this.id} does not export ${name} (imported by ${importer.id})` );
}
} }
parse ( ast ) { parse ( ast ) {

Loading…
Cancel
Save