-
Notifications
You must be signed in to change notification settings - Fork 221
Expand file tree
/
Copy pathtsup.config.ts
More file actions
37 lines (34 loc) · 1.42 KB
/
tsup.config.ts
File metadata and controls
37 lines (34 loc) · 1.42 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
import { defineConfig } from 'tsup';
import fs from 'fs';
import path from 'path';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm'],
dts: true,
clean: true,
outDir: 'dist',
// Optional runtime-loaded dependencies (database drivers and cloud auth
// packages) are declared as optionalDependencies and loaded via dynamic
// import(). Database drivers must be external so tsup does not bundle their
// CJS code into ESM chunks (which causes "Dynamic require of X is not
// supported"). Cloud auth packages are externalized to keep their large
// dependency trees out of the bundle.
external: ['pg', 'mysql2', 'mariadb', 'mssql', 'better-sqlite3', '@aws-sdk/rds-signer', '@azure/identity'],
// Copy the employee-sqlite demo data to dist
async onSuccess() {
// Create target directory
const targetDir = path.join('dist', 'demo', 'employee-sqlite');
fs.mkdirSync(targetDir, { recursive: true });
// Copy all SQL files from demo/employee-sqlite to dist/demo/employee-sqlite
const sourceDir = path.join('demo', 'employee-sqlite');
const files = fs.readdirSync(sourceDir);
for (const file of files) {
if (file.endsWith('.sql')) {
const sourcePath = path.join(sourceDir, file);
const targetPath = path.join(targetDir, file);
fs.copyFileSync(sourcePath, targetPath);
console.log(`Copied ${sourcePath} to ${targetPath}`);
}
}
},
});