-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathtsup.config.js
More file actions
73 lines (66 loc) · 1.66 KB
/
Copy pathtsup.config.js
File metadata and controls
73 lines (66 loc) · 1.66 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
import { defineConfig } from 'tsup';
import packageJson from './package.json' with { type: 'json' };
import * as path from 'path';
const getDir = (filePath) => path.dirname(filePath);
// Base external dependencies (for Node.js builds)
const baseExternal = [
...Object.keys(packageJson.dependencies),
...Object.keys(packageJson.peerDependencies)
];
const config = {
entry: ['src/index.ts'],
platform: 'node',
dts: false,
splitting: false,
sourcemap: true,
clean: true,
external: baseExternal
};
// For browser ESM build, we need to bundle some dependencies that are problematic as externals
const browserESMExternal = [
...Object.keys(packageJson.peerDependencies).filter((key) => key.startsWith('@iden3/')),
'snarkjs',
'ffjavascript'
];
export default defineConfig([
{
...config,
format: ['esm'],
outDir: getDir(packageJson.exports['.'].node.import),
},
{
...config,
format: ['cjs'],
outDir: getDir(packageJson.exports['.'].node.require),
outExtension: () => ({
'.js': '.cjs',
}),
noExternal: ['quick-lru']
},
{
...config,
format: ['esm'],
// !NOTE: uncomment if you need to test index.html
// external: [...Object.keys(packageJson.peerDependencies)],
// noExternal: [
// ...Object.keys(packageJson.dependencies),
// ],
platform: 'browser',
outDir: getDir(packageJson.exports['.'].browser),
env: {
BUILD_BROWSER: true,
},
},
{
...config,
format: ['iife'],
platform: 'browser',
globalName: 'PolygonIdSdk',
external: [],
env: {
BUILD_BROWSER: true,
},
minify: true,
outDir: getDir(packageJson.exports['.'].umd),
}
]);