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. 6
      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 ); const exportAllModule = this.moduleById.get( id );
keys( exportAllModule.exportsAll ).forEach( name => { keys( exportAllModule.exportsAll ).forEach( name => {
if ( name in module.exportsAll ) { if ( name in module.exportsAll ) {
this.onwarn( `A module cannot have multiple exports with the same name ('${name}')` + this.onwarn( `Conflicting namespaces: ${module.id} re-exports '${name}' from both ${module.exportsAll[ name ]} (will be ignored) and ${exportAllModule.exportsAll[ name ]}.` );
` from ${module.exportsAll[ name ] } and ${exportAllModule.exportsAll[ name ]}` );
} }
module.exportsAll[ name ] = exportAllModule.exportsAll[ name ]; module.exportsAll[ name ] = exportAllModule.exportsAll[ name ];
}); });

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

@ -8,8 +8,8 @@ function normalize( file ) {
module.exports = { module.exports = {
description: 'throws on duplicate export * from', description: 'throws on duplicate export * from',
warnings ( warnings ) { warnings ( warnings ) {
assert.equal( warnings[0], `A module cannot have multiple exports with the same name ('foo')` + assert.deepEqual( warnings, [
` from ${normalize( 'foo.js' )} and ${normalize( 'deep.js' )}` ); `Conflicting namespaces: ${normalize('main.js')} re-exports 'foo' from both ${normalize('foo.js')} (will be ignored) and ${normalize('deep.js')}.`
assert.equal( warnings.length, 1 ); ]);
} }
}; };

Loading…
Cancel
Save