-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtsup.config.js
61 lines (58 loc) · 1.39 KB
/
tsup.config.js
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
// @ts-check
import { defineConfig } from 'tsup'
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { replace } from 'esbuild-plugin-replace';
import pkg from './sdk/package.json' assert { type: 'json' };
export default defineConfig((options) => {
if (options.watch) {
// Watch mode
return {
outDir: 'dist/browser',
format: 'esm',
target: 'es2022',
platform: 'browser',
bundle: true,
}
}
return [
// Browser Bundle for ESM
{
outDir: 'dist/browser',
platform: 'browser',
format: 'esm',
target: 'es2022',
minify: true,
bundle: true,
noExternal: ['@uniswap/swap-router-contracts'],
treeshake: true,
esbuildPlugins: [
nodeModulesPolyfillPlugin({
globals: {
Buffer: true,
process: true,
},
modules: ['crypto', 'buffer', 'process']
}),
replace({
'__SDK_VERSION__': pkg.version,
})
]
},
// Node Bundle for CommonJS and ESM
{
outDir: 'dist/node',
platform: 'node',
format: ['esm', 'cjs'],
target: 'es2022',
minify: true,
bundle: true,
noExternal: ['@uniswap/swap-router-contracts'],
treeshake: true,
esbuildPlugins: [
replace({
'__SDK_VERSION__': pkg.version,
})
]
},
]
})