perf(compile): 启用 bytecode + minify + inline sourcemap

- Bun 官方 bytecode caching:中型应用 startup ~2x(docs.bun.sh/docs/bundler/bytecode)
- minify:减小 bytecode 体积,二进制仅 +2MB sourcemap
- sourcemap inline:嵌入二进制,保证错误堆栈可读,并在 compile.ts 清理 bundler 残留的 *.js.map
This commit is contained in:
2026-04-25 14:05:01 +08:00
parent 20104a6d53
commit e28fe9dc7b
2 changed files with 14 additions and 0 deletions
+6
View File
@@ -49,12 +49,18 @@ const main = async () => {
entrypoints: [ENTRYPOINT],
outdir: OUTDIR,
compile: { outfile, target },
minify: true,
bytecode: true,
sourcemap: 'inline',
})
if (!result.success) {
throw new Error(result.logs.map(String).join('\n'))
}
// Bun bundler still writes *.js.map next to the binary even with inline sourcemap.
await rm(`${OUTDIR}/${ENTRYPOINT.replace(/\.ts$/, '')}.js.map`, { force: true })
console.log(`${target}${OUTDIR}/${outfile}`)
}