Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SvelteKit #600

Closed
niiwade opened this issue Jul 11, 2022 · 22 comments
Closed

Support SvelteKit #600

niiwade opened this issue Jul 11, 2022 · 22 comments
Assignees
Labels
ecosystem Something that relates to package or framework compatibility enhancement New feature or request

Comments

@niiwade
Copy link

niiwade commented Jul 11, 2022

What is the problem this feature will solve?

We need to have Svelte to be included in the project creation step to make it easy to using Bun to create Sveltekit apps.

What is the feature you are proposing to solve the problem?

We need bun create svelte ./app to make it easy to create a new svelte project

What alternatives have you considered?

No response

@niiwade niiwade added the enhancement New feature or request label Jul 11, 2022
@FinnRG
Copy link
Collaborator

FinnRG commented Jul 11, 2022

@niiwade Would you like to create a PR for this?

@niiwade
Copy link
Author

niiwade commented Jul 11, 2022

yes sure

@swyxio
Copy link

swyxio commented Jul 11, 2022

note that there is a community adapter here you can maybe crib from https://github.com/gornostay25/svelte-adapter-bun

@niiwade
Copy link
Author

niiwade commented Jul 11, 2022

note that there is a community adapter here you can maybe crib from https://github.com/gornostay25/svelte-adapter-bun

Thank you @sw-yx , am checking it out

@ryanrussell
Copy link
Contributor

ryanrussell commented Jul 30, 2022

Any good news on SvelteKit + bun runtime?

This would be a great framework to get first class support for in bun.

image

@Electroid Electroid added ecosystem Something that relates to package or framework compatibility and removed templates labels Nov 2, 2022
@paperclover paperclover changed the title Create Sveltekit Apps using Bun Support SvelteKit Jul 22, 2023
@paperclover paperclover mentioned this issue Jul 22, 2023
@paperclover
Copy link
Member

Status on SvelteKit:

  • It depends on worker_threads, though not much of it. Just parentPort and new Worker, and passing env data.
  • Since we do not export anything in worker_threads, it causes vite to crash loading the config file.

@kansson
Copy link

kansson commented Aug 3, 2023

SvelteKit is now working with bun upgrade --canary until v0.7.2 is released 🚀
EDIT: There is still some work to be done see #600 (comment).

@gitblit
Copy link

gitblit commented Aug 3, 2023

This was a nice surprise. Thanks for commenting @hanssonduck . Looks like there are some minor console tty issues on Vite and some HMR issues too, although fair to say those are not SvelteKit directly. On a starter app built from the Svelte bootstrapping command, I have success. On a more complex app, I have hanging requests. Not sure why yet. But overall getting closer!!

image

@paperclover
Copy link
Member

Worker threads got it so importing sveltekit stopped throwing, which gets us past the vite config load step.

But

We're not fully there yet, unfortunately. I've spotted some reliability issues with actions and .formData(), where the promise never resolved. Though small reproductions dont actually recreate the issue. Something subtle with our streams implementation.

Looking into it and maybe we'll have it fully working by 0.7.3.

@paperclover
Copy link
Member

paperclover commented Aug 5, 2023

update: found what is blocking sveltekit actions from working:

const headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Set-Cookie", "cookies");
const entries = Array.from(headers);
expect(entries).toEqual([
  ["content-type", "application/json"],
  ["set-cookie", "cookies"],
]);

what bun is doing is duplicating the content-type header, meaning cookies never get set.

this took a very long time to narrow down haha

@paperclover
Copy link
Member

the set cookie pr will make dev server fully functional. there is a different issue that is tracked by #3943 but i htink we should keep this issue open until that is fixed as this a broader tracking issue.

we are close. i imagine this week / next release

@paperclover
Copy link
Member

did i say this week actually meant now after #4052

@gitblit
Copy link

gitblit commented Aug 8, 2023

@paperdave are there special considerations for running SvelteKit with Bun like changing the adapter or some other tweak? Forms are still hanging on me. Looks related to websockets. I'm running all the latest packages and the latest canary build on WSL2.

image

@birkskyum
Copy link
Collaborator

birkskyum commented Aug 8, 2023

@gitblit I don't think the canary has been updated since this fix was added. You can see here under canary when it was updated last - some 22h ago. The only way you can test this now would be to build bun locally, which actually isn't that hard, or just try again tomorrow.

@gitblit
Copy link

gitblit commented Aug 8, 2023

I'll admit I don't know exactly how the binaries are served. The README suggests canary is built on every push to main and I was assuming they are downloaded from Github artifacts and not from a Docker container, but that might not be a valid assumption.

@birkskyum
Copy link
Collaborator

@gitblit interesting, you might be right about that. In that case I wonder why the canary docker image isn't kept in sync.

@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented Aug 8, 2023

Canary is compiled on every commit to main. Here is the most recent one for Linux x64 at the time of writing: https://github.com/oven-sh/bun/actions/runs/5794742061

The bun-linux-x64 one is the artifact which becomes the canary build of bun

@gitblit
Copy link

gitblit commented Aug 24, 2023

The 0.8.0 canary is now running my SvelteKit app almost perfectly. The fix for hanging await formData mentioned on Twitter addresses the scenario I noted here. I will post the remaining issue I observe as a new ticket.

@birkskyum
Copy link
Collaborator

There is something going on here - sveltekit often freezes and doesn't manage to boot the server.

@Tyjust31
Copy link

Tyjust31 commented Nov 10, 2023

For the development of bun run dev, I prefer to use a plugin like vite directly on vs code store because there is a bug

@Tyjust31
Copy link

To build for production, you'll need to add the right SvelteKit adapter. Currently we recommend the

bun add -D svelte-adapter-bun.

Now, make the following changes to your svelte.config.js.

@birkskyum
Copy link
Collaborator

Let's see what the svelte summit tomorrow brings of announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem Something that relates to package or framework compatibility enhancement New feature or request
Projects
None yet
Development

No branches or pull requests