-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
74 lines (56 loc) · 1.57 KB
/
tsdown.config.ts
File metadata and controls
74 lines (56 loc) · 1.57 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { defineConfig } from 'tsdown';
export default defineConfig({
// Entry points for the library
entry: ['./src/index.ts'],
// Output formats: ESM and CommonJS for maximum compatibility
format: ['esm', 'cjs'],
// Clean output directory before building
clean: true,
// Generate TypeScript declaration files
dts: true,
// Target modern JavaScript environments
target: 'node18',
// Platform-specific optimizations
platform: 'neutral',
// External dependencies (none for this library)
external: [],
// Enable unbundled mode - we want separate files for better tree-shaking
unbundle: true,
// Output directory structure
outDir: 'dist',
// Minification disabled for library code (let consumers handle this)
minify: false,
// Generate source maps for better debugging
sourcemap: true,
// Treeshaking to remove unused code
treeshake: true,
// Fix import extensions for ESM compatibility
fixedExtension: true,
// Validate exports field in package.json
// Disabled to manually manage package.json exports
exports: true,
// Publint validation
publint: true,
// Custom output configuration for different formats
outExtension({ format }) {
if (format === 'esm') {
return {
js: '.mjs',
};
}
if (format === 'cjs') {
return {
js: '.cjs',
};
}
return {};
},
// Success callback
onSuccess() {
console.info('✅ Build succeeded!');
},
// Failure callback
onFailure(error) {
console.error('❌ Build failed:', error);
},
});