-
Notifications
You must be signed in to change notification settings - Fork 145
/
rollup.config.js
65 lines (57 loc) · 2.2 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
// Copyright 2017-2024 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import path from 'node:path';
import { createBundle } from '@polkadot/dev/config/rollup';
const pkgs = [
'@polkadot/hw-ledger',
'@polkadot/keyring',
'@polkadot/util',
'@polkadot/util-crypto'
];
const external = [
...pkgs
];
const entries = ['hw-ledger-transports', 'networks', 'x-bigint', 'x-fetch', 'x-global', 'x-randomvalues', 'x-textdecoder', 'x-textencoder', 'x-ws'].reduce((all, p) => ({
...all,
[`@polkadot/${p}`]: path.resolve(process.cwd(), `packages/${p}/build`)
}), {});
const overrides = {
'@polkadot/hw-ledger': {
// these are all used in the un-shakeable (and unused inside @polkadot/*) hdDerivation
// functionality from the Zondax libs, disable it completely with empty stubs
entries: {
'bip32-ed25519': path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
bip39: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
blakejs: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
bs58: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
events: path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js'),
'hash.js': path.resolve(process.cwd(), 'packages/x-bundle/build/empty.js')
}
},
'@polkadot/util-crypto': {
entries: {
'@polkadot/wasm-crypto': path.resolve(process.cwd(), 'node_modules/@polkadot/wasm-crypto/bundle.js'),
'bn.js': path.resolve(process.cwd(), 'packages/x-bundle/build/cjs/bn.js'),
buffer: path.resolve(process.cwd(), 'packages/x-bundle/build/buffer.js'),
crypto: path.resolve(process.cwd(), 'packages/x-bundle/build/crypto.js')
},
inject: {
Buffer: path.resolve(process.cwd(), 'packages/x-bundle/build/buffer.js'),
crypto: path.resolve(process.cwd(), 'packages/x-bundle/build/crypto.js'),
inherits: path.resolve(process.cwd(), 'packages/x-bundle/build/inherits.js')
},
polyfill: false
}
};
export default pkgs.map((pkg) => {
const override = (overrides[pkg] || {});
return createBundle({
external,
pkg,
...override,
entries: {
...entries,
...(override.entries || {})
}
});
});