Skip to content

Commit c4ae1ab

Browse files
feat: updates build process
1 parent 1a65b5b commit c4ae1ab

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"dist"
6969
],
7070
"scripts": {
71-
"build": "bun run ./script/build.ts",
71+
"build": "tsup",
7272
"format": "bun x prettier --write '**/*.{js,jsx,ts,tsx,json,md,yaml,yml}'",
7373
"release": "bun run build && changeset publish"
7474
},
@@ -86,6 +86,7 @@
8686
"git-cliff": "2.7.0",
8787
"globals": "^15.14.0",
8888
"prettier": "3.4.2",
89+
"tsup": "8.5.1",
8990
"typescript": "^5.7.3"
9091
},
9192
"dependencies": {

tsup.config.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defineConfig } from "tsup"
2+
import pkg from "./package.json"
3+
4+
function getEntriesFromExports(exportsField: any) {
5+
const entries: string[] = []
6+
7+
for (const key in exportsField) {
8+
const value = exportsField[key]
9+
10+
if (typeof value === "object" && value.import) {
11+
const path = value.import
12+
.replace("./dist/esm/", "./src/")
13+
.replace(/\.js$/, ".ts")
14+
15+
entries.push(path)
16+
}
17+
}
18+
19+
return entries
20+
}
21+
22+
export default defineConfig(() => {
23+
const entries = getEntriesFromExports(pkg.exports)
24+
25+
return {
26+
entry: entries,
27+
format: ["esm"],
28+
dts: true,
29+
outDir: "dist/esm",
30+
sourcemap: true,
31+
clean: true,
32+
splitting: false,
33+
external: ["payload"],
34+
}
35+
})

0 commit comments

Comments
 (0)