feat: custom server entry points during development#16464
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/87d28dfb71e7cc3ca8d69554b19a9ca40bb37024Open in |
|
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), { |
There was a problem hiding this comment.
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
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>
…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>
…implementation is a bag of shite
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-entryID 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 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
Serverclass andmanifestfrom two different paths. My gut feeling is that it was originally designed that way to make generating split serverless functions easier as differentmanifests can be injected into each function entrypoint while reusing the sameServerclass 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:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits