-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.mjs
76 lines (71 loc) · 2.25 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
67
68
69
70
71
72
73
74
75
76
import { nodeResolve } from '@rollup/plugin-node-resolve';
function onwarn(warning) {
const ignoreCodes = ['CIRCULAR_DEPENDENCY', 'THIS_IS_UNDEFINED'];
if (!ignoreCodes.includes(warning.code)) {
console.error(`(!) ${warning.message}`);
}
}
function getConfig(opts) {
if (opts == null) {
opts = {};
}
const file = `./dist/quais${opts.suffix || ''}.js`;
const exportConditions = ['import', 'default'];
const mainFields = ['module', 'main'];
if (opts.browser) {
mainFields.unshift('browser');
}
return {
input: './lib/esm/index.js',
output: {
file,
banner: "const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !== 'undefined' ? window: typeof global !== 'undefined' ? global: typeof self !== 'undefined' ? self: {});",
name: opts.name || undefined,
format: opts.format || 'esm',
sourcemap: true,
globals: {
'google-protobuf': 'pb_1',
'@bitcoinerlab/secp256k1': 'ecc',
},
},
external: ['google-protobuf', '@bitcoinerlab/secp256k1'],
context: '__$G',
treeshake: true,
onwarn,
plugins: [
nodeResolve({
exportConditions,
mainFields,
modulesOnly: true,
preferBuiltins: false,
}),
],
};
}
export default [
getConfig({ browser: true }),
getConfig({ browser: true, suffix: '.umd', format: 'umd', name: 'quais' }),
{
input: './lib/esm/wordlists/wordlists-extra.js',
onwarn,
output: {
file: './dist/wordlists-extra.js',
format: 'esm',
sourcemap: true,
globals: {
'google-protobuf': 'pb_1',
'@bitcoinerlab/secp256k1': 'ecc',
},
},
external: ['google-protobuf', '@bitcoinerlab/secp256k1'],
treeshake: true,
plugins: [
nodeResolve({
exportConditions: ['default', 'module', 'import'],
mainFields: ['browser', 'module', 'main'],
modulesOnly: true,
preferBuiltins: false,
}),
],
},
];