Skip to content

Commit

Permalink
Fix issue : In multiple configurations context, no bundle is created
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeTroopers committed Aug 4, 2017
1 parent b7a4edf commit 8d5224b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
26 changes: 15 additions & 11 deletions bin/src/runRollup.js
Expand Up @@ -92,6 +92,7 @@ export default function runRollup ( command ) {

const configs = require( config );
const normalized = Array.isArray( configs ) ? configs : [configs];
const promises = [];

normalized.forEach(options => {
if ( Object.keys( options ).length === 0 ) {
Expand All @@ -102,8 +103,12 @@ export default function runRollup ( command ) {
});
}

execute( options, command );
promises.push(new Promise((resolve) => {
execute(options, command);
resolve();
}));
});
Promise.all(promises).catch( handleError );

require.extensions[ '.js' ] = defaultLoader;
})
Expand Down Expand Up @@ -193,10 +198,10 @@ function execute ( options, command ) {

if ( command.watch ) {
if ( !options.entry || ( !options.dest && !options.targets ) ) {
handleError({
throw {
code: 'WATCHER_MISSING_INPUT_OR_OUTPUT',
message: 'must specify --input and --output when using rollup --watch'
});
};
}

try {
Expand Down Expand Up @@ -227,16 +232,16 @@ function execute ( options, command ) {
});
} catch ( err ) {
if ( err.code === 'MODULE_NOT_FOUND' ) {
handleError({
throw {
code: 'ROLLUP_WATCH_NOT_INSTALLED',
message: 'rollup --watch depends on the rollup-watch package, which could not be found. Install it with npm install -D rollup-watch'
});
};
}

handleError( err );
throw err;
}
} else {
bundle( options ).catch( handleError );
return bundle( options );
}
}

Expand Down Expand Up @@ -269,10 +274,10 @@ function bundle ( options ) {
}

if ( options.sourceMap && options.sourceMap !== 'inline' ) {
handleError({
throw {
code: 'MISSING_OUTPUT_OPTION',
message: 'You must specify an --output (-o) option when creating a file with a sourcemap'
});
};
}

return bundle.generate(options).then( ({ code, map }) => {
Expand All @@ -282,6 +287,5 @@ function bundle ( options ) {

process.stdout.write( code );
});
})
.catch( handleError );
});
}
4 changes: 4 additions & 0 deletions test/cli/multiple-configs/_config.js
@@ -0,0 +1,4 @@
module.exports = {
description: 'generates output file when multiple configurations are specified and one build fails',
command: 'rollup -c'
};
5 changes: 5 additions & 0 deletions test/cli/multiple-configs/_expected/bundle1.js
@@ -0,0 +1,5 @@
'use strict';

var main = 0;

module.exports = main;
1 change: 1 addition & 0 deletions test/cli/multiple-configs/main.js
@@ -0,0 +1 @@
export default 0;
14 changes: 14 additions & 0 deletions test/cli/multiple-configs/rollup.config.js
@@ -0,0 +1,14 @@
export default [{
entry: 'main.js',
format: 'cjs',
dest: '_actual/bundle1.js'
}, {
entry: 'main.js',
format: 'cjs',
plugins: [{
resolveId(id) {
throw new Error("Unexpected Exception");
}
}],
dest: '_actual/bundle2.js'
}];

0 comments on commit 8d5224b

Please sign in to comment.