Browse Source

allow multiple export alls in entry module

better-aggressive
Rich-Harris 9 years ago
parent
commit
baa09c05c8
  1. 16
      src/Module.js
  2. 3
      test/function/export-all-multiple/_config.js
  3. 1
      test/function/export-all-multiple/bar.js
  4. 1
      test/function/export-all-multiple/foo.js
  5. 2
      test/function/export-all-multiple/main.js

16
src/Module.js

@ -690,17 +690,20 @@ export default class Module {
return otherModule.namespace();
}
return otherModule.traceExport( importDeclaration.name, this );
const declaration = otherModule.traceExport( importDeclaration.name );
if ( !declaration ) throw new Error( `Module ${otherModule.id} does not export ${importDeclaration.name} (imported by ${this.id})` );
return declaration;
}
return null;
}
traceExport ( name, importer ) {
traceExport ( name ) {
// export { foo } from './other'
const reexportDeclaration = this.reexports[ name ];
if ( reexportDeclaration ) {
return reexportDeclaration.module.traceExport( reexportDeclaration.localName, this );
return reexportDeclaration.module.traceExport( reexportDeclaration.localName );
}
const exportDeclaration = this.exports[ name ];
@ -710,14 +713,9 @@ export default class Module {
for ( let i = 0; i < this.exportAllModules.length; i += 1 ) {
const module = this.exportAllModules[i];
const declaration = module.traceExport( name, this );
const declaration = module.traceExport( name );
if ( declaration ) return declaration;
}
let errorMessage = `Module ${this.id} does not export ${name}`;
if ( importer ) errorMessage += ` (imported by ${importer.id})`;
throw new Error( errorMessage );
}
}

3
test/function/export-all-multiple/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'allows multiple export * statements'
};

1
test/function/export-all-multiple/bar.js

@ -0,0 +1 @@
export const BAR = 2;

1
test/function/export-all-multiple/foo.js

@ -0,0 +1 @@
export const FOO = 1;

2
test/function/export-all-multiple/main.js

@ -0,0 +1,2 @@
export * from './foo.js';
export * from './bar.js';
Loading…
Cancel
Save