Problem
- There's no way to pass additional flags (e.g. --minify, --sourcemap, --bytecode) to bun build --compile during the adapter's
compile step.
- The sveltekit server entry uses top-level await, which causes bun build --compile --bytecode to fail with:
error: "await" can only be used inside an "async" function
- The gracefulShutdown handler runs twice on Ctrl+C because both SIGINT and SIGTERM fire, producing duplicate logs:
Stopping server...
Stopping server...
Stopped server
Stopped server
Proposed Changes
- All packages (sveltekit, nuxt, tanstack): Add a bunArgs option that passes additional flags to bun build --compile
- sveltekit: Wrap the server entry in an async IIFE to eliminate top-level await for --bytecode compatibility
- sveltekit: Add a guard to gracefulShutdown to prevent duplicate execution
Usage
// svelte.config.js
adapter({
bunArgs: ["--minify", "--sourcemap", "--bytecode"]
})
Problem
compile step.
error: "await" can only be used inside an "async" function
Stopping server...
Stopping server...
Stopped server
Stopped server
Proposed Changes
Usage