-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbundle-api.mjs
More file actions
49 lines (45 loc) · 1.19 KB
/
bundle-api.mjs
File metadata and controls
49 lines (45 loc) · 1.19 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
/**
* Pre-bundles the Vercel serverless API function.
*
* This script bundles server/index.ts with dependencies inlined,
* creating a self-contained serverless function for Vercel deployment.
*
* Native packages like better-sqlite3 are kept external and will be
* packaged separately by Vercel.
*/
import { build } from 'esbuild';
// Packages that cannot be bundled (native bindings / optional drivers)
const EXTERNAL = [
'better-sqlite3',
'@libsql/client',
// Optional knex database drivers
'pg',
'pg-native',
'pg-query-stream',
'mysql',
'mysql2',
'sqlite3',
'oracledb',
'tedious',
// macOS-only native file watcher
'fsevents',
];
await build({
entryPoints: ['server/index.ts'],
bundle: true,
platform: 'node',
format: 'esm',
target: 'es2020',
outfile: 'api/_handler.js',
sourcemap: true,
external: EXTERNAL,
logOverride: { 'require-resolve-not-external': 'silent' },
banner: {
js: [
'// Bundled by esbuild — see scripts/bundle-api.mjs',
'import { createRequire } from "module";',
'const require = createRequire(import.meta.url);',
].join('\n'),
},
});
console.log('[bundle-api] Bundled server/index.ts → api/_handler.js');