forked from Xin128/ElectionGuard-COMP413
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
94 lines (89 loc) · 2.57 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// @rollup/plugin-typescript: faster, but I couldn't get it to properly emit declaration files
// rollup-plugin-typescript2: couldn't get it to respect output.file instead of tsconfig.json
import typescript from 'rollup-plugin-ts';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import polyfill from 'rollup-plugin-polyfill-node';
import externals from 'rollup-plugin-node-externals';
import {terser} from 'rollup-plugin-terser';
import deno from 'rollup-plugin-deno';
import pkg from './package.json';
const clean = {comments: /[^\w\W]/};
// somewhat hacky, but official, way to prevent redundant declaration files
const suppressDuplicateDeclarations = {
outputPath: (path, kind) =>
kind === 'declaration' ? './dist/index.d.ts' : path,
};
const builds = [
{
input: 'src/electionguard/index.ts',
output: [
{file: pkg.exports.import, format: 'esm'},
{file: pkg.exports.require, format: 'cjs'},
],
plugins: [
commonjs(),
typescript({hook: suppressDuplicateDeclarations}),
externals(),
terser({
output: clean,
}),
],
external: [
'bigint-mod-arith',
'io-ts/lib/Decoder.js',
'io-ts/lib/Encoder.js',
'io-ts/lib/Codec.js',
'fp-ts/lib/function.js',
'fp-ts/lib/Either.js',
'randombytes',
'create-hash',
'create-hmac',
'seedrandom',
'@stdlib/assert-has-arrow-function-support',
'@stdlib/assert-has-async-await-support',
'@stdlib/assert-has-bigint-support',
'@stdlib/assert-has-class-support',
'@stdlib/assert-has-map-support',
'@stdlib/assert-has-set-support',
'@stdlib/assert-has-uint8array-support',
],
},
{
input: 'src/electionguard/index.ts',
output: [{file: 'dist/mod.js', format: 'esm'}],
context: 'this',
plugins: [
commonjs(),
resolve({preferBuiltins: false, browser: false}),
typescript({hook: suppressDuplicateDeclarations}),
deno(),
terser({
output: clean,
}),
],
external: ['https://deno.land/std@0.90.0/node/crypto.ts'],
},
{
input: 'src/electionguard/index.ts',
output: [
{file: pkg.browser, format: 'esm'},
{
file: 'dist/electionguard.umd.js',
name: 'eg',
format: 'umd',
},
],
context: 'this',
plugins: [
commonjs(),
resolve({preferBuiltins: false, browser: true}),
polyfill(),
typescript({hook: suppressDuplicateDeclarations}),
terser({
output: clean,
}),
],
},
];
export default builds;