refactor(devframe): replace sirv with h3-native static serving#330
Merged
Conversation
Add a small in-tree utility at `devframe/utils/serve-static` exposing
`serveStaticHandler` (h3 event handler) and `serveStaticNodeMiddleware`
(Connect-compatible) backed by a shared file-resolution function with
SPA fallback, MIME via `mrmime`, HEAD short-circuit, and path-traversal
guard. Swap all 8 sirv call sites across devframe adapters, kit's Vite
host, core's server + CLI, and example test utilities. Drop `sirv` from
the workspace catalog and from every package.json that listed it
(including two orphan entries in `packages/{rolldown,vite}` that never
imported it).
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Drops the
sirvdependency in favor of a small in-tree utility atdevframe/utils/serve-staticthat builds on h3 +mrmime(both already in the workspace catalog). Exposes two thin entry points sharing one resolver:serveStaticHandlerfor h3 apps (replacesfromNodeMiddleware(sirv(...))at 6 sites) andserveStaticNodeMiddlewarefor Vite's Connect middlewares (replaces directsirv(...)at 2 sites — avoids forcing@vitejs/devtools-kitto depend on h3 just to bridge an event handler). Behavior matches sirv's{ dev: true, single: true }mode:Cache-Control: no-store, SPA fallback toindex.htmlon extension-less misses,.htmlextension auto-resolve, path-traversal guard, HEAD short-circuit.sirvis removed from the workspace catalog and from everypackage.jsonthat listed it (including two orphan entries inpackages/{rolldown,vite}that never imported it).Linked Issues
None.
Additional context
The Vite-Connect outlier was the main shape question — review
packages/kit/src/node/vite-host.tsto confirm the Node-middleware variant is preferable to spinning up a per-mount throwaway h3 app. New utility has 13 unit tests covering direct hits, directory→index, SPA fallback, asset-looking 404, path traversal, HEAD, POST→405, percent-decoding, and.htmlparity.