-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
71 lines (52 loc) · 2.09 KB
/
rollup.config.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {builtinModules} from 'module'
import rpi_jsy from 'rollup-plugin-jsy'
import rpi_dgnotify from 'rollup-plugin-dgnotify'
import rpi_resolve from '@rollup/plugin-node-resolve'
import { terser as rpi_terser } from 'rollup-plugin-terser'
const _rpis_ = (defines, ...args) => [
rpi_jsy({defines}),
rpi_resolve(),
...args,
// rpi_commonjs(), // Allow CommonJS use -- https://github.com/rollup/plugins/tree/master/packages/commonjs#readme
rpi_dgnotify()]
const _cfg_ = {
external: id => /^\w+:/.test(id) || builtinModules.includes(id),
plugins: _rpis_({}) }
const _cfg_nodejs_ = { ..._cfg_,
plugins: _rpis_({PLAT_NODEJS: true, HAS_STREAM: true}) }
const _cfg_deno_ = { ..._cfg_,
plugins: _rpis_({PLAT_DENO: true}) }
const _cfg_web_ = { ..._cfg_,
plugins: _rpis_({PLAT_WEB: true}) }
let is_watch = process.argv.includes('--watch')
const _cfg_web_min_ = is_watch ? null : { ... _cfg_web_,
plugins: _rpis_({PLAT_WEB: true}, rpi_terser()) }
export default [
... add_jsy('index'),
... add_jsy('core'),
... add_jsy('v4', {plat:true}),
... add_jsy('v5', {plat:true}),
... add_jsy('opaque/index'),
... add_jsy('opaque/v4', {plat:true}),
... add_jsy('opaque/v5', {plat:true}),
]
function * add_jsy(src_name, opt={}) {
let {plat} = opt
const input = `code/${src_name}${opt.ext || '.jsy'}`
const out_name = src_name.replace(/\/index$/,'').replace(/[\/]/g, '_')
if (! plat)
yield { ... _cfg_, input,
output: { file: `esm/${out_name}.js`, format: 'es', sourcemap: true }}
if (plat && _cfg_nodejs_)
yield { ... _cfg_nodejs_, input,
output: { file: `esm/node/${out_name}.js`, format: 'es', sourcemap: true }}
if (plat && _cfg_deno_)
yield { ... _cfg_deno_, input,
output: { file: `esm/deno/${out_name}.js`, format: 'es', sourcemap: true }}
if (plat && _cfg_web_)
yield { ... _cfg_web_, input,
output: { file: `esm/web/${out_name}.js`, format: 'es', sourcemap: true }}
if (_cfg_web_min_)
yield { ... _cfg_web_min_, input,
output: { file: plat ? `esm/web/${out_name}.min.js` : `esm/${out_name}.min.js`, format: 'es', sourcemap: false }}
}