-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtsup.config.ts
36 lines (35 loc) · 944 Bytes
/
tsup.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
import { defineConfig } from "tsup";
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
export default defineConfig((options) => ({
entry: ["src/index.ts"],
dts: true,
format: ["esm"],
sourcemap: true,
minify: true,
clean: true,
external: ["solid-js", "zod"],
outExtension: () => ({ js: '.jsx' }),
esbuildOptions(options) {
options.jsx = "preserve";
options.jsxImportSource = "solid-js";
options.banner = {
js: '"use client";',
};
},
onSuccess: async () => {
try {
execSync('npm run test', { stdio: 'inherit', cwd: __dirname });
} catch (error) {
console.error('Tests failed. Removing dist directory.');
const distPath = path.join(__dirname, 'dist');
if (fs.existsSync(distPath)) {
fs.rmSync(distPath, { recursive: true, force: true });
}
if (!options.watch) {
process.exit(1);
}
}
},
}));