-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.js
46 lines (44 loc) · 1.1 KB
/
rollup.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
36
37
38
39
40
41
42
43
44
45
46
'use strict'
const fs = require('fs')
const rollup = require('rollup').rollup
const nodeResolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const json = require('rollup-plugin-json')
const buble = require('buble')
const writeFilePromise = (path, data) =>
new Promise((resolve, reject) =>
fs.writeFile(path, data, err =>
err ? reject(err) : resolve('file written')
)
)
rollup({
entry: 'lib/js/repl.js',
plugins: [
nodeResolve({
jsnext: true,
main: true,
skip: ['ramda', 'sanctuary', 'buble', 'ramda-fantasy'],
extensions: ['.js', '.json']
}),
commonjs({
include: './node_modules/**'
}),
json()
]
})
.then(function(bundle) {
const result = bundle.generate({
format: 'iife',
moduleName: 'ramtuary',
globals: {
ramda: 'R',
sanctuary: 'S',
buble: 'buble',
'ramda-fantasy': 'RF'
}
})
return buble.transform(result.code).code
})
.then(code => writeFilePromise('lib/js/bundle.js', code))
.then(console.log)
.catch(console.error)