Replies: 3 comments 3 replies
-
|
Hi, you should make this a feature request for better visibility, I don't see maintainers reacting here often. |
Beta Was this translation helpful? Give feedback.
-
|
Haven’t looked into this, but what’s the difference between this approach and what we’re currently doing for split functions in the Vercel and Netlify adapters? |
Beta Was this translation helpful? Give feedback.
-
|
Great question. I actually hadn't looked at the Vercel and Netlify split implementations before. The Netlify approach is quite close to what I'd like to achieve long-term: each function is a thin That said, even with Netlify's approach, each function still loads the full SvelteKit Vercel's approach is heavier: each What OpenWorkers does differently is the opposite direction: instead of starting from the full Server and filtering down, we start from nothing and only add what each endpoint actually needs. Build-time static analysis detects whether each I ran all three on httpbin, a SvelteKit app with 32 API routes:
The tradeoff is that this lightweight approach currently only works for That's the core of my proposal: the official adapters don't need these internals because they delegate to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
SvelteKit builds a single monolithic manifest and
Serverinstance. This works well for traditional deployments, but makes it hard for serverless runtimes that want to deploy routes as independent lightweight workers.Adapter authors who want to build minimal per-route handlers currently have to reach into SvelteKit internals via path aliasing:
This works but is fragile — these are undocumented internal paths that could break on any release.
Use case
I'm building OpenWorkers, a self-hosted serverless runtime in Rust with V8 isolates. The SvelteKit adapter I've built can compile each
+server.tsinto a standalone mini-worker with per-route isolation and independent scaling.To build a proper
RequestEventin these mini-workers, I need access to:get_cookies,add_cookies_to_headers)parse_route_id,exec)These are currently buried in
src/runtime/server/andsrc/utils/.Proposal
Two levels of improvement, from smallest to most ambitious:
1. Expose key utilities as public API (quick win)
Expose cookie handling and route matching as documented, stable imports — something like:
This alone would unblock adapter authors who build per-route handlers.
2. Per-route partial manifests (longer term)
Allow adapters to generate partial manifests per route at build time, containing only the resolved layout chain and minimal rendering context needed for a single page. This would enable per-route isolation for
+page.server.tstoo, not just+server.ts.Why this matters
Any serverless runtime with its own routing could benefit. Instead of routing everything through a single fat worker containing the entire app, each route becomes its own deployment unit with minimal cold start and a tiny bundle size.
Currently OpenWorkers can do this for API routes (
+server.ts) but not for pages, and relies on fragile internal imports to do even that.Happy to help prototype or test any of this!
Beta Was this translation helpful? Give feedback.
All reactions