-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtsup.config.ts
60 lines (58 loc) · 1.5 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import type { Options } from 'tsup'
import { copyFile } from 'node:fs/promises'
import { defineConfig } from 'tsup'
const commonOptions: Options = {
entry: {
'index': 'src/index.ts',
'idb': 'src/vfs/idb.ts',
'idb-memory': 'src/vfs/idb-memory.ts',
'opfs': 'src/vfs/opfs.ts',
'fs-handle': 'src/vfs/fs-handle.ts',
'constant': 'src/constant.ts',
},
format: ['esm', 'cjs'],
treeshake: true,
noExternal: ['wa-sqlite'],
tsconfig: './tsconfig.json',
}
export default defineConfig([
{
...commonOptions,
clean: true,
dts: { resolve: true },
},
{
...commonOptions,
minify: true,
splitting: false,
outExtension({ format }) {
return {
js: format === 'esm' ? `.min.js` : '.min.cjs',
}
},
plugins: [
{
name: 'copy-wasm',
buildEnd() {
if (this.format === 'esm') {
Promise.all([
copyFile(
'./wa-sqlite-fts5/wa-sqlite.wasm',
'./dist/wa-sqlite.wasm',
),
copyFile(
'./wa-sqlite-fts5/wa-sqlite-async.wasm',
'./dist/wa-sqlite-async.wasm',
),
// Maybe uncomment later when jspi support is widely supported
// copyFile(
// './wa-sqlite-fts5/wa-sqlite-jspi.wasm',
// './dist/wa-sqlite-jspi.wasm',
// ),
])
}
},
},
],
},
])