-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsup.config.ts
29 lines (28 loc) · 894 Bytes
/
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
import { readFileSync, rmSync, writeFileSync } from "node:fs";
import { rm } from "node:fs/promises";
import { defineConfig } from "tsup";
export default defineConfig([
{
entry: ["src/index.ts", "src/cli.ts"],
format: ["cjs", "esm"],
outDir: "dist",
dts: true,
minify: "terser",
treeshake: "smallest",
external: ["vitest", "typescript"],
noExternal: ["defu", "ignore"],
splitting: true,
async onSuccess() {
// beforeExit because onSuccess runs before dts is built
process.on("beforeExit", () => {
rmSync("dist/index.d.mts");
rmSync("dist/cli.d.mts");
rmSync("dist/cli.d.ts");
rmSync("dist/cli.js");
const rawJson = readFileSync("npm-shrinkwrap.json");
const json = JSON.parse(rawJson.toString());
writeFileSync("npm-shrinkwrap.json", JSON.stringify(json));
});
},
},
]);