-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
73 lines (68 loc) · 1.75 KB
/
Copy pathtsdown.config.ts
File metadata and controls
73 lines (68 loc) · 1.75 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
import VersionInjector from '@redstardev/unplugin-version-injector/rolldown';
import { defineConfig, type OutExtensionContext, type UserConfig } from 'tsdown';
const baseConfig = {
entry: ['src/index.ts'],
platform: 'node',
target: 'node24.2',
outDir: 'dist',
clean: true,
sourcemap: true,
minify: false,
failOnWarn: true,
checks: {
// v0.0.2 transforms the version marker without returning a source map.
// Keep source maps enabled while suppressing only Rolldown's plugin-map warning.
sourcemapBroken: false,
},
treeshake: true,
deps: {
neverBundle: true,
},
plugins: [VersionInjector()],
} satisfies UserConfig;
const packageConfig = {
...baseConfig,
format: ['esm', 'cjs'],
checks: {
...baseConfig.checks,
// Packages intentionally dual-publish ESM and CJS. With a node24.2 target
// (which supports require(esm)), tsdown escalates its legacy-CJS
// recommendation to an error under failOnWarn, so opt out of that check.
legacyCjs: false,
},
outExtensions: (context: OutExtensionContext) => ({
js: context.format === 'es' ? '.mjs' : '.cjs',
dts: context.format === 'es' ? '.d.mts' : '.d.cts',
}),
dts: {
sourcemap: true,
},
attw: {
entrypoints: ['.'],
enabled: true,
level: 'error',
profile: 'node16',
},
publint: {
enabled: true,
level: 'error',
},
} satisfies UserConfig;
const appConfig = {
...baseConfig,
format: ['esm'],
fixedExtension: false,
dts: false,
} satisfies UserConfig;
export function definePackageConfig(overrides: UserConfig = {}) {
return defineConfig({
...packageConfig,
...overrides,
});
}
export function defineAppConfig(overrides: UserConfig = {}) {
return defineConfig({
...appConfig,
...overrides,
});
}