pnpm init
pnpm add -D typescript tsup vitest
npx tsc --init
tsup.config.ts
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
format: ["cjs", "esm"], // Build for commonJS and ESmodules
dts: true, // Generate declaration file (.d.ts)
splitting: false,
sourcemap: true,
clean: true,
});
{
"scripts": {
"build": "tsup",
"test": "vitest"
}
}