-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtsup.config.ts
49 lines (44 loc) · 1.04 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
import { rm } from "fs/promises";
import { rollup } from "rollup";
import { defineConfig } from "tsup";
import mangleCache from "./mangle-cache.json";
import pkg from "./package.json";
const base = defineConfig({
entry: ["src/index.ts"],
target: "esnext",
clean: true,
treeshake: true,
dts: true,
splitting: false,
sourcemap: true,
minify: Boolean(process.env.MINIFY),
esbuildOptions: options => {
options.sourcesContent = false;
options.mangleProps = /[^_]_$/;
options.mangleCache = mangleCache;
},
});
export default defineConfig([
{
...base,
format: ["cjs", "esm"],
},
{
...base,
format: ["esm"],
sourcemap: false,
noExternal: Object.keys(pkg.dependencies),
outExtension: () => ({ js: `.umd.mjs` }),
onSuccess: async () => {
const bundle = await rollup({
input: ["dist/index.umd.mjs"],
});
await bundle.write({
format: "umd",
file: "dist/index.umd.js",
name: "Remitter",
});
await rm("dist/index.umd.mjs");
},
},
]);