Skip to content

feat: custom server entry points during development#16464

Open
teemingc wants to merge 59 commits into
version-3from
feat-server-entrypoint
Open

feat: custom server entry points during development#16464
teemingc wants to merge 59 commits into
version-3from
feat-server-entrypoint

Conversation

@teemingc

@teemingc teemingc commented Jul 21, 2026

Copy link
Copy Markdown
Member

split off from #15574

This PR moves dev manifest generation and server instantiation to their own modules away from the main Vite dev setup. Doing so provides a way for adapters to intercept the dev server instantiation by adding a Vite plugin which resolves the sveltekit:server-entry ID to its own server entry module. This allows us to reuse adapter or user server entrypoints during development so that it reflects the production build more closely. For example:

  • the static adapter can enable "prerendering" conditions that are normally only surfaced during build
  • the Node adapter can use the actual adapter handler code during both dev/production. We can also expose an option to specify the path of a custom server that can be used during development
  • it brings us one step closer to allowing a custom worker entrypoint for the Cloudflare adapter

The downside is that a good API for this hasn't been discussed beforehand, so there's probably room on the table to improving it rather than the current patching over existing APIs to get it working.

One idea was to pass an instantiated server to each handler rather than having to import the Server class and manifest from two different paths. My gut feeling is that it was originally designed that way to make generating split serverless functions easier as different manifests can be injected into each function entrypoint while reusing the same Server class import from the build output. If we do end up changing this, we'll have to refactor most of the existing adapter server handlers and that should be its own PR.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 21, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 87d28df:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/87d28dfb71e7cc3ca8d69554b19a9ca40bb37024

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16464

@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 87d28df

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@teemingc
teemingc marked this pull request as ready for review July 23, 2026 17:40
Comment thread packages/kit/src/exports/vite/dev/server.js Outdated
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
const type = manifest.mimeTypes[file.slice(file.lastIndexOf('.'))];

return new Response(read_implementation(file), {
return new Response(read_implementation(__SVELTEKIT_DEV__ ? from_fs(file) : file), {

@teemingc teemingc Jul 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Movedfrom_fs out of the dev read implementation to here so that adapters don't have to repeat from_fs when providing a read implementation

teemingc and others added 7 commits July 24, 2026 01:57
Co-authored-by: Nic Polumeyv <nicolas.polum@outlook.com>
Co-authored-by: Nic Polumeyv <nicolas.polum@outlook.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Base automatically changed from runnable-dev-environment to version-3 July 24, 2026 14:14
Rich-Harris added a commit that referenced this pull request Jul 24, 2026
…16490)

closes #11932

Makes sense to split this off from
#16464 since it's a relatively
simple change. Technically, this means we're 100% on the environment
API, but everything still runs on Node.js only. Main benefit is that we
have separate module graphs between the client and server now and one
step closer to adopting other parts of the environment API (fetchable
dev environments)

---

### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:
- [x] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it
solves.
- [ ] Ideally, include a test that fails without this PR but passes with
it.

### Tests
- [ ] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets
- [ ] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.

### Edits

- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Nic Polumeyv <nicolas.polum@outlook.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
Comment thread packages/kit/src/exports/vite/index.js Outdated
Comment thread packages/kit/src/exports/vite/index.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants