-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (30 loc) · 861 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict'
const rollup = require('rollup')
exports.name = 'rollup'
exports.inputFormats = ['js']
exports.outputFormat = 'js'
exports.renderFileAsync = function (filename, options) {
options = options || {}
options.entry = filename
if (options.plugins) {
if (!Array.isArray(options.plugins)) {
const newPlugins = []
for (const plugin in options.plugins) {
if ({}.hasOwnProperty.call(options.plugins, plugin)) {
const pluginOptions = options.plugins[plugin]
newPlugins.push(require(plugin)(pluginOptions))
}
}
options.plugins = newPlugins
}
}
return new Promise((resolve, reject) => {
rollup.rollup(options)
.then(bundle => {
const result = bundle.generate(options)
resolve(result.code)
}).catch(error => {
reject(error)
})
})
}