'use strict'

const rollup = require('rollup')
const assign = require('object-assign')


function createPreprocessor (options, preconfig, logger) {

	const log = logger.create('preprocessor.rollup')

	let cache

	return (content, file, done) => {
		const config = assign({}, options, preconfig.options,
			{
				input: file.path,
				cache,
			}
		)
		done(null, content)
	}
}

createPreprocessor.$inject = ['config.rollupPreprocessor', 'args', 'logger']

module.exports = {
	'preprocessor:rollup': ['factory', createPreprocessor],
}

@@ -39,17 +39,24 @@
 rollup')
+.rollup
 %0A
-
 const as
@@ -354,28 +354,424 @@
 %09%09)%0A
-%09%09done(null, content
+%0A%09%09rollup(config)%0A%09%09%09.then(bundle =%3E %7B%0A%09%09%09%09cache = bundle%0A%09%09%09%09return bundle.generate(config)%0A%09%09%09%7D)%0A%09%09%09.then(generated =%3E %7B%0A%09%09%09%09let output = generated.code%0A%09%09%09%09if (config.sourcemap === 'inline') %7B%0A%09%09%09%09%09output += %60%5Cn//# sourceMappingURL=$%7Bgenerated.map.toUrl()%7D%5Cn%60%0A%09%09%09%09%7D%0A%09%09%09%09done(null, output)%0A%09%09%09%7D)%0A%09%09%09.catch(error =%3E %7B%0A%09%09%09%09log.error('Error processing %25s%5Cn%5Cn%25s%5Cn', file.path, error.message)%0A%09%09%09%09done(error, null)%0A%09%09%09%7D
 )%0A%09%7D

implement basics of rollup api