diff --git a/bin/runRollup.js b/bin/runRollup.js index 0ace1ee..748ec1a 100644 --- a/bin/runRollup.js +++ b/bin/runRollup.js @@ -39,7 +39,9 @@ function bundle ( options, method ) { }).then( function ( bundle ) { var generateOptions = { dest: options.output, - format: options.format + format: options.format, + moduleId: options.id, + moduleName: options.name }; if ( options.output ) { diff --git a/test/cli/module-name/_config.js b/test/cli/module-name/_config.js new file mode 100644 index 0000000..49c1fa4 --- /dev/null +++ b/test/cli/module-name/_config.js @@ -0,0 +1,4 @@ +module.exports = { + description: 'generates UMD export with correct moduleName', + command: 'rollup main.js --format umd --name myBundle' +} diff --git a/test/cli/module-name/_expected.js b/test/cli/module-name/_expected.js new file mode 100644 index 0000000..b5aa08a --- /dev/null +++ b/test/cli/module-name/_expected.js @@ -0,0 +1,11 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + global.myBundle = factory(); +}(this, function () { 'use strict'; + + var main = 42; + + return main; + +})); diff --git a/test/cli/module-name/main.js b/test/cli/module-name/main.js new file mode 100644 index 0000000..7a4e8a7 --- /dev/null +++ b/test/cli/module-name/main.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/test.js b/test/test.js index 28bf18f..02a92d3 100644 --- a/test/test.js +++ b/test/test.js @@ -295,6 +295,20 @@ describe( 'rollup', function () { unintendedError ? done( unintendedError ) : done(); } + + else if ( config.result ) { + try { + config.result( code ); + } catch ( err ) { + done( err ); + } + } + + else { + var expected = sander.readFileSync( '_expected.js' ).toString(); + assert.equal( code.trim(), expected.trim() ); + done(); + } }); }); });