-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathesbuild.config.ts
47 lines (41 loc) · 1.05 KB
/
esbuild.config.ts
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
import * as esbuild from 'esbuild';
import { nodeExternalsPlugin } from 'esbuild-node-externals';
import { resolve } from 'path';
const buildOptions: esbuild.BuildOptions = {
entryPoints: [resolve(__dirname, 'src/index.ts')],
outfile: 'dist/index.js',
bundle: true,
platform: 'node',
target: ['node16'],
format: 'cjs',
sourcemap: true,
minify: true,
plugins: [
nodeExternalsPlugin(),
],
};
async function build() {
try {
console.log('📦 Building package...');
const start = Date.now();
await esbuild.build(buildOptions);
await esbuild.build({
...buildOptions,
entryPoints: [resolve(__dirname, 'src/index.ts')],
outfile: 'dist/index.d.ts',
format: 'esm',
bundle: false,
minify: false,
splitting: false,
write: true,
plugins: [],
loader: { '.ts': 'ts' },
});
const duration = Date.now() - start;
console.log(`✅ Build completed in ${duration}ms`);
} catch (error) {
console.error('❌ Build failed:', error);
process.exit(1);
}
}
build();