Skip to content

feat: serve static assets from the build manifest - #16908

Open
Nic-Polumeyv wants to merge 3 commits into
remove-polkafrom
manifest-static-assets
Open

feat: serve static assets from the build manifest#16908
Nic-Polumeyv wants to merge 3 commits into
remove-polkafrom
manifest-static-assets

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Closes #16565, fixes #11766.

Serving static assets from build manifest is 10 to 20% faster than sirv on a local loopback benchmark, winning all eight comparisons across two interleaved rounds of plain, brotli, icon, and extensionless-alias requests at 20 concurrent keep-alive connections.

Currently, the static file server re-derives at request time what the build already computed. adapter-node now writes two tables into the emitted manifest, one per mount, mapping every servable pathname (including precomputed foo.html/foo/index.html aliases in sirv's resolution order) to its file, size, content-hash ETag and compressed-variant sizes/hashes. Serving (src/static.js) is a map lookup and a stream, Vary is sent exactly when a variant exists (which retires uncompressed_extensions and the over-send #16566 had to work around), and the range handling is RFC 7233 (bytes=0-0 returned the whole file under sirv, bytes=-3 was off by one — the former is the probe HTML5 video and PDF.js use). sirv, @polka/url and their transitive mrmime/totalist drop out of the adapter, along with the 27kB sirv chunk in the build output.

manifest.mimeTypes is now also seeded from client output extensions (same mechanism as the prerendered seeding from #16564), since .js/.css/imported-asset types previously came from sirv's bundled mrmime.

Deliberate behavior changes: ETags are content hashes instead of mtime-derived (stable across rebuilds of identical files), Last-Modified is no longer sent (deploy processes reset mtimes, and the ETag supersedes it), Accept-Ranges is always advertised, and files with unknown extensions omit Content-Type instead of sending an empty one. Base-path key construction follows the same ${base} composition the old asset_dir used, but no adapter-node test app exercises a base path - that's a pre-existing coverage hole.

Sits on #16907; only the last commit is new.

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 22, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 050fcd5:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/050fcd534fe0a32060ddd510cb3feefae15abdbc

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

@changeset-bot

changeset-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 050fcd5

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

This PR includes changesets to release 2 packages
Name Type
@sveltejs/adapter-node Minor
@sveltejs/kit Patch

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

@Nic-Polumeyv
Nic-Polumeyv force-pushed the manifest-static-assets branch 2 times, most recently from d59c710 to 81ea893 Compare August 22, 2026 19:29
@Nic-Polumeyv
Nic-Polumeyv force-pushed the manifest-static-assets branch from 81ea893 to 1192a76 Compare August 22, 2026 19:31
@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review August 22, 2026 19:50
Comment thread packages/adapter-node/src/static.js Outdated
Key the prerendered table by the exact paths kit prerendered, which removes
the prerendered set and the request-time gate that filtered out unreachable
alias keys. The manifest now ships one string per prerendered page instead
of four. Fold create_asset_map into serve_static and resolve content types
once at boot instead of per request.
An unhandled read stream error (a file deleted from the build output,
EMFILE) crashed the process. Headers are already sent by then, so drop
the connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serve static assets from the build manifest adapter-node does not serve filenames that end with +

1 participant