Browse Source

Merge branch 'fail-exports-all-dup'

semi-dynamic-namespace-imports
Rich Harris 9 years ago
parent
commit
9c18b513f5
  1. 18
      src/Bundle.js
  2. 15
      test/function/double-named-export-from/_config.js
  3. 1
      test/function/double-named-export-from/bar.js
  4. 1
      test/function/double-named-export-from/deep.js
  5. 1
      test/function/double-named-export-from/foo.js
  6. 2
      test/function/double-named-export-from/main.js

18
src/Bundle.js

@ -210,7 +210,23 @@ export default class Bundle {
this.modules.push( module );
this.moduleById.set( id, module );
return this.fetchAllDependencies( module ).then( () => module );
return this.fetchAllDependencies( module ).then( () => {
module.exportsAll = blank();
keys( module.exports ).forEach( name => {
module.exportsAll[name] = module.id;
});
module.exportAllSources.forEach( source => {
const id = module.resolvedIds[ source ];
const exportAllModule = this.moduleById.get( id );
keys( exportAllModule.exportsAll ).forEach( name => {
if ( name in module.exportsAll ) {
this.onwarn( `Conflicting namespaces: ${module.id} re-exports '${name}' from both ${module.exportsAll[ name ]} (will be ignored) and ${exportAllModule.exportsAll[ name ]}.` );
}
module.exportsAll[ name ] = exportAllModule.exportsAll[ name ];
});
});
return module;
});
});
}

15
test/function/double-named-export-from/_config.js

@ -0,0 +1,15 @@
const path = require('path');
const assert = require( 'assert' );
function normalize ( file ) {
return path.resolve( __dirname, file ).split( '\\' ).join( '/' );
}
module.exports = {
description: 'throws on duplicate export * from',
warnings ( warnings ) {
assert.deepEqual( warnings, [
`Conflicting namespaces: ${normalize('main.js')} re-exports 'foo' from both ${normalize('foo.js')} (will be ignored) and ${normalize('deep.js')}.`
]);
}
};

1
test/function/double-named-export-from/bar.js

@ -0,0 +1 @@
export * from './deep.js';

1
test/function/double-named-export-from/deep.js

@ -0,0 +1 @@
export var foo = 2;

1
test/function/double-named-export-from/foo.js

@ -0,0 +1 @@
export var foo = 1;

2
test/function/double-named-export-from/main.js

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