-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
76 lines (66 loc) · 2.06 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
import typescript from '@rollup/plugin-typescript'
import babel from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import json from '@rollup/plugin-json'
import replace from "@rollup/plugin-replace"
import { readFileSync } from "node:fs"
import { resolve as resolvePath, dirname } from "node:path"
import { fileURLToPath } from "node:url"
import pkg from './package.json' with { type: "json" }
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const packageJson = JSON.parse(
readFileSync(resolvePath(__dirname, './package.json'))
);
const version = packageJson.version;
const minifiedOutputs = [
{
file: pkg.exports['.'].import,
format: 'esm',
},
{
file: pkg.exports['.'].require,
format: 'cjs',
}
];
const unminifiedOutputs = minifiedOutputs.map(({ file, ...rest }) => ({
...rest,
file: file.replace('.min.', '.'),
}));
export default [
// {
// input: './src/index.ts',
// output: [...unminifiedOutputs, ],
// plugins: [
// typescript({tsconfig: resolvePath(__dirname, 'tsconfig.esm.json')}),
// babel({
// exclude: 'node_modules/**',
// extensions: ['.js', '.jsx', '.ts', '.tsx'],
// }),
// resolve(),
// json()
// ],
// external: [/^@babel\/runtime\//],
// },
{
input: './index.ts',
output: [...minifiedOutputs],
plugins: [
// replace({
// 'Object.defineProperty(exports,"__esModule",{value:!0})': '',
// delimiters: ['\n', '\n']
// }),
typescript({tsconfig: resolvePath(__dirname, 'tsconfig.json')}),
babel({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
resolve({
modulePaths: ['./node_modules/bitcoinjs-lib/src']
}),
terser(),
json(),
],
external: [/^@babel\/runtime\//],
},
];