forked from intoli/user-agents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
30 lines (28 loc) · 802 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
import { Plugin } from 'esbuild';
import { defineConfig } from 'tsup';
// Tell esbuild not to bundle the JSON file so that we reuse it between CommonJS and ESM builds.
const externalJsonPlugin = (): Plugin => ({
name: 'external-json',
setup(build) {
build.onResolve({ filter: /user-agents-tea\.json$/ }, (args) => {
return {
path: args.path,
external: true,
};
});
},
});
export default defineConfig({
cjsInterop: true,
dts: true,
entryPoints: ['src/index.ts'],
esbuildPlugins: [externalJsonPlugin()],
format: ['cjs', 'esm'],
minify: true,
outDir: 'dist',
// CJS interop is broken without splitting, see:
// * https://github.com/egoist/tsup/issues/992#issuecomment-1763540165
splitting: true,
sourcemap: true,
target: 'esnext',
});