-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtsup.config.ts
More file actions
77 lines (73 loc) · 2.14 KB
/
Copy pathtsup.config.ts
File metadata and controls
77 lines (73 loc) · 2.14 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
//@ts-check
import fs from 'node:fs/promises';
import { Options, defineConfig } from 'tsup';
import pkg from './package.json';
import path from 'node:path';
function fileEntry(source: string, filepath: string): Partial<Options> {
const {name, dir, ext} = path.parse(filepath);
return {
entry: { [name]: source },
outDir: dir,
outExtension: ctx => ({ js: ext })
};
}
const commonConfig: Options = {
splitting: false,
sourcemap: true,
dts: false,
clean: false,
skipNodeModulesBundle: true
}
console.log('clearing dist directory');
await fs.rm('./dist', { recursive: true, force: true });
export default defineConfig((options) => {
const cfg: Options[] = [
{
...fileEntry('src/index.ts', pkg.browser),
format: 'esm',
platform: 'browser',
target: ['es2024'],
...commonConfig,
dts: true
},
{
...fileEntry('src/index-nodefetch.mts', pkg.exports['./node-fetch'].node.import),
format: 'esm',
platform: 'node',
target: ['node20'],
...commonConfig
},
{
...fileEntry('src/index-nodefetch.cts', pkg.exports['./node-fetch'].node.require),
format: 'cjs',
platform: 'node',
target: ['node20'],
...commonConfig
},
{
...fileEntry('src/index-node-native.ts', pkg.exports['./native-fetch'].node.import),
format: 'esm',
platform: 'node',
target: ['node24'],
...commonConfig
},
{
...fileEntry('src/index-node-native.ts', pkg.exports['./native-fetch'].node.require),
format: 'cjs',
platform: 'node',
target: ['node24'],
...commonConfig
},
{
...fileEntry('src/index.ts', pkg.exports['./iife']),
format: 'iife',
platform: 'browser',
globalName: 'revClientLib',
target: ['es2024'],
...commonConfig,
minify: true,
dts: false
}
];
return cfg;
});