Added bun bundle

This commit is contained in:
2025-08-10 20:57:27 +02:00
parent 30e18257d0
commit b4f0a2c8dc
16 changed files with 88 additions and 98 deletions

37
scripts/build.ts Normal file
View File

@@ -0,0 +1,37 @@
import fs from "node:fs/promises"
const normalFiles = await Promise.all([
fs.readdir("src/commands"),
fs.readdir("src/commands-contextmenu"),
fs.readdir("src/components/autocomplete"),
fs.readdir("src/components/buttons"),
fs.readdir("src/components/modals"),
fs.readdir("src/events/cron")
])
const eventFiles = (await fs.readdir("src/events", { recursive: true })).filter(f => f.endsWith(".ts"))
const files = [
normalFiles[0].map(f => `src/commands/${f}`),
normalFiles[1].map(f => `src/commands-contextmenu/${f}`),
normalFiles[2].map(f => `src/components/autocomplete/${f}`),
normalFiles[3].map(f => `src/components/buttons/${f}`),
normalFiles[4].map(f => `src/components/modals/${f}`),
normalFiles[5].map(f => `src/events/cron/${f}`),
eventFiles.map(f => `src/events/${f}`)
].flat()
await Bun.build({
entrypoints: ["src/index.ts", ...files],
outdir: "dist",
target: "bun",
splitting: true,
sourcemap: "external",
naming: {
entry: "[dir]/[name].[ext]",
chunk: "chunk/[name]-[hash].[ext]",
asset: "asset/[name]-[hash].[ext]"
},
root: "src",
banner: "process.env.BUILD = 'true'"
})