-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
42 lines (39 loc) · 1.12 KB
/
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
import type { Options } from 'tsup'
// import pkg from './package.json'
// const isProduction = process.env.NODE_ENV === 'production'
// const external = [
// ...Object.keys(pkg.dependencies || {}),
// ...Object.keys(pkg.peerDependencies || {}),
// ]
// const noExternal = [
// ...Object.keys(pkg.dependencies || {}),
// ]
export default <Options>{
entryPoints: ['src/index.ts'],
outDir: 'dist',
target: 'node18', // needed for working ESM
format: ['esm'],
splitting: false,
sourcemap: true,
clean: true,
dts: true,
minify: process.env.NODE_ENV === 'production',
// noExternal,
skipNodeModulesBundle: true,
banner: ({ format }) => {
if (format === 'esm') {
return {
// eslint-disable-next-line @typescript-eslint/quotes
js: `import {createRequire as __createRequire} from 'module';var require=__createRequire(import\.meta.url);`,
}
}
},
footer: ({ format }) => {
if (format === 'cjs') {
return {
// eslint-disable-next-line @typescript-eslint/quotes
js: `if (module.exports.default) module.exports = module.exports.default;`,
}
}
},
}