Browse Source

change language to reflect the fact that conflicting namespaces are permitted, if discouraged

semi-dynamic-namespace-imports
Rich Harris 9 years ago
parent
commit
84cccae433
  1. 3
      src/Bundle.js
  2. 10
      test/function/double-named-export-from/_config.js

3
src/Bundle.js

@ -220,8 +220,7 @@ export default class Bundle {
const exportAllModule = this.moduleById.get( id );
keys( exportAllModule.exportsAll ).forEach( name => {
if ( name in module.exportsAll ) {
this.onwarn( `A module cannot have multiple exports with the same name ('${name}')` +
` from ${module.exportsAll[ name ] } and ${exportAllModule.exportsAll[ name ]}` );
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 ];
});

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

@ -1,15 +1,15 @@
const path = require('path');
const assert = require( 'assert' );
function normalize( file ) {
function normalize ( file ) {
return path.resolve( __dirname, file ).split( '\\' ).join( '/' );
}
module.exports = {
description: 'throws on duplicate export * from',
warnings(warnings) {
assert.equal( warnings[0], `A module cannot have multiple exports with the same name ('foo')` +
` from ${normalize( 'foo.js' )} and ${normalize( 'deep.js' )}` );
assert.equal( warnings.length, 1 );
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')}.`
]);
}
};

Loading…
Cancel
Save