-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathtsdown.config.base.ts
More file actions
102 lines (88 loc) · 2.45 KB
/
tsdown.config.base.ts
File metadata and controls
102 lines (88 loc) · 2.45 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import type { UserConfig, OutExtensionContext } from 'tsdown';
// Turbo task execution triggers a tsdown ATTW tarball path bug for scoped packages.
// Keep ATTW for direct package builds, but disable it for workspace builds.
const isTurboTask = Boolean(process.env.TURBO_HASH);
/**
* tsdown config with shared defaults.
* Package-specific options (e.g., entry, outDir, outExtensions) can be overridden by the caller.
* Paths are relative to the closest `tsdown.config.ts` file that imports this config.
*/
export const baseConfig = {
/**
* Entry points for the build.
*/
entry: ['src/index.ts'],
/**
* Output directory for the build.
*/
outDir: 'dist',
outExtensions: (ctx) => ({
js: isESM(ctx)
? '.mjs'
: '.cjs',
dts: isESM(ctx)
? '.d.mts'
: '.d.cts',
}),
/**
* Configures the output formats for the build.
* - 'esm' generates ESM (ECMAScript Module) output
* - 'cjs' generates lecayse CommonJS output
*/
format: ['esm', 'cjs' /* legacy */],
/**
* Generates TypeScript declaration files (.d.mts, .d.ts)
*/
dts: true,
/**
* Clean `outDir` before each build.
*/
clean: true,
/**
* Compress code to reduce bundle size.
*/
minify: false,
/**
* Target ECMAScript version for the output.
*/
target: 'es2022',
/**
* Callback function to execute after a successful build.
*/
onSuccess() {
console.info('🙏 Build succeeded!');
},
/**
* External dependencies that should not be bundled, but provided by the consumer.
*/
external: ['zod', '@composio/core', /^node:/],
/**
* Control how Node.js built-in module imports are handled.
* When true, imports like `fs` are transformed to `node:fs`.
*/
nodeProtocol: true,
/**
* Configuration for @arethetypeswrong/cli.
* Uses '.' entrypoint to check the package root via the exports field,
* since src/index.ts is only used during development and not exported.
* Uses 'node16' profile since packages support both ESM and CJS.
*/
attw: {
entrypoints: ['.'],
enabled: !isTurboTask,
level: 'error',
profile: 'node16',
ignoreRules: [/* Node.js 10 only, attw doesn't automatically exclude it despite the selected profile */ 'internal-resolution-error'],
},
/**
* Configuration for publint.
*/
publint: {
enabled: true,
level: 'error',
pack: 'pnpm',
},
} satisfies UserConfig
function isESM(ctx: OutExtensionContext) {
return ctx.format === 'es'
}