-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtsup.config.ts
47 lines (45 loc) · 898 Bytes
/
tsup.config.ts
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
import { defineConfig, type Options } from 'tsup';
const baseOptions: Options = {
clean: true,
entry: ['src/lib/index.ts'],
dts: true,
minify: false,
skipNodeModulesBundle: true,
sourcemap: true,
target: 'es2021',
tsconfig: 'src/tsconfig.json',
keepNames: true,
treeshake: true
};
export default [
defineConfig({
...baseOptions,
outDir: 'dist/cjs',
format: 'cjs',
outExtension: () => ({ js: '.cjs' })
}),
defineConfig({
...baseOptions,
outDir: 'dist/esm',
format: 'esm',
shims: true,
esbuildOptions: (options, context) => {
switch (context.format) {
case 'esm': {
options.banner = {
js: [
//
"import { createRequire } from 'node:module';",
'const require = createRequire(import.meta.url);'
].join('\n')
};
break;
}
// If it's not esm then we do nothing
default: {
break;
}
}
}
})
];