diff --git a/src/Bundle.js b/src/Bundle.js index 4c2f5a8..1f7c78a 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -26,6 +26,8 @@ export default class Bundle { }); } + this.failOnExportAllDup = Boolean( options.failOnExportAllDup ); + this.plugins = ensureArray( options.plugins ); this.plugins.forEach( plugin => { @@ -211,6 +213,9 @@ export default class Bundle { this.moduleById.set( id, module ); return this.fetchAllDependencies( module ).then( () => { + if ( !this.failOnExportAllDup ) { + return module; + } module.exportsAll = blank(); keys( module.exports ).forEach( name => { module.exportsAll[name] = module.id; diff --git a/src/rollup.js b/src/rollup.js index a9c50fd..5399dc3 100644 --- a/src/rollup.js +++ b/src/rollup.js @@ -31,7 +31,8 @@ const ALLOWED_KEYS = [ 'sourceMapFile', 'targets', 'treeshake', - 'useStrict' + 'useStrict', + 'failOnExportAllDup' ]; export function rollup ( options ) { diff --git a/test/function/double-named-export-from/_config.js b/test/function/double-named-export-from/_config.js index 1b402d3..0aaa1f5 100644 --- a/test/function/double-named-export-from/_config.js +++ b/test/function/double-named-export-from/_config.js @@ -7,6 +7,9 @@ function normalize( file ) { module.exports = { description: 'throws on duplicate export * from', + options: { + failOnExportAllDup: true + }, error: err => { assert.equal( err.message, `A module cannot have multiple exports with the same name ('foo')` + ` from ${normalize( 'foo.js' )} and ${normalize( 'deep.js' )}` ); diff --git a/test/test.js b/test/test.js index 30ec5f2..6bd60b1 100644 --- a/test/test.js +++ b/test/test.js @@ -76,7 +76,7 @@ describe( 'rollup', function () { return rollup.rollup({ entry: 'x', plUgins: [] }).then( function () { throw new Error( 'Missing expected error' ); }, function ( err ) { - assert.equal( err.message, 'Unexpected key \'plUgins\' found, expected one of: acorn, banner, cache, dest, entry, exports, external, footer, format, globals, indent, intro, moduleId, moduleName, noConflict, onwarn, outro, plugins, preferConst, sourceMap, sourceMapFile, targets, treeshake, useStrict' ); + assert.equal( err.message, 'Unexpected key \'plUgins\' found, expected one of: acorn, banner, cache, dest, entry, exports, external, footer, format, globals, indent, intro, moduleId, moduleName, noConflict, onwarn, outro, plugins, preferConst, sourceMap, sourceMapFile, targets, treeshake, useStrict, failOnExportAllDup' ); }); }); });