feat(server): add compression support for production server#8595
feat(server): add compression support for production server#8595jack-old-archive wants to merge 3 commits into
Conversation
- Fix "unkown" -> "unknown" in streaming error message - Fix "preResovled" -> "preResolved" in comment - Fix "createRemixReuqest" -> "createRemixRequest" function name
The generated modern-app-env.d.ts is missing the @rsbuild/core/types reference, causing TypeScript errors for import.meta.env.DEV and other Rsbuild built-in environment variables. Closes web-infra-dev#8522
|
✅ Deploy Preview for modernjs-byted ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@Jack-sh1 Thanks for the PR — the motivation (compression without nginx/CDN) is valid. 👍 That said, I don't think this needs to live in the framework: Modern.js already exposes Hono middleware via the custom server (server/modern.server.ts), so users can enable hono/compress in a few lines: I verified this with modern serve: responses come back with content-encoding: gzip. This is basically what the plugin does internally, so server.compression is mostly a config alias over something already achievable. A couple of issues with the current implementation, FWIW:
Suggestion: document the recipe above instead of adding a new config/plugin. If you do want it built in, basing it on http-compression (already used by the dev server — supports brotli + a filter) would keep dev/prod consistent and make brotli actually work. Thanks again! |
@keepview Thanks for the thorough review! You're right about both issues — the brotli crash and the Accept-Encoding bypass are real bugs that need fixing. I'll address them. That said, I'd still like to keep this as a built-in feature for a couple reasons:
I'll refactor this PR to:
Would you be open to reviewing the updated implementation once it's ready? |
sure~ |

Summary
Add gzip/br/deflate compression middleware for the production server via
server.compressionconfig option.This allows developers to enable response compression without relying on a reverse proxy like nginx.
Usage: