bun build --compile doesn't work for sveltekit apps
What version of Bun is running?
1.1.38
What platform is your computer?
Linux 6.8.0-49-generic x86_64 x86_64
What steps can reproduce the bug?
reference docs:
- https://bun.sh/guides/ecosystem/sveltekit
- https://bun.sh/docs/bundler/executables
$ bunx sv create sveltekit-bun-app
┌ Welcome to the Svelte CLI! (v0.6.7)
│
◇ Which template would you like?
│ SvelteKit demo
│
◇ Add type checking with Typescript?
│ Yes, using Typescript syntax
│
◆ Project created
│
◇ What would you like to add to your project? (use arrow keys / space bar)
│ none
│
◇ Which package manager do you want to install dependencies with?
│ bun
$ cd sveltekit-bun-app
$ bun dev --open
this works ok, then
$ bun add -D svelte-adapter-bun
update svelte.config.js
// import adapter from "@sveltejs/adapter-auto";
import adapter from "svelte-adapter-bun";
create build
$ bun --bun run build
test build
$ bun --bun build/index.js
works ok
compile app
$ bun build build/index.js --compile --outfile bun-server
[34ms] bundle 32 modules
[99ms] compile bun-server
$ ll -h bun-server
-rwxrwxrwx 1 sas sas 93M Dec 12 12:43 bun-server*
execute it
$ ./bun-server
Listening on 0.0.0.0:3000
assets cannot be found
console output:
$ ./bun-server
Listening on 0.0.0.0:3000
error: Not found: /
at new SvelteKitError (/$bunfs/root/bun-server:992:7)
at /$bunfs/root/bun-server:18538:18
at resolve2 (/$bunfs/root/bun-server:18449:29)
at resolve (/$bunfs/root/bun-server:18396:42)
at /$bunfs/root/bun-server:18394:49
error: Not found: /favicon.png
at new SvelteKitError (/$bunfs/root/bun-server:992:7)
at /$bunfs/root/bun-server:18538:18
at resolve2 (/$bunfs/root/bun-server:18449:29)
at resolve (/$bunfs/root/bun-server:18396:42)
at /$bunfs/root/bun-server:18394:49
What is the expected behavior?
the app to work ok
What do you see instead?
the pasted screenshot
Additional information
same issue happens with deno: https://github.com/denoland/deno/issues/26155#issuecomment-2495622048
Same happens to me... I'm thinking that the issue comes from how bun choses what files to include into the exe: https://bun.sh/docs/bundler/executables#deploying-to-production by watching only "import and require".
And svelte compiles it's build, no css are imported into the js files
(I'm on windows)
same problem with deno, so I guess it should be the same solution for both
please have a look at https://github.com/denoland/deno/issues/26155#issuecomment-2495622048 to reproduce the issue
Yeah just tried with deno, and got the same issue
Built my own adapter to solve this, works well! We can now compile full-stack SvelteKit apps as a single binary executable (with all Kit features such as SSR, API endpoints, server hooks, remote functions...)
Built my own adapter to solve this, works well! We can now compile full-stack SvelteKit apps as a single binary executable (with all Kit features such as SSR, API endpoints, server hooks, remote functions...)
This is great! I'm starring it and will definitely give it a try, and I hope bun devs could have a look at it so we can have bun compile sveltekit apps out of the box
Just stumbled across this issue, as I was testing bun compilation. What I'm seeing is a complete request hang, even though the compiled executable emits logs just fine.
Steps
- Install sveltekit and setup the demo app.
bun run buildbun build(runs from the builtbuilddirectory). All requests are served properly,curl localhost:3000works fine.bun build --compile --production --outfile test build
Output:
╰─ bun build --production --compile --outfile test build2
[6ms] minify -244.54 KB (estimate)
[3ms] bundle 24 modules
[17ms] compile test
Running ./test:
Listening on http://0.0.0.0:3000
Output of curl request:
╰─ curl -vvv localhost:3000
12:06:13.197636 [0-x] == Info: [READ] client_reset, clear readers
12:06:13.197692 [0-0] == Info: Host localhost:3000 was resolved.
12:06:13.197728 [0-0] == Info: IPv6: ::1
12:06:13.197744 [0-0] == Info: IPv4: 127.0.0.1
12:06:13.197770 [0-0] == Info: [SETUP] added
12:06:13.197811 [0-0] == Info: Trying [::1]:3000...
12:06:13.197925 [0-0] == Info: connect to ::1 port 3000 from ::1 port 52696 failed: Connection refused
12:06:13.197985 [0-0] == Info: Trying 127.0.0.1:3000...
12:06:13.198051 [0-0] == Info: Connected to localhost (127.0.0.1) port 3000
12:06:13.198085 [0-0] == Info: using HTTP/1.x
12:06:13.198126 [0-0] => Send header, 78 bytes (0x4e)
0000: GET / HTTP/1.1
0010: Host: localhost:3000
0026: User-Agent: curl/8.11.1
003f: Accept: */*
004c:
12:06:13.198204 [0-0] == Info: Request completely sent off
^C
So it accepts the request, and then just never responds.