|
|
@ -1,6 +1,6 @@ |
|
|
|
import { basename } from './utils/path.js'; |
|
|
|
import { writeFile } from './utils/fs.js'; |
|
|
|
import { keys } from './utils/object.js'; |
|
|
|
import { assign, keys } from './utils/object.js'; |
|
|
|
import validateKeys from './utils/validateKeys.js'; |
|
|
|
import SOURCEMAPPING_URL from './utils/sourceMappingURL.js'; |
|
|
|
import Bundle from './Bundle.js'; |
|
|
@ -52,19 +52,33 @@ export function rollup ( options ) { |
|
|
|
const bundle = new Bundle( options ); |
|
|
|
|
|
|
|
return bundle.build().then( () => { |
|
|
|
return { |
|
|
|
function generate ( options ) { |
|
|
|
const rendered = bundle.render( options ); |
|
|
|
|
|
|
|
bundle.plugins.forEach( plugin => { |
|
|
|
if ( plugin.ongenerate ) { |
|
|
|
plugin.ongenerate( assign({ |
|
|
|
bundle: result |
|
|
|
}, options )); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return rendered; |
|
|
|
} |
|
|
|
|
|
|
|
var result = { |
|
|
|
imports: bundle.externalModules.map( module => module.id ), |
|
|
|
exports: keys( bundle.entryModule.exports ), |
|
|
|
modules: bundle.orderedModules.map( module => module.toJSON() ), |
|
|
|
|
|
|
|
generate: options => bundle.render( options ), |
|
|
|
generate, |
|
|
|
write: options => { |
|
|
|
if ( !options || !options.dest ) { |
|
|
|
throw new Error( 'You must supply options.dest to bundle.write' ); |
|
|
|
} |
|
|
|
|
|
|
|
const dest = options.dest; |
|
|
|
let { code, map } = bundle.render( options ); |
|
|
|
let { code, map } = generate( options ); |
|
|
|
|
|
|
|
let promises = []; |
|
|
|
|
|
|
@ -85,5 +99,7 @@ export function rollup ( options ) { |
|
|
|
return Promise.all( promises ); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
return result; |
|
|
|
}); |
|
|
|
} |
|
|
|