kit icon indicating copy to clipboard operation
kit copied to clipboard

serve static assets from the build manifest

Open Nic-Polumeyv opened this issue 4 months ago • 0 comments

Describe the problem

The static file server re-derives at request time what the build already computed, and each gap surfaces as its own bug:

  • MIME types: sirv bundles its own mrmime, so kit's utils/mime.js additions never reach adapter-node (#13753; patched at the response layer by #16564)
  • Vary: Accept-Encoding sent for assets that were never precompressed (#15182, #16566)
  • filenames ending in + 404 in production but resolve in dev (#11766, still reproduces on 3.0.2)
  • startup totalist walk rebuilds a lookup the build already has; ETag is mtime-derived, not content-derived

Describe the proposed solution

Record the two things adapt time knows and currently discards (which files builder.compress produced variants for, and a content hash), then serve from the manifest: lookup and stream. Type from manifest.mimeTypes, Vary only where a variant exists, exact keys instead of path-guessing, no startup walk. sirv, totalist, @polka/url and mrmime drop out of adapter-node as a consequence. Exporting the server from @sveltejs/kit/node keeps adapter-node on one copy.

Alternatives considered

Upstreaming: sirv#173 open unreviewed since January, last release September 2025. Vendoring sirv's 249 lines as-is: fixes MIME but keeps the runtime re-derivation.

Importance

nice to have

Nic-Polumeyv avatar Jul 29 '26 18:07 Nic-Polumeyv