Skip to content

Commit 7bad14a

Browse files
committed
esbuild
1 parent 9a77f66 commit 7bad14a

File tree

6 files changed

+147
-327
lines changed

6 files changed

+147
-327
lines changed

TYPESCRIPT_MIGRATION.md

Lines changed: 0 additions & 296 deletions
This file was deleted.

esbuild.config.mjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import * as esbuild from 'esbuild';
2+
3+
const isWatch = process.argv.includes('--watch');
4+
const isProd = process.argv.includes('--prod');
5+
6+
const config = {
7+
entryPoints: ['index.ts'],
8+
bundle: true,
9+
platform: 'node',
10+
target: 'node22',
11+
outfile: 'dist/index.js',
12+
format: 'cjs',
13+
sourcemap: false,
14+
minify: isProd,
15+
minifyWhitespace: true,
16+
minifyIdentifiers: isProd, // Minify identifiers in production
17+
minifySyntax: true,
18+
treeShaking: true,
19+
drop: isProd ? ['debugger'] : [],
20+
legalComments: 'none',
21+
// Native modules that can't be bundled
22+
external: [
23+
'better-sqlite3',
24+
'talib',
25+
'protobufjs',
26+
'protobufjs/minimal',
27+
'protobufjs/minimal.js',
28+
'ts-node',
29+
'ts-node/register',
30+
'fsevents',
31+
],
32+
define: {
33+
'process.env.NODE_ENV': isProd ? '"production"' : '"development"',
34+
},
35+
logLevel: 'warning',
36+
mainFields: ['module', 'main'],
37+
conditions: ['node'],
38+
ignoreAnnotations: true,
39+
keepNames: true,
40+
// Mark these as pure for better tree-shaking
41+
pure: [
42+
'console.debug',
43+
'console.trace',
44+
],
45+
};
46+
47+
if (isWatch) {
48+
const ctx = await esbuild.context(config);
49+
await ctx.watch();
50+
console.log('Watching for changes...');
51+
} else {
52+
await esbuild.build(config);
53+
}

0 commit comments

Comments
 (0)