forked from xmtp/xmtp-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
37 lines (33 loc) · 1.09 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
import { defineConfig } from 'tsup'
import externalGlobal from 'esbuild-plugin-external-global'
import { Plugin } from 'esbuild'
export default defineConfig((options) => {
const esbuildPlugins: Plugin[] = []
// for the browser bundle, replace `crypto` import with an object that
// returns the browser's built-in crypto library
if (options.platform === 'browser') {
esbuildPlugins.push(
externalGlobal.externalGlobalPlugin({
crypto: '{ webcrypto: window.crypto }',
})
)
}
const isBench = options.entry?.[0] === 'bench/index.ts'
return {
entry: options.entry ?? ['src/index.ts'],
outDir:
options.outDir ?? (options.platform === 'browser' ? 'dist/web' : 'dist'),
splitting: false,
sourcemap: !isBench,
treeshake: true,
clean: true,
bundle: true,
platform: options.platform ?? 'node',
minify: isBench ? false : options.platform === 'browser',
dts: isBench ? false : options.platform !== 'browser',
format:
options.format ??
(options.platform === 'browser' ? ['esm'] : ['esm', 'cjs']),
esbuildPlugins,
}
})