|
@ -45,6 +45,36 @@ describe( 'rollup', function () { |
|
|
it( 'has a rollup method', function () { |
|
|
it( 'has a rollup method', function () { |
|
|
assert.equal( typeof rollup.rollup, 'function' ); |
|
|
assert.equal( typeof rollup.rollup, 'function' ); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it( 'fails without options or options.entry', function () { |
|
|
|
|
|
assert.throws( function () { |
|
|
|
|
|
rollup.rollup(); |
|
|
|
|
|
}, /must supply options\.entry/ ); |
|
|
|
|
|
|
|
|
|
|
|
assert.throws( function () { |
|
|
|
|
|
rollup.rollup({}); |
|
|
|
|
|
}, /must supply options\.entry/ ); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe( 'bundle.write()', function () { |
|
|
|
|
|
it( 'fails without options or options.dest', function () { |
|
|
|
|
|
return rollup.rollup({ |
|
|
|
|
|
entry: 'x', |
|
|
|
|
|
resolveId: function () { return 'test'; }, |
|
|
|
|
|
load: function () { |
|
|
|
|
|
return '// empty'; |
|
|
|
|
|
} |
|
|
|
|
|
}).then( function ( bundle ) { |
|
|
|
|
|
assert.throws( function () { |
|
|
|
|
|
bundle.write(); |
|
|
|
|
|
}, /must supply options\.dest/ ); |
|
|
|
|
|
|
|
|
|
|
|
assert.throws( function () { |
|
|
|
|
|
bundle.write({}); |
|
|
|
|
|
}, /must supply options\.dest/ ); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
describe( 'function', function () { |
|
|
describe( 'function', function () { |
|
@ -80,22 +110,22 @@ describe( 'rollup', function () { |
|
|
format: 'cjs' |
|
|
format: 'cjs' |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
if ( config.error ) { |
|
|
if ( config.generateError ) { |
|
|
unintendedError = new Error( 'Expected an error while generating output' ); |
|
|
unintendedError = new Error( 'Expected an error while generating output' ); |
|
|
} |
|
|
} |
|
|
} catch ( err ) { |
|
|
} catch ( err ) { |
|
|
if ( config.error ) { |
|
|
if ( config.generateError ) { |
|
|
config.error( err ); |
|
|
config.generateError( err ); |
|
|
} else { |
|
|
} else { |
|
|
unintendedError = err; |
|
|
unintendedError = err; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ( unintendedError ) throw unintendedError; |
|
|
if ( unintendedError ) throw unintendedError; |
|
|
|
|
|
if ( config.error || config.generateError ) return; |
|
|
|
|
|
|
|
|
var code; |
|
|
var code; |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
if ( config.babel ) { |
|
|
if ( config.babel ) { |
|
|
code = babel.transform( result.code, { |
|
|
code = babel.transform( result.code, { |
|
|
blacklist: [ 'es6.modules' ], |
|
|
blacklist: [ 'es6.modules' ], |
|
@ -130,13 +160,6 @@ describe( 'rollup', function () { |
|
|
|
|
|
|
|
|
if ( config.exports ) config.exports( module.exports ); |
|
|
if ( config.exports ) config.exports( module.exports ); |
|
|
if ( config.bundle ) config.bundle( bundle ); |
|
|
if ( config.bundle ) config.bundle( bundle ); |
|
|
} catch ( err ) { |
|
|
|
|
|
if ( config.error ) { |
|
|
|
|
|
config.error( err ); |
|
|
|
|
|
} else { |
|
|
|
|
|
unintendedError = err; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( config.show || unintendedError ) { |
|
|
if ( config.show || unintendedError ) { |
|
|
console.log( code + '\n\n\n' ); |
|
|
console.log( code + '\n\n\n' ); |
|
|