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:
@@ -67,6 +67,14 @@ Add a subcommand: drop a file in `src/cli/` that default-exports `defineCommand(
|
||||
|
||||
**Deploy flow is always migrate-then-serve.** The compiled binary bundles neither the `./drizzle/` SQL files nor the app schema migrations at runtime — they're read from disk next to the binary. Dockerfile copies `drizzle/` alongside `./server`, and `compose.yaml` models this with a one-shot `migrate` service that `app` `depends_on: service_completed_successfully`. On k8s, run `./server migrate` as an initContainer or a Helm `pre-upgrade` Job; run `./server` (= `./server serve`) as the main container.
|
||||
|
||||
## Compile flags
|
||||
|
||||
`compile.ts` builds with `--minify --bytecode --sourcemap=inline`:
|
||||
|
||||
- **`bytecode`** — pre-compiles JS to bytecode and embeds it in the binary; ~2x startup on app-sized binaries (Bun docs benchmark). Requires `--compile`; top-level `await` must live inside `async` functions (it already does in this repo).
|
||||
- **`minify`** — shrinks the binary and the bytecode it derives from.
|
||||
- **`sourcemap: 'inline'`** — embeds the source map in the binary so error stack traces stay decodable. Bun also writes a residual `out/bin.js.map` next to the output; `compile.ts` removes it so the binary is the only artifact.
|
||||
|
||||
## ORPC
|
||||
|
||||
Contract → Router → Handler → Client, all type-safe from a single contract.
|
||||
|
||||
Reference in New Issue
Block a user