Browse Source

Merge pull request #702 from rollup/shared-target-config

Merge target options with main options.
ghi-672
Rich Harris 9 years ago
parent
commit
9b615469e0
  1. 13
      bin/runRollup.js
  2. 4
      test/cli/multiple-targets-shared-config/_config.js
  3. 6
      test/cli/multiple-targets-shared-config/_expected/cjs.js
  4. 1
      test/cli/multiple-targets-shared-config/_expected/cjs.js.map
  5. 4
      test/cli/multiple-targets-shared-config/_expected/es6.js
  6. 1
      test/cli/multiple-targets-shared-config/_expected/es6.js.map
  7. 1
      test/cli/multiple-targets-shared-config/main.js
  8. 14
      test/cli/multiple-targets-shared-config/rollup.config.js

13
bin/runRollup.js

@ -171,6 +171,17 @@ function execute ( options, command ) {
}
}
function clone ( object ) {
return assign( {}, object );
}
function assign ( target, source ) {
Object.keys( source ).forEach( function ( key ) {
target[ key ] = source[ key ];
});
return target;
}
function bundle ( options ) {
if ( !options.entry ) {
handleError({ code: 'MISSING_INPUT_OPTION' });
@ -185,7 +196,7 @@ function bundle ( options ) {
var result = null;
options.targets.forEach( function ( target ) {
result = bundle.write(target);
result = bundle.write( assign( clone( options ), target ) );
});
return result;

4
test/cli/multiple-targets-shared-config/_config.js

@ -0,0 +1,4 @@
module.exports = {
description: 'uses shared config for each target',
command: 'rollup -c'
};

6
test/cli/multiple-targets-shared-config/_expected/cjs.js

@ -0,0 +1,6 @@
'use strict';
var main = 0;
module.exports = main;
//# sourceMappingURL=cjs.js.map

1
test/cli/multiple-targets-shared-config/_expected/cjs.js.map

@ -0,0 +1 @@
{"version":3,"file":"cjs.js","sources":["../main.js"],"sourcesContent":["export default 0;\n"],"names":[],"mappings":";;WAAe,CAAC,CAAC,;;"}

4
test/cli/multiple-targets-shared-config/_expected/es6.js

@ -0,0 +1,4 @@
var main = 0;
export default main;
//# sourceMappingURL=es6.js.map

1
test/cli/multiple-targets-shared-config/_expected/es6.js.map

@ -0,0 +1 @@
{"version":3,"file":"es6.js","sources":["../main.js"],"sourcesContent":["export default 0;\n"],"names":[],"mappings":"WAAe,CAAC,CAAC,;;"}

1
test/cli/multiple-targets-shared-config/main.js

@ -0,0 +1 @@
export default 0;

14
test/cli/multiple-targets-shared-config/rollup.config.js

@ -0,0 +1,14 @@
export default {
entry: 'main.js',
sourceMap: true,
targets: [
{
format: 'cjs',
dest: '_actual/cjs.js'
},
{
format: 'es6',
dest: '_actual/es6.js'
}
]
};
Loading…
Cancel
Save