-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
45 lines (41 loc) · 955 Bytes
/
build.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
import { rename } from 'fs/promises'
import { glob } from 'glob'
import { build } from 'tsup'
await build({
platform: 'node',
format: 'cjs',
entry: ['src/index.ts'],
outDir: 'dist/cjs',
tsconfig: './tsconfig.cjs.json',
bundle: true,
shims: true,
// minify: true,
// minifyIdentifiers: true,
// minifySyntax: true,
// minifyWhitespace: true,
skipNodeModulesBundle: true,
splitting: false,
clean: true,
dts: false
})
const files = await glob('dist/**/*.cjs', { cwd: process.cwd() })
for (const filename of files) {
const newName = filename.replace('.cjs', '.js')
await rename(filename, newName)
}
await build({
platform: 'node',
format: 'esm',
entry: ['src/index.ts'],
outDir: 'dist/mjs',
tsconfig: './tsconfig.mjs.json',
bundle: true,
minify: true,
minifyIdentifiers: true,
minifySyntax: true,
minifyWhitespace: true,
skipNodeModulesBundle: true,
splitting: true,
clean: true,
dts: false
})