-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtsup.config.ts
More file actions
82 lines (66 loc) · 1.88 KB
/
tsup.config.ts
File metadata and controls
82 lines (66 loc) · 1.88 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
75
76
77
78
79
80
81
82
import { defineConfig } from 'tsup';
export default defineConfig({
entry: {
index: 'src/index.ts',
'bin/cli': 'src/bin/cli.ts',
'bin/feedback-collector': 'src/bin/feedback-collector.ts'
},
format: ['esm', 'cjs'],
target: 'node18',
platform: 'node',
tsconfig: 'tsconfig.build.json',
// Code splitting and bundling
splitting: false,
bundle: true,
minify: false,
// Source maps and debugging
sourcemap: true,
clean: true,
// TypeScript declarations
dts: true,
// External dependencies (don't bundle)
external: [
'fsevents' // macOS-specific, optional dependency
],
// Environment and Node.js specific
shims: false,
// Output configuration
outDir: 'dist',
// Banner for CLI executable
banner: {
js: '#!/usr/bin/env node'
},
// ESBuild options
esbuildOptions: (options) => {
options.conditions = ['node'];
options.mainFields = ['module', 'main'];
// Suppress unused import warnings for bundled dependencies
options.ignoreAnnotations = false;
options.treeShaking = true;
// Suppress warnings about unused imports from bundled modules
options.logLevel = 'warning';
options.logLimit = 0;
},
// Only add shebang to CLI entries
onSuccess: 'chmod +x dist/bin/cli.js && chmod +x dist/bin/feedback-collector.js',
// Development mode
watch: process.env.NODE_ENV === 'development',
// Enable tree shaking
treeshake: true,
// Target specific output
outExtension({ format }) {
return {
js: format === 'esm' ? '.mjs' : '.js'
};
},
// Define globals for better optimization
define: {
__VERSION__: JSON.stringify(process.env.npm_package_version || '1.0.0'),
__DEV__: process.env.NODE_ENV === 'development' ? 'true' : 'false'
},
// Inject package.json version
inject: ['./src/version.ts'],
// Ensure proper module format
cjsInterop: true,
legacyOutput: false
});