-
Notifications
You must be signed in to change notification settings - Fork 7
/
rollup.config.js
executable file
·95 lines (81 loc) · 2.22 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
95
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import pkg from './package.json';
import json from '@rollup/plugin-json';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
const extensions = [
'.js', '.jsx', '.ts', '.tsx',
];
const name = 'HerajsWallet';
const namedExports = {
'node_modules/elliptic/lib/elliptic.js': 'ec'.split(', '),
'../client/dist/herajs.js': 'AergoClient, Amount, Address'.split(', '),
'../crypto/dist/herajs-crypto.iife.js': [
'encodeAddress',
'decodeAddress',
'encodePrivateKey',
'decodePrivateKey',
'createIdentity',
'identifyFromPrivateKey',
'addressFromPublicKey',
'publicKeyFromAddress',
'decryptPrivateKey',
'encryptPrivateKey',
'signMessage',
'signTransaction',
'verifySignature',
'verifyTxSignature',
'hashTransaction'
]
};
const nodeExternal = [
'crypto',
'buffer',
'util'
];
const external = Object.keys(pkg.dependencies).concat(...nodeExternal);
export default ['node', 'web'].map(target => ({
input: './src/index.ts',
external: external,
plugins: [
commonjs({ namedExports }),
resolve({
extensions,
browser: target === 'web'
}),
json(),
babel({ extensions, include: ['src/**/*'] }),
globals(),
builtins(),
],
output: target === 'node' ? [{
file: pkg.main,
format: 'cjs',
external: nodeExternal,
}, {
file: pkg.module,
format: 'es',
external: nodeExternal,
}] : [{
file: pkg.browser,
format: 'umd',
name,
globals: external.reduce((prev, cur) => {
prev[cur] = cur; return prev;
}, {}),
}],
onwarn(warning, warn) {
const ignoredCircular = [
'elliptic'
];
if (
warning.code === 'CIRCULAR_DEPENDENCY' &&
ignoredCircular.some(d => warning.importer.includes(d))
) {
return;
}
warn(warning.message);
},
}));