Skip to content

breaking: replace builder.generateManifest with builder.generateServer and builder.getManifest - #16843

Closed
ottomated wants to merge 12 commits into
version-3from
adapter-generateServer
Closed

breaking: replace builder.generateManifest with builder.generateServer and builder.getManifest#16843
ottomated wants to merge 12 commits into
version-3from
adapter-generateServer

Conversation

@ottomated

Copy link
Copy Markdown
Contributor

alternative to #16827

Removes SSRManifest as a public api. Previously, adapters were using it directly; now they have a more limited api that mirrors $app/manifest. This ends up simplifying the code that adapters have to generate, because they only have to worry about a single server module vs server + manifest. It also removes the need for manifest._.foo in the internal code, which is nice.

Technically, SSRManifest is still used by some adapters (search server.manifest to find the uses). I don't know if we want to go all the way here and replace those with, i.e. rolldown defines?


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:.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 18, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 5c1787e:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/5c1787ec380d6590208a2f20c0eae80bedcf3833

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

@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5c1787e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@sveltejs/adapter-cloudflare Major
@sveltejs/adapter-netlify Major
@sveltejs/adapter-node Major
@sveltejs/adapter-vercel Major
@sveltejs/kit Major

Not sure what this means? Click here to learn what changesets are.

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

@svelte-docs-bot

Copy link
Copy Markdown

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Suggestion:

Netlify edge.js entry still uses the old new Server(manifest) API, so Server is undefined and the MANIFEST import is unresolved, breaking the edge function build.

Fix on Vercel

Comment thread packages/adapter-vercel/files/serverless.js
Comment thread packages/adapter-node/index.js
@Rich-Harris

Copy link
Copy Markdown
Member

Nice! This feels way better than what we have now. A few places where I think we could potentially go further:

  • would it make sense to have an API like builder.generateServer(dest, { routes }) that writes the file to dest (instead of returning a string) and figures out the relative path itself? i.e. instead of this...

    writeFileSync(
      `${tmp}/server.js`,
      builder.generateServer({
        relativePath: path.posix.relative(tmp, builder.getServerDirectory())
      })
    );

    ...this:

    builder.generateServer(`${tmp}/server.js`);

    It would also mean getting rid of the export option; the Netlify that adapter that currently uses it would just import the generated module:

    /**
    -* @param {string} server
     * @returns {string}
     */
    -function generate_serverless_function_module(server) {
    +function generate_serverless_function_module() {
      return `\
    import { init } from '../serverless.js';
    -${server}
    +import { server } from '../server.js';
    
    export default init(server);
    `;
    }

    (Might need a serverDirectory option alongside routes that points to the dir in builder.writeServer(dir), in the cases where that happens which IIUC is only Netlify. It would default to builder.getServerDirectory().)

  • Ideally I don't think we'd expose server.manifest at all, otherwise there's still an awkward public API that we will struggle to evolve. The adapters that need that stuff can use define (or equivalent) along with the config and manifest data that's available to builder:

    -const app_path = `/${server.manifest.app_path}`;
    +const app_path = APP_PATH;

    APP_PATH would basically be JSON.stringify(`${builder.config.paths.base}/${builder.config.appDir}`).

  • We're already computing the manifest data inside buildApp, should we just pass it directly as builder.manifest rather than builder.getManifest()?

  • If we did all that we'd presumably also need a builder.mimeTypes object or similar, since that's not exposed anywhere else and is needed by adapter-node

For the sake of the diff it might be easier to keep stuff under manifest._ for now, and tidy that up in a follow-up PR.

@ottomated

Copy link
Copy Markdown
Contributor Author

would it make sense to have an API like builder.generateServer(dest, { routes })

Makes sense, maybe builder.writeServerModule is better in that case?

It would also mean getting rid of the export option; the Netlify that adapter that currently uses it would just import the generated module

I don't think we can do that; that function is used to generate a bunch of serverless functions in a magic netlify folder, each with a unique set of routes. They would each need to write a server-functionname.js file to a separate folder I think, which just seems more complicated.

Ideally I don't think we'd expose server.manifest at all, otherwise there's still an awkward public API that we will struggle to evolve. The adapters that need that stuff can use define (or equivalent) along with the config and manifest data that's available to builder:

I somehow missed that config is passed to the builder, that should make it possible. Maybe also deprecate builder.getAppPath() in favor of builder.config.paths.base + builder.config.appDir?

(side note, it would make my life a lot easier on the cloudflare stuff if we could somehow pass the svelte config to the adapter function before adapt is called so it can be used in vite plugins)

We're already computing the manifest data inside buildApp, should we just pass it directly as builder.manifest rather than builder.getManifest()?

Makes sense to me. I'll do a second pass on all of this

Comment thread packages/kit/src/exports/vite/build/service-worker.js
@ottomated
ottomated force-pushed the adapter-generateServer branch 2 times, most recently from 6ecf024 to 9884263 Compare August 20, 2026 17:29
@ottomated ottomated closed this Aug 20, 2026
@ottomated
ottomated force-pushed the adapter-generateServer branch from 9884263 to 3ae5f22 Compare August 20, 2026 17:36
@ottomated ottomated reopened this Aug 20, 2026
@ottomated
ottomated marked this pull request as draft August 20, 2026 17:45
@ottomated ottomated closed this Aug 20, 2026
teemingc added a commit that referenced this pull request Aug 27, 2026
breaking #16843 into smaller pieces

This PR just removes all adapter code that accesses SSRManifest. #16876
is stacked on top of this and actually makes `SSRManifest` private,
which is the end goal.

---

### 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

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

### Changesets

- [x] 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:`.

---------

Co-authored-by: Tee Ming <chewteeming01@gmail.com>
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