unjs / unenv

πŸ•ŠοΈ Convert javaScript code to be runtime agnostic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unenv for SvelteKit

michael opened this issue Β· comments

Describe the feature

Hey there!

I just learned I can magically deploy Nuxt applications, referencing some node stuff in the imports on CloudFlare Pages, when I tried the same with SvelteKit. πŸ˜…

This like gave me troubles:

import Database from 'better-sqlite3';

I know very little about state of the art build pipelines, but I wonder if there's an easy way to activate unenv nodeless for SvelteKit applications. By configuring Vite? Or does this work differently? Happy to work on and document something that provides that, given that it's feasible and you can give me some pointers how to start.

πŸ™
Michael

Additional information

  • Would you be willing to help implement this feature?

Hi. In theory, it should be possible yes to integrate several unenv features.

You can check env from unenv is integrated into nitro rollup config. I suppose same can be integrated with it's Vite configuration.

On a related topic I have not much knowledge about internals of SvelteKit but an alternative approach could be (similar to Nuxt) to pass Svelte build output into a Nitro build pipeline as well to leverage all provider supports and zero code change.

Hi @pi0 thank you for the pointers. I think I will try to start a conversation about this within the Svelte community (they'll surely have thoughts about it) and come back here if more questions come up.

Thanks for this important work!