-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathesbuild.config.js
More file actions
77 lines (73 loc) · 1.59 KB
/
esbuild.config.js
File metadata and controls
77 lines (73 loc) · 1.59 KB
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
import { build, context } from 'esbuild';
import { nodeExternalsPlugin } from 'esbuild-node-externals';
const isProduction = process.env.NODE_ENV === 'production';
const isWatch = process.argv.includes('--watch');
const config = {
entryPoints: ['src/index.ts'],
bundle: true,
platform: 'node',
format: 'esm',
mainFields: ['module', 'main'],
conditions: ['import'],
sourcemap: !isProduction,
minify: isProduction,
target: ['node18'],
outfile: 'dist/bundle.js',
external: [
'@modelcontextprotocol/sdk',
'viem',
'ethers',
'bitcoinjs-lib',
'ecpair',
'tiny-secp256k1',
'light-bolt11-decoder',
'zod',
'pino',
'express',
'crypto',
'fs',
'path',
'url',
'os',
'util'
],
plugins: [
nodeExternalsPlugin({
allowWorkspaces: false,
devDependencies: false
})
],
define: {
'process.env.NODE_ENV': `"${process.env.NODE_ENV || 'development'}"`
},
logLevel: 'info'
};
async function run() {
if (isWatch) {
const ctx = await context({
...config,
plugins: [
...config.plugins,
{
name: 'watch-plugin',
setup(build) {
build.onEnd((result) => {
if (result.errors.length > 0) {
console.error('Watch build failed:', result.errors);
} else {
console.log('Watch build succeeded');
}
});
}
}
]
});
await ctx.watch();
console.log('Watching for changes...');
} else {
await build(config);
}
}
run().catch(() => {
process.exit(1);
});