Skip to content

Commit

Permalink
handle --amd.id and --amd.define
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Aug 20, 2017
1 parent d1c4eb9 commit 36e4cb8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/src/run/mergeOptions.js
Expand Up @@ -59,6 +59,12 @@ export default function mergeOptions ( config, command ) {

options.external = external;

if ( command.amd ) {
if ( !options.amd ) options.amd = {};
if ( command.amd.id ) options.amd.id = command.amd.id;
if ( command.amd.define ) options.amd.define = command.amd.define;
}

// Use any options passed through the CLI as overrides.
Object.keys( equivalents ).forEach( cliOption => {
if ( command.hasOwnProperty( cliOption ) ) {
Expand Down
7 changes: 7 additions & 0 deletions test/cli/samples/amd/_actual.js
@@ -0,0 +1,7 @@
define(function () { 'use strict';

var main = 42;

return main;

});
4 changes: 4 additions & 0 deletions test/cli/samples/amd/_config.js
@@ -0,0 +1,4 @@
module.exports = {
description: 'sets AMD module ID and define function',
command: 'rollup -i main.js -f amd --amd.id foo --amd.define defn'
};
7 changes: 7 additions & 0 deletions test/cli/samples/amd/_expected.js
@@ -0,0 +1,7 @@
defn('foo', function () { 'use strict';

var main = 42;

return main;

});
1 change: 1 addition & 0 deletions test/cli/samples/amd/main.js
@@ -0,0 +1 @@
export default 42;

0 comments on commit 36e4cb8

Please sign in to comment.