-
Notifications
You must be signed in to change notification settings - Fork 24
/
rollup.config.mjs
66 lines (65 loc) · 2.08 KB
/
rollup.config.mjs
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
import terser from '@rollup/plugin-terser'
import alias from '@rollup/plugin-alias'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import typescript from 'rollup-plugin-typescript2'
const formats = ['umd', 'es']
const targets = ['allows', 'throws']
const variants = ['wasm']
const environments = ['node', 'web', 'worker']
const outputs = formats.reduce(
(acc, format) => [
...acc,
...targets.reduce(
(acc, target) => [
...acc,
...variants.reduce(
(acc, variant) => [
...acc,
...environments.reduce(
(acc, environment) => [
...acc,
{
input: `src/${target}_${variant}_${environment}_${format}.ts`,
output: {
file: `dist/${target}_${variant}_${environment}_${format}.js`,
sourcemap: true,
format,
name: 'SEAL',
exports: 'auto',
plugins: [terser()]
},
plugins: [
environment === 'node' && commonjs(), // needed to convert commonjs to es6 for emscripten 'node' builds
alias({
entries: [
// Used to replace the paths that use `import sealLibrary from './seal_*'` statement to point to their respective JS files
{
find: /^seal_(.*)$/,
replacement: './src/bin/seal_$1.js'
},
{
find: /^(.*)\.json$/,
replacement: './$1.json'
}
]
}),
json({ compact: true }),
typescript({
verbosity: 2
})
].filter(Boolean)
}
],
[]
)
],
[]
)
],
[]
)
],
[]
)
export default outputs